NETGEAR is aware of a growing number of phone and online scams. To learn how to stay safe click here.
Forum Discussion
Plukkie
Nov 28, 2007Aspirant
How to startup custom services at boottime automatically
Hi,
I just installed my first piece of code on the NV+, a streaming daemon "kissd". I wonder how I can get this service startup automatic at bootime on the Infrant?
I discovered there's only one startup script named "/etc/rc3.d/S99rc3" in runlevel 3.
What's the way to automatically startup custom daemons / services?
Regards,
Peter
I just installed my first piece of code on the NV+, a streaming daemon "kissd". I wonder how I can get this service startup automatic at bootime on the Infrant?
I discovered there's only one startup script named "/etc/rc3.d/S99rc3" in runlevel 3.
What's the way to automatically startup custom daemons / services?
Regards,
Peter
27 Replies
Replies have been turned off for this discussion
- yoh-dahGuideJust create a /etc/rc3.d/Sxxkissd file and call it from there.
- PlukkieAspirantYoh-dah,
Can I duplicate some script from /etc/init.d/ and just change the variables for my daemon "kissd"?
gr Peter - yoh-dahGuide
Plukkie wrote: Yoh-dah,
Can I duplicate some script from /etc/init.d/ and just change the variables for my daemon "kissd"?
gr Peter
It wouldn't be just variables you'd be changing. You'd need to change the daemon name as well. You can test by running something like "./Sxxkissd start" and "./Sxxkissd stop". - PlukkieAspirantHi Joh-Dah,
Created my custom script, it works.
Thank you. For the info of other Infrant users, hereby the scriptcontent:
nas01:~# ls -l /etc/rc3.d/
total 0
lrwxrwxrwx 1 root root 15 dec 1 23:18 S100kissd -> ../init.d/kissd
lrwxrwxrwx 1 root root 13 nov 26 15:25 S99rc3 -> ../init.d/rc3
nas01:~#
nas01:~# ls -l /etc/init.d/kissd
-rwxr-xr-x 1 root root 975 dec 3 10:58 /etc/init.d/kissd
nas01:~#
nas01:~# cat /etc/init.d/kissd
#! /bin/sh
#
# This file is created by Peter, the owner of this NAS.
#
# It starts the streaming daemon Kissd, which is used by Mediaplayers of Vendor KISS.
#
# Created 01 december 2007.
PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin
DAEMON=/usr/local/bin/kissd
CONFIG=/usr/local/etc/kissd.conf
PIDFILE=/var/run/kissd.pid
# Arguments to kissd
#
ARGS="-c $CONFIG -d"
test -x $DAEMON || exit 0
test -f $CONFIG || exit 0
case "$1" in
start)
echo -n "Starting Streaming Media Server: kissd"
start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- $ARGS
echo "."
;;
stop)
echo -n "Stopping Streaming Media Server: kissd"
start-stop-daemon --stop --quiet --pidfile $PIDFILE --exec $DAEMON
echo "."
;;
reload)
echo "Not implemented."
;;
force-reload|restart)
sh $0 stop
sh $0 start
;;
*)
echo "Usage: /etc/init.d/kissd {start|stop|restart|force-reload|reload}"
exit 1
;;
esac
exit 0
nas01:~# - PlukkieAspirantHi Joh-Dah,
I upgraded my streaming daemon to a new version, modified the startscript as necessary, but auto startup at boottime does nog work.
When the machine finished booting and I start the script manually, it works. Stopping and restarting also works??
Do you know what can be wrong here?
Below the info:
=================================================
nas01:/# ls -l /etc/init.d/kissdx
-rwxr-xr-x 1 root root 1278 dec 6 18:18 /etc/init.d/kissdx
nas01:/#
nas01:/# ls -l /etc/rc3.d/
total 0
lrwxrwxrwx 1 root root 16 dec 6 18:15 S100kissdx -> ../init.d/kissdx
lrwxrwxrwx 1 root root 13 nov 26 15:25 S99rc3 -> ../init.d/rc3
nas01:/#
nas01:/# ls -l /usr/local/bin/kissdx
-rwxr-xr-x 1 root root 387881 dec 5 16:57 /usr/local/bin/kissdx
nas01:/#
nas01:/# ls -l /usr/local/etc/kissdx.conf
-rw-r--r-- 1 root 50 6686 dec 6 10:51 /usr/local/etc/kissdx.conf
nas01:/#
nas01:/# cat /etc/init.d/kissdx
#! /bin/sh
#
# This file is created by Peter, the owner of this NAS.
#
# It starts the streaming daemon Kissdx, which is used by Mediaplayers of Vendor KISS.
#
# Created 06 december 2007.
PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin
DAEMON=/usr/local/bin/kissdx
CONFIG=/usr/local/etc/kissdx.conf
# Arguments to kissdx
#
STARTARGS="-c $CONFIG -d"
STOPARGS="-s FORCESTOP"
GRACESTOP="-s STOP"
RELOAD="-s RELOAD_CONFIG"
test -x $DAEMON || exit 0
test -f $CONFIG || exit 0
case "$1" in
start)
echo -n "Starting Streaming Media Server: kissdx"
start-stop-daemon --start --quiet --exec $DAEMON -- $STARTARGS
echo "."
;;
stop)
echo -n "Stopping Streaming Media Server: kissdx"
start-stop-daemon --stop --quiet --exec $DAEMON -- $STOPARGS
echo "."
;;
gracestop)
echo -n "Stopping Streaming Media Server Gracefully: kissdx"
start-stop-daemon --stop --quiet --exec $DAEMON -- $GRACESTOP
echo "."
;;
reload)
echo -n "Reloading Configfile: kissdx"
start-stop-daemon --start --quiet --exec $DAEMON -- $RELOAD
echo "."
;;
force-reload|restart)
sh $0 stop
sh $0 start
;;
*)
echo "Usage: /etc/init.d/kissdx {start|stop|gracestop|restart|force-reload|reload}"
exit 1
;;
esac
exit 0
nas01:/#
================================================
thank you in advance. - gknippelsAspirantPlukkie,
What I did to add (your) program to start up automatically at boot is:
create a small script called kissdx :
#!/bin/sh
/usr/sbin/kissdx -d -c /etc/kissdx.conf
store it in the directory /etc/init.d/
then call from that same directory
update-rc.d kissd defaults 20
This command will add it to the scripts for startup.
In case you would like to remove it simply type:
update-rc.d -f kissd remove
P.S. You also need to disable kissd (the old version you made available) because it uses the same port.
Let me know if you need further help. Thanks again for the nice programs.
Guido - gknippelsAspirantPlukkie,
Sorry I made two typos in the update-rc lines. I typed 'kissd' instead of 'kissdx'. So the correct lines should read
update-rc.d kissdx defaults 20
update-rc.d -f kissdx remove
Guido - PlukkieAspirantGuido,
It doesn't work for me. For the test I just created the simplest testscript you can imagine:
#! /bin/sh
/usr/local/bin/kissdx -c /ust/local/etc/kissdx.conf -d
I pushed it in /etc/init.d/ and created the startscripts with:
nas01:/etc/init.d# update-rc.d test defaults 60
Adding system startup for /etc/init.d/test ...
/etc/rc0.d/K60test -> ../init.d/test
/etc/rc1.d/K60test -> ../init.d/test
/etc/rc6.d/K60test -> ../init.d/test
/etc/rc2.d/S60test -> ../init.d/test
/etc/rc3.d/S60test -> ../init.d/test
/etc/rc4.d/S60test -> ../init.d/test
/etc/rc5.d/S60test -> ../init.d/test
nas01:/etc/init.d#
After the reboot, it isn't started.
I am thinking about the sequencing. There's only 1 startscript from Infrant in rc3.d, which is S99. This starts everything including networking probaby. Can it be, that kissdx refuses to start when networking isn't started yet?
But then again, I do not understand why it works at your Infrant?! - gknippelsAspirantPlukkie,
I don't know if it is important but I registered the scripts with:
update-rc.d kissdx defaults 20
I saw that you used 60. To be honest I don't know if it makes a difference.
Also, I would briefly verify that your script line
/usr/local/bin/kissdx -c /ust/local/etc/kissdx.conf -d
does indeed execute without any problems if you just type it at the prompt. Also, you are sure that the older kissd deamon isn't running anymore? If it is, it blocks the port that kissdx also want's to use.
That's all I can think of right now.
Good luck - PlukkieAspirantNetgear,
Can you please explain, the way I want to start my daemon is correct?
Related Content
NETGEAR Academy
Boost your skills with the Netgear Academy - Get trained, certified and stay ahead with the latest Netgear technology!
Join Us!