2
votes

I'm using debian 7 x64, I want to add a service autostart at boot but it doesn't work.

The command : "update-rc.d defaults" works good and return me : update-rc.d: using dependency based boot sequencing

My script working when I use the command : service start/stop But when I restart the computer, the service is down.

My script start by :

### BEGIN INIT INFO
# Provides:          scriptname
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start daemon at boot time
# Description:       Enable service provided by daemon.
### END INIT INFO

I don't understand what is wrong ?

Edit :

I tried another way for my script, I looked at this example : http://doc.ubuntu-fr.org/tutoriel/comment_transformer_un_programme_en_service and it works great. Always don't understand why the other way didn't work. Whatever it's good for me now, thank you for helping.

1
Have you added the script to /etc/init.d/ before running update-rc.d defaults, and has the script in /etc/init.d/ the proper rights (including execution flag)? Do you see any hint in /var/log/ (messages/dmesg/syslog)? - SaeX
Yes it is in /etc/init.d. The file authorizations are 755. I can launch a "service script start" and it works perfectly. I see nothing in logs, but I have many files in .gz ! - user3224275
@user3224275 Did you manage to solve the problem? I am experiencing the same one. Manually service is started or restarted without any problems. But it is not started automatically after system reboot. - ilya

1 Answers

0
votes

One of the reasons can be the fact, that during OS boot launch script can`t find Java in known places: env var JAVA_HOME, path /usr/bin/java, etc.

In my case, there was a message in /var/log/boot.log: Unable to find Java. It came from this part of launch.script:

# Find Java
if [[ -n "$JAVA_HOME" ]] && [[ -x "$JAVA_HOME/bin/java" ]]; then
    javaexe="$JAVA_HOME/bin/java"
elif type -p java > /dev/null 2>&1; then
    javaexe=$(type -p java)
elif [[ -x "/usr/bin/java" ]];  then
    javaexe="/usr/bin/java"
else
    echo "Unable to find Java"
exit 1
fi

To fix that you need to be sure, that Java is available in paths during OS boot. Or you can follow recommendations from deployment docs and use .conf file with JAVA_HOME value in it.