Skip to content

Commit

Permalink
example: fix status and restart for init.d
Browse files Browse the repository at this point in the history
Signed-off-by: Laurent Arnoud <laurent.arnoud@af83.com>
Signed-off-by: Julien Boyer <julien.boyer@af83.com>
  • Loading branch information
spk committed Mar 14, 2013
1 parent 8641404 commit 1d4ef4f
Showing 1 changed file with 13 additions and 18 deletions.
31 changes: 13 additions & 18 deletions examples/pids.init.d.sh
Expand Up @@ -43,7 +43,7 @@ SCRIPTNAME=/etc/init.d/$NAME
do_start() do_start()
{ {
su -l -c "source $PROFILE; $DAEMON start -d" $APP_USER su -l -c "source $PROFILE; $DAEMON start -d" $APP_USER
RETVAL="$?" RETVAL="$?"
return "$RETVAL" return "$RETVAL"
} }


Expand All @@ -53,10 +53,19 @@ do_start()
do_stop() do_stop()
{ {
su -l -c "source $PROFILE; $DAEMON stop" $APP_USER su -l -c "source $PROFILE; $DAEMON stop" $APP_USER
RETVAL="$?" RETVAL="$?"
return "$RETVAL" return "$RETVAL"
} }


#
# Function that restarts the daemon/service
#
do_restart()
{
su -l -c "source $PROFILE; $DAEMON restart" $APP_USER
RETVAL="$?"
return "$RETVAL"
}


case "$1" in case "$1" in
start) start)
Expand All @@ -76,29 +85,15 @@ case "$1" in
esac esac
;; ;;
status) status)
status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $? status_of_proc "${NAME}_supervisor" && exit 0 || exit $?
;; ;;
restart|force-reload) restart|force-reload)
# #
# If the "reload" option is implemented then remove the # If the "reload" option is implemented then remove the
# 'force-reload' alias # 'force-reload' alias
# #
log_daemon_msg "Restarting $DESC" "$NAME" log_daemon_msg "Restarting $DESC" "$NAME"
do_stop do_restart
case "$?" in
0|1)
do_start
case "$?" in
0) log_end_msg 0 ;;
1) log_end_msg 1 ;; # Old process is still running
*) log_end_msg 1 ;; # Failed to start
esac
;;
*)
# Failed to stop
log_end_msg 1
;;
esac
;; ;;
*) *)
echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2 echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2
Expand Down

0 comments on commit 1d4ef4f

Please sign in to comment.