aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick J Cherry <patrick@bytemark.co.uk>2011-07-19 17:58:45 +0100
committerPatrick J Cherry <patrick@bytemark.co.uk>2011-07-19 17:58:45 +0100
commiteadb2e10670093ebd754d5041d8cce17bca10d4d (patch)
treeb872d2dc9a1b4495633a26599ceab13a48943a37
parent1c8bf33bd7663fcb67fe854d968670aa475173dd (diff)
Tidied up initscript
-rw-r--r--debian/mauvealert-server.init64
1 files changed, 32 insertions, 32 deletions
diff --git a/debian/mauvealert-server.init b/debian/mauvealert-server.init
index accea6c..55aec2d 100644
--- a/debian/mauvealert-server.init
+++ b/debian/mauvealert-server.init
@@ -48,22 +48,22 @@ do_start()
# 1 if daemon was already running
# 2 if daemon could not be started
- start-stop-daemon --start --quiet --pidfile $PIDFILE --startas $DAEMON --chuid $RUNASUSER --test > /dev/null \
- || return 1
+ start-stop-daemon --start --quiet --pidfile $PIDFILE --startas $DAEMON --chuid $RUNASUSER --test > /dev/null \
+ || return 1
start-stop-daemon --start --quiet --pidfile $PIDFILE --make-pidfile --chuid $RUNASUSER --background --startas $DAEMON -- \
$DAEMON_ARGS \
|| return 2
# Add code here, if necessary, that waits for the process to be ready
# to handle requests from services started subsequently which depend
# on this one. As a last resort, sleep for some time.
- count=0
+ count=0
- while [ $((count = count + 1)) -le 5 ] ; do
- echo -n .
- sleep 1
- start-stop-daemon --start --quiet --pidfile $PIDFILE --startas $DAEMON --chuid $RUNASUSER --test > /dev/null \
- || return 0
- done
+ while [ $((count = count + 1)) -le 5 ] ; do
+ echo -n .
+ sleep 1
+ start-stop-daemon --start --quiet --pidfile $PIDFILE --startas $DAEMON --chuid $RUNASUSER --test > /dev/null \
+ || return 0
+ done
return 2
}
@@ -78,7 +78,7 @@ do_stop()
# 1 if daemon was already stopped
# 2 if daemon could not be stopped
# other if a failure occurred
- start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME
+ start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --user $RUNASUSER
RETVAL="$?"
[ "$RETVAL" = 2 ] && return 2
# Wait for children to finish too if this is a daemon that forks
@@ -87,7 +87,7 @@ do_stop()
# that waits for the process to drop all resources that could be
# needed by services started subsequently. A last resort is to
# sleep for some time.
- start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --pidfile $PIDFILE --name $NAME
+ start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --pidfile $PIDFILE --user $RUNASUSER
[ "$?" = 2 ] && return 2
# Many daemons don't delete their pidfiles when they exit.
rm -f $PIDFILE
@@ -103,7 +103,7 @@ do_reload() {
# restarting (for example, when it is sent a SIGHUP),
# then implement that here.
#
- start-stop-daemon --stop --signal HUP --quiet --pidfile $PIDFILE --name $NAME
+ start-stop-daemon --stop --signal HUP --quiet --pidfile $PIDFILE --user $RUNASUSER
return 0
}
@@ -111,13 +111,13 @@ do_reload() {
# Function that sends a SIGUSR1 to reopen logfiles
#
do_reopenlogs() {
- start-stop-daemon --stop --signal USR1 --quiet --pidfile $PIDFILE --name $NAME
+ start-stop-daemon --stop --signal USR1 --quiet --pidfile $PIDFILE --user $RUNASUSER
return 0
}
case "$1" in
- start)
+ start)
[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
do_start
case "$?" in
@@ -125,7 +125,7 @@ case "$1" in
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
esac
;;
- stop)
+ stop)
[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
do_stop
case "$?" in
@@ -133,10 +133,10 @@ case "$1" in
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
esac
;;
- status)
- status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
- ;;
- reload|force-reload)
+ status)
+ status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
+ ;;
+ reload|force-reload)
#
# If do_reload() is not implemented then leave this commented out
# and leave 'force-reload' as an alias for 'restart'.
@@ -145,15 +145,15 @@ case "$1" in
do_reload
log_end_msg $?
;;
- #
- # This is for use by logrotate, as the post-rotate method.
- #
- reopen-logs)
- log_daemon_msg "Re-opening logs for $DESC" "$NAME"
- do_reopenlogs
- log_end_msg $?
- ;;
- restart)
+ #
+ # This is for use by logrotate, as the post-rotate method.
+ #
+ reopen-logs)
+ log_daemon_msg "Re-opening logs for $DESC" "$NAME"
+ do_reopenlogs
+ log_end_msg $?
+ ;;
+ restart)
#
# If the "reload" option is implemented then remove the
# 'force-reload' alias
@@ -161,7 +161,7 @@ case "$1" in
log_daemon_msg "Restarting $DESC" "$NAME"
do_stop
case "$?" in
- 0|1)
+ 0|1)
do_start
case "$?" in
0) log_end_msg 0 ;;
@@ -169,13 +169,13 @@ case "$1" in
*) log_end_msg 1 ;; # Failed to start
esac
;;
- *)
- # Failed to stop
+ *)
+ # Failed to stop
log_end_msg 1
;;
esac
;;
- *)
+ *)
#echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2
exit 3