View previous topic :: View next topic |
Author |
Message |
leonixyz Tux's lil' helper
Joined: 18 Sep 2012 Posts: 76
|
Posted: Fri Oct 05, 2012 4:10 pm Post subject: [SOLVED] rc-update |
|
|
Hello,
I wrote the two following scripts in /etc/init.d/, made them executable (chmod +x filename), and added to rc-update as default services (rc-update add scriptname default).
When I start the system they doesn't start, but if i call manually "/etc/inid.d/scriptname start", the programs ar launched correctly.
I want to start them as default, where am i wrong?
Another question: when i start those services (manually like is described above), and want to stop one of them (/etc/init.d/scriptname stop), all two were killed because they have the same name in "ps". Is it possible to append a string to the process name? otherwise how can i stop only one of them?
Thanks
Code: | #!/bin/sh
case "$1" in
start)
python3 /sbin/xyzserver.py &
echo "The xyzbrowser server has been started."
;;
stop)
killall python3
echo "The xyzbrowser process has been killed."
;;
restart)
killall python3
echo "The xyzbrowser process has been killed."
python3 /sbin/xyzserver.py &
echo "The xyzbrowser server has been started."
;;
*)
echo "Usage: $0 {start|stop|restart}"
exit 1
;;
esac |
Code: | #!/bin/sh
case "$1" in
start)
python3 /sbin/xyzpinger.py &
echo "The xyzpinger has been started."
;;
stop)
killall python3
echo "The xyzpinger process has been killed."
;;
restart)
killall python3
echo "The xyzpinger process has been killed."
python3 /sbin/xyzserver.py &
echo "The xyzpinger has been started."
;;
*)
echo "Usage: $0 {start|stop|restart}"
exit 1
;;
esac |
Last edited by leonixyz on Sat Oct 06, 2012 2:35 pm; edited 1 time in total |
|
Back to top |
|
|
BitJam Advocate
Joined: 12 Aug 2003 Posts: 2508 Location: Silver City, NM
|
Posted: Fri Oct 05, 2012 5:26 pm Post subject: |
|
|
Take a look at the fine documentation on how to write init scripts for Gentoo. They need to start with: |
|
Back to top |
|
|
leonixyz Tux's lil' helper
Joined: 18 Sep 2012 Posts: 76
|
Posted: Sat Oct 06, 2012 8:29 am Post subject: |
|
|
thank you very much, now the scripts are executed at startup...
here is the code of one of them:
Code: | #!/sbin/runscript
start(){
python3 /sbin/xyzserver.py &
echo "The xyzbrowser server has been started."
}
stop(){
killall python3
echo "The xyzbrowser process has been killed."
}
restart(){
killall python3
echo "The xyzbrowser process has been killed."
python3 /sbin/xyzserver.py &
echo "The xyzbrowser server has been started."
}
|
how could i kill only one of them two, if the processes names are equal? ("python3")
It's not possible to append a string to the process name? (like "python3/scriptname")
should i note somehow the process id and kill them by id? how could i do that?
thanks |
|
Back to top |
|
|
BitJam Advocate
Joined: 12 Aug 2003 Posts: 2508 Location: Silver City, NM
|
Posted: Sat Oct 06, 2012 8:51 am Post subject: |
|
|
Take another look at the fine documentation. The start-stop-daemon function is designed to handle this problem. It puts the process id of the started process in the pidfile on startup and then kills that process on shutdown.
You really either need to read the documentation or at the very least try to mimic the scripts that are already in /etc/init.d. |
|
Back to top |
|
|
leonixyz Tux's lil' helper
Joined: 18 Sep 2012 Posts: 76
|
Posted: Sat Oct 06, 2012 3:37 pm Post subject: |
|
|
thank you another time..
follows one of the working scripts
i got some problems, solved
1) by adding #!/usr/bin/python3.2 in the first line of those .py scripts
2) by converting one of them with dos2unix because i got this error
/usr/bin/python3.2^M: bad interpreter: No such file or directory
Code: |
#!/sbin/runscript
start(){
ebegin "Starting xyzbrowser server"
start-stop-daemon --start --pidfile /var/run/xyzserver.pid --background --make-pidfile --exec /sbin/xyzserver.py
eend $?
}
stop(){
ebegin "Stopping xyzbrowser server"
start-stop-daemon --stop --pidfile /var/run/xyzbrowser.pid --exec /sbin/xyzserver.py
eend $?
}
restart(){
stop
start
} |
|
|
Back to top |
|
|
|