[nSLUG] Startup scripts

Robert McKay robert at mckay.com
Sun Jan 7 14:07:09 AST 2007

On 1/7/07, David Payne <dapayne12 at gmail.com> wrote:
> Ok, that could be it, but I find it strange that the script works when
> I log in as root and run the startup script myself.
> Or does it default to the shell that I am logged into where as when the startup
> script is run at startup there would be no shell?

Yes. In this case because 1) You're root and 2) You specified -m which
preserves the environment including the $SHELL environment variable
which, if present, is used to select the shell.

When you run the script from init the SHELL environment variable is
not exported. It might be set by the interpreter of your script but
that won't be exported to su unless you explicitly export SHELL in
your script before calling su.

You could set the SHELL variable in the script and export it

export SHELL
su tsd -m -c ./teamspeak2-server_startupscript $1

or use su's -s option to su to force the shell:

cd /opt/tss2_rc2
su tsd -s /bin/sh -m -c ./teamspeak2-server_startupscript $1

Either of those should work.



More information about the nSLUG mailing list