Remove tabs from init scripts

In reviewing the previous change, it became clear that these files were
very tab-happy, which makes reading changes in gertty sad. Clean that
up.

Change-Id: I922fb9b427a4147dc2368577a80f06d212e20c3e
This commit is contained in:
Monty Taylor 2015-11-15 09:08:50 -05:00
parent b03adc90a8
commit 183ef31e75
2 changed files with 176 additions and 172 deletions

View File

@ -38,26 +38,27 @@ USER=zuul
# #
do_start() do_start()
{ {
# Return # Return
# 0 if daemon has been started # 0 if daemon has been started
# 1 if daemon was already running # 1 if daemon was already running
# 2 if daemon could not be started # 2 if daemon could not be started
# 3 if pid file already exist # 3 if pid file already exist
mkdir -p /var/run/$NAME mkdir -p /var/run/$NAME
chown $USER /var/run/$NAME chown $USER /var/run/$NAME
ulimit -n 8192 ulimit -n 8192
if [ -f $PIDFILE ]; then if [ -f $PIDFILE ]; then
return 3 return 3
fi fi
start-stop-daemon --start --quiet --pidfile $PIDFILE -c $USER --exec $DAEMON --test > /dev/null \ start-stop-daemon \
|| return 1 --start --quiet --pidfile $PIDFILE -c $USER \
start-stop-daemon --start --quiet --pidfile $PIDFILE -c $USER --exec $DAEMON -- \ --exec $DAEMON --test > /dev/null || return 1
$DAEMON_ARGS \ start-stop-daemon \
|| return 2 --start --quiet --pidfile $PIDFILE -c $USER \
# Add code here, if necessary, that waits for the process to be ready --exec $DAEMON -- $DAEMON_ARGS || return 2
# to handle requests from services started subsequently which depend # Add code here, if necessary, that waits for the process to be ready
# on this one. As a last resort, sleep for some time. # to handle requests from services started subsequently which depend
# on this one. As a last resort, sleep for some time.
} }
# #
@ -65,75 +66,76 @@ do_start()
# #
do_stop() do_stop()
{ {
# Return # Return
# 0 if daemon has been stopped # 0 if daemon has been stopped
# 1 if daemon was already stopped # 1 if daemon was already stopped
# 2 if daemon could not be stopped # 2 if daemon could not be stopped
# other if a failure occurred # other if a failure occurred
start-stop-daemon --stop --signal 9 --pidfile $PIDFILE start-stop-daemon --stop --signal 9 --pidfile $PIDFILE
RETVAL="$?" RETVAL="$?"
[ "$RETVAL" = 2 ] && return 2 [ "$RETVAL" = 2 ] && return 2
rm -f /var/run/$NAME/* rm -f /var/run/$NAME/*
return "$RETVAL" return "$RETVAL"
} }
# #
# Function that sends a SIGHUP to the daemon/service # Function that sends a SIGHUP to the daemon/service
# #
do_reload() { do_reload() {
# #
# If the daemon can reload its configuration without # If the daemon can reload its configuration without
# restarting (for example, when it is sent a SIGHUP), # restarting (for example, when it is sent a SIGHUP),
# then implement that here. # then implement that here.
# #
start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name zuul-merger start-stop-daemon \
return 0 --stop --signal 1 --quiet --pidfile $PIDFILE --name zuul-merger
return 0
} }
case "$1" in case "$1" in
start) start)
[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME" [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
do_start do_start
case "$?" in case "$?" in
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
3) echo "Pidfile at $PIDFILE already exists, run service zuul-merger stop to clean up." 3) echo "Pidfile at $PIDFILE already exists, run service zuul-merger stop to clean up."
esac esac
;; ;;
stop) stop)
[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME" [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
do_stop do_stop
case "$?" in case "$?" in
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
esac esac
;; ;;
status) status)
status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $? status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
;; ;;
reload|force-reload) reload|force-reload)
# #
# If do_reload() is not implemented then leave this commented out # If do_reload() is not implemented then leave this commented out
# and leave 'force-reload' as an alias for 'restart'. # and leave 'force-reload' as an alias for 'restart'.
# #
log_daemon_msg "Reloading $DESC" "$NAME" log_daemon_msg "Reloading $DESC" "$NAME"
do_reload do_reload
log_end_msg $? log_end_msg $?
;; ;;
restart) restart)
# #
# 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_stop
do_start do_start
;; ;;
*) *)
#echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2 #echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2 echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2
exit 3 exit 3
;; ;;
esac esac
: :

View File

@ -38,26 +38,27 @@ USER=zuul
# #
do_start() do_start()
{ {
# Return # Return
# 0 if daemon has been started # 0 if daemon has been started
# 1 if daemon was already running # 1 if daemon was already running
# 2 if daemon could not be started # 2 if daemon could not be started
# 3 if pid file exits already # 3 if pid file exits already
mkdir -p /var/run/$NAME mkdir -p /var/run/$NAME
chown $USER /var/run/$NAME chown $USER /var/run/$NAME
ulimit -n 8192 ulimit -n 8192
if [ -f $PIDFILE ]; then if [ -f $PIDFILE ]; then
return 3 return 3
fi fi
start-stop-daemon --start --quiet --pidfile $PIDFILE -c $USER --exec $DAEMON --test > /dev/null \ start-stop-daemon \
|| return 1 --start --quiet --pidfile $PIDFILE -c $USER \
start-stop-daemon --start --quiet --pidfile $PIDFILE -c $USER --exec $DAEMON -- \ --exec $DAEMON --test > /dev/null || return 1
$DAEMON_ARGS \ start-stop-daemon \
|| return 2 --start --quiet --pidfile $PIDFILE -c $USER \
# Add code here, if necessary, that waits for the process to be ready --exec $DAEMON -- $DAEMON_ARGS || return 2
# to handle requests from services started subsequently which depend # Add code here, if necessary, that waits for the process to be ready
# on this one. As a last resort, sleep for some time. # to handle requests from services started subsequently which depend
# on this one. As a last resort, sleep for some time.
} }
# #
@ -65,16 +66,16 @@ do_start()
# #
do_stop() do_stop()
{ {
# Return # Return
# 0 if daemon has been stopped # 0 if daemon has been stopped
# 1 if daemon was already stopped # 1 if daemon was already stopped
# 2 if daemon could not be stopped # 2 if daemon could not be stopped
# other if a failure occurred # other if a failure occurred
start-stop-daemon --stop --signal 9 --pidfile $PIDFILE start-stop-daemon --stop --signal 9 --pidfile $PIDFILE
RETVAL="$?" RETVAL="$?"
[ "$RETVAL" = 2 ] && return 2 [ "$RETVAL" = 2 ] && return 2
rm -f /var/run/$NAME/* rm -f /var/run/$NAME/*
return "$RETVAL" return "$RETVAL"
} }
# #
@ -82,83 +83,84 @@ do_stop()
# #
do_graceful_stop() do_graceful_stop()
{ {
PID=`cat $PIDFILE` PID=`cat $PIDFILE`
kill -USR1 $PID kill -USR1 $PID
# wait until really stopped # wait until really stopped
if [ -n "${PID:-}" ]; then if [ -n "${PID:-}" ]; then
i=0 i=0
while kill -0 "${PID:-}" 2> /dev/null; do while kill -0 "${PID:-}" 2> /dev/null; do
if [ $i -eq '0' ]; then if [ $i -eq '0' ]; then
echo -n " ... waiting " echo -n " ... waiting "
else else
echo -n "." echo -n "."
fi fi
i=$(($i+1)) i=$(($i+1))
sleep 1 sleep 1
done done
fi fi
rm -f /var/run/$NAME/* rm -f /var/run/$NAME/*
} }
# #
# Function that sends a SIGHUP to the daemon/service # Function that sends a SIGHUP to the daemon/service
# #
do_reload() { do_reload() {
# #
# If the daemon can reload its configuration without # If the daemon can reload its configuration without
# restarting (for example, when it is sent a SIGHUP), # restarting (for example, when it is sent a SIGHUP),
# then implement that here. # then implement that here.
# #
start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name zuul-server start-stop-daemon \
return 0 --stop --signal 1 --quiet --pidfile $PIDFILE --name zuul-server
return 0
} }
case "$1" in case "$1" in
start) start)
[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME" [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
do_start do_start
case "$?" in case "$?" in
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
3) echo "Pidfile at $PIDFILE already exists, run service zuul stop to clean up." ;; 3) echo "Pidfile at $PIDFILE already exists, run service zuul stop to clean up." ;;
esac esac
;; ;;
stop) stop)
[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME" [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
do_stop do_stop
case "$?" in case "$?" in
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
esac esac
;; ;;
status) status)
status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $? status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
;; ;;
reload|force-reload) reload|force-reload)
# #
# If do_reload() is not implemented then leave this commented out # If do_reload() is not implemented then leave this commented out
# and leave 'force-reload' as an alias for 'restart'. # and leave 'force-reload' as an alias for 'restart'.
# #
log_daemon_msg "Reloading $DESC" "$NAME" log_daemon_msg "Reloading $DESC" "$NAME"
do_reload do_reload
log_end_msg $? log_end_msg $?
;; ;;
restart) restart)
# #
# 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_graceful_stop do_graceful_stop
do_start do_start
;; ;;
*) *)
#echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2 #echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2 echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2
exit 3 exit 3
;; ;;
esac esac
: :