0

I've created the following init.d script per this guide, which is designed to start this branch of MaNGOS at boot:

#!/bin/sh
### BEGIN INIT INFO
# Provides: mangosd
# Should-Start: console-screen dbus network-manager
# Required-Start: $all
# Required-Stop: $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: start mangosd at boot time
### END INIT INFO
#

set -e

/lib/lsb/init-functions

PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/sbin

SCRIPT="/usr/local/sbin/realmd.sh"
SCRIPT2="/usr/local/sbin/mangosd.sh"
PROGRAMNAME="realmd"
PROGRAMNAME2="mangosd"
case "$1" in
start)
     $SCRIPT
     $SCRIPT2
     ;;
stop)
     pkill $PROGRAMNAME
     pkill $PROGRAMNAME2
     ;;
esac

exit 0

I am able to run this script with sudo /etc/init.d/mangosd start, which will cause it to work as expected, running realmd.sh and mangosd.sh, which are as follows.

realmd.sh:

 #!/bin/sh
 # /usr/local/sbin/realmd.sh

 /home/rebirth/MaNGOS/bin/realmd &

mangosd.sh:

 #!/bin/sh
 # /usr/local/sbin/mangosd.sh

 cd /home/rebirth/MaNGOS/bin
 ./mangosd &

All three files have the same permissions, as follows:

 -rwxr-xr-x 1 root root 80 Sep  2 20:33 /usr/local/sbin/mangosd.sh

The programs realmd and mangosd will then run as expected. Per the guide, I have run sudo insserv mangosd and verified the boot file was created:

 $ ls -la /etc/rc2.d/S04mangosd
 lrwxrwxrwx 1 root root 17 Sep  2 18:00 /etc/rc2.d/S04mangosd -> ../init.d/mangosd

I ran sudo reboot and neither realmd nor mangosd started automatically at boot. Running the init.d script manually at this point still works as expected.

I have viewed the following posts relating to this issue:

Init.d script to start Hudson doesn't run at boot on Ubuntu

debian init.d script not running after reboot

Neither provided a solution, however the latter did have another command I hadn't tried, sudo update-rc.d mangosd defaults. Unfortunately, after running this command and rebooting, realmd and mangosd were still not running automatically at boot.

If anyone has any suggestions, or is able to point me in the right direction, I'd really appreciate it. Thank you very much!

Alex
  • 23
  • 6

1 Answers1

0

You can check on debian a file called skeleton, located in the directory /etc/init.d/, which is supposed to help people to get started with custom init.d services.

This line is not mandatory and you can remove it :

# Should-Start: console-screen dbus network-manager

Replace :

 /lib/lsb/init-functions

with

. /lib/lsb/init-functions

You should remove too :

set -e

If it's not working, you can try to set defaults required-start to this :

# Required-Start: $remote_fs $syslog

So final file can be : (not tested)

#!/bin/sh
### BEGIN INIT INFO
# Provides: mangosd
# Required-Start: $local_fs $remote_fs $network $syslog
# Required-Stop: $local_fs $remote_fs $network $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: start mangosd at boot time
### END INIT INFO
#

. /lib/lsb/init-functions

PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/sbin

SCRIPT="/usr/local/sbin/realmd.sh"
SCRIPT2="/usr/local/sbin/mangosd.sh"
PROGRAMNAME="realmd"
PROGRAMNAME2="mangosd"
case "$1" in
start)
     $SCRIPT
     $SCRIPT2
     ;;
stop)
     pkill $PROGRAMNAME
     pkill $PROGRAMNAME2
     ;;
esac

exit 0

These links can help you :

Debian wiki : https://wiki.debian.org/LSBInitScripts/

initscript example : https://gist.github.com/gsf/6222405

another example : https://gist.github.com/wallyqs/c96d56e735c74ee4cc1f

Krish
  • 33
  • 4