0

I'm using S6 v3 with a working configuration until the latest addition, which I'm stuck with.

I'm trying to check whether an env. variable is certain value, so I can execute a command.

Here's what I have:

#!/usr/bin/with-contenv sh

if [["dev" = "$APP_ENV"]]; then\
    exec printf '#################################################################';\
fi

I've tried various variations, including the use of test function. No solutions to be found online.

I assume it's a silly issue. Please let me know what is the issue and where I can learn more about the syntax used with S6 executables (the script above runs as expected in host machine with #!/usr/bin/env sh)

alexbusu
  • 701
  • 4
  • 13

1 Answers1

0

After some research on the topic I've found that (according to s6 documentation) the up and down files are special: they're not shell scripts, but single command lines interpreted by execlineb. That means that an up file contains a single command line. So in my case, having a script with several instructions, here's how I solved the issue:

  • Created an executable file mounted in /etc/s6-overlay/scripts/my_script (the location is arbitrary)
  • Call that script in the up file, with env. vars (because I need them) like this:
with-contenv
/etc/s6-overlay/scripts/my_script

Also, maybe it is worth mentioning that pwd is not the WORKDIR that is defined in the container, so if you relay on that, then you need to cd first.

alexbusu
  • 701
  • 4
  • 13