------------------------------------------------------------ revno: 5968 committer: David Martin <david.martin.mailbox@xxxxxxxxxxxxxx> branch nick: hipl_init-scripts timestamp: Tue 2011-06-21 14:50:02 +0200 message: Use start-stop-daemon in dnsproxy and hipfw debian init scripts. Both dnsproxy and hipfw init scripts now use the start-stop-daemon in a similar fashion as the hipd. This means: - it is not an error when the daemon is already running and start is called again, print a notice instead - let start-stop-daemon take care of exiting the daemon, it will send a TERM and wait for three seconds before killing it, there is no additional shell script magic necessary to test if the daemon is running This commit fixes the error return value of the dnsproxy in bug 795848. modified: debian/hipl-dnsproxy.init debian/hipl-firewall.init -- lp:hipl https://code.launchpad.net/~hipl-core/hipl/trunk Your team HIPL core team is subscribed to branch lp:hipl. To unsubscribe from this branch go to https://code.launchpad.net/~hipl-core/hipl/trunk/+edit-subscription
=== modified file 'debian/hipl-dnsproxy.init' --- debian/hipl-dnsproxy.init 2011-06-08 13:32:52 +0000 +++ debian/hipl-dnsproxy.init 2011-06-21 12:50:02 +0000 @@ -27,7 +27,7 @@ start_dnsproxy() { log_daemon_msg "Starting DNS proxy for HIP" "hipdnsproxy" - if start-stop-daemon --start --quiet --exec $EXEC -- $DNSPROXY_OPTS; then + if start-stop-daemon --start --oknodo --exec $EXEC -- $DNSPROXY_OPTS; then log_end_msg 0 else log_end_msg 1 @@ -36,12 +36,9 @@ stop_dnsproxy() { log_daemon_msg "Stopping DNS proxy for HIP" "hipdnsproxy" - if test -r $PID_FILE && ps $(head -1 $PID_FILE) > /dev/null; then # see bug id 812 - if start-stop-daemon --stop --pidfile $PID_FILE --quiet -- $DNSPROXY_OPTS; then - log_end_msg 0 - else - log_end_msg 1 - fi + # send TERM to the daemon, if it is still running after 3 seconds send kill + if start-stop-daemon --stop --retry 3 --oknodo --pidfile $PID_FILE; then + log_end_msg 0 else log_end_msg 1 fi @@ -56,7 +53,6 @@ ;; restart|force-reload) stop_dnsproxy - sleep 3 start_dnsproxy ;; status) === modified file 'debian/hipl-firewall.init' --- debian/hipl-firewall.init 2011-06-08 13:32:52 +0000 +++ debian/hipl-firewall.init 2011-06-21 12:50:02 +0000 @@ -10,7 +10,6 @@ ### END INIT INFO HIPFW_OPTS="-bklpF" -PID=$(pidof -o $$ hipfw) set -e @@ -48,19 +47,17 @@ ip6tables -X HIPFW-FORWARD 2> /dev/null } +start_hipfw() { + if start-stop-daemon --start --oknodo --exec /usr/sbin/hipfw -- $HIPFW_OPTS; then + log_end_msg 0 + else + log_end_msg 1 + fi +} + stop_hipfw() { - # Ensure that we don't try to kill init.d script itself - # Run this before killing hipfw because it also removes dangling rules! - if [ $PID ]; then - kill $1 $PID - log_end_msg 0 - else - log_end_msg 1 - fi -} - -start_hipfw() { - if start-stop-daemon --start --quiet --exec /usr/sbin/hipfw -- $HIPFW_OPTS; then + # send TERM to hipfw and if it is still running after 3 seconds send KILL + if start-stop-daemon --stop --retry 3 --oknodo --exec /usr/sbin/hipfw; then log_end_msg 0 else log_end_msg 1 @@ -81,7 +78,6 @@ log_daemon_msg "Restarting HIP firewall" "hipfw" flush_iptables stop_hipfw - sleep 3 start_hipfw ;; status)