During booting I can specify certain programs to start using the init.d using the startproc (and co.) methods. My problem is, that even though I change to a different user (options -u and -g), the HOME environment variable does not change accordingly (during boot none is available, and if I just call startproc manually, then the HOME dir will remain /root/) thus crashing the program I try to start as it wants to write to the HOME and gets a permission denied error. Is there a way to load up the specified user’s environmental variables with startproc?
It would be bad practice for a service startup script to read a user’s startup script, it would create a dependency on /home, which in some situations may not even be mounted. The correct way to do it is to make sure that any output is explicitly redirected to log files. If you cannot arrange this, at least do a cd /tmp or something like that.
Actually the reason for doing this is because of a software bug in the Deluge daemon (the program I want to start). It always writes something into the home dir.
Anyway, until the bug is corrected I managed to circumvent it by replacing ‘startproc’ with 'su deluge -c “…” '.
>
> Actually the reason for doing this is because of a software bug in the
> Deluge daemon (the program I want to start). It always writes something
> into the home dir.
>
> Anyway, until the bug is corrected I managed to circumvent it by
> replacing ‘startproc’ with 'su deluge -c “…” '.
>
>
You could define HOME prior to executing startproc
HOME=/tmp
export HOME
startproc …
Setting the variable and exporting it DO depend on which shell you’re using.
The above will definitely work with bash.
Thanks for all of your responses. I’ll check the newer versions of Deluge to see if the bug was corrected (as stated by the Deluge team), but if not, I certainly will try one of your solutions.