enioka-Haute-Couture / jqm

An asynchronous job manager
Apache License 2.0
96 stars 25 forks source link

Start as initd service throught symlink fails #382

Open deiv opened 4 years ago

deiv commented 4 years ago

If jqm.sh is symlinked in /etc/init.d (as documentation states):

ln -s $JQM_ROOT/jqm.sh /etc/init.d/jqm

And started as root. It fails because the relaunching of the script, cant resolve the real filename of the script. Affected code:

if [ $(whoami) = "root" ]
then
    if [ "x${JQM_SERVICE_ACCOUNT}" = "x" ]
    then
        echo "Defaulting to account jqm for running the script. Set JQM_SERVICE_ACCOUNT to use a different account."
        JQM_SERVICE_ACCOUNT="jqm"
    fi
    echo "Re-launching script as ${JQM_SERVICE_ACCOUNT}"
    su - ${JQM_SERVICE_ACCOUNT} -c "export JQM_NODE=\${JQM_NODE:-${JQM_NODE}}; $(pwd -P)/$(basename $0) $*"
    exit $?
fi

It's failing because $(basename $0) it getting resolved as jqm not jqm.sh.

Thanks,

tuxella commented 4 years ago

Could you give the exact error message you get and the shell used by the JQM_SERVICE_ACCOUNT account?

deiv commented 4 years ago

Hi,

Error and shell: -bash: /home/jqm/jqm-2.2.2/jqm: No existe el fichero o el directorio

In my setup, I have the following soft links:

tuxella commented 4 years ago

I just tested, this should work ok.

Can you check /etc/init.d/jqm actually links to the shell script with \ls -l /etc/init.d/jqm ?

deiv commented 4 years ago

Here we go:

lrwxrwxrwx 1 root root 20 Jan 22 11:42 /etc/init.d/jqm -> /home/jqm/jqm/jqm.sh