Skip to content

Commit

Permalink
Update debian init to work with start-stop-daemon instead of daemon
Browse files Browse the repository at this point in the history
  • Loading branch information
ctavan committed Nov 9, 2012
1 parent 0b18c7f commit 465e4bb
Showing 1 changed file with 25 additions and 27 deletions.
52 changes: 25 additions & 27 deletions debian/init
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ test -x $DAEMON || exit 0

LOGDIR=/var/log/tablesnap
PIDFILE=/var/run/$NAME.pid
DODTIME=1 # Time to wait for the server to die, in seconds
# If this value is set too low you might not
# let some servers to die gracefully and
# 'restart' will not work

# Define LSB log_* functions.
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
. /lib/lsb/init-functions

# Include defaults if available
if [ -f /etc/default/tablesnap ] ; then
Expand All @@ -37,40 +37,38 @@ fi

set -e

running()
{
daemon --running --name $NAME
return $?
daemon_start() {
log_daemon_msg "Starting $DESC daemon" "$NAME"
start-stop-daemon --start --quiet --oknodo --make-pidfile --background \
--name "$NAME" --pidfile $PIDFILE --exec $DAEMON -- $DAEMON_OPTS
status=$?
log_end_msg $status
}

daemon_stop() {
log_daemon_msg "Stopping $DESC daemon" "$NAME"
start-stop-daemon --stop --quiet --oknodo --pidfile $PIDFILE \
--name "$NAME"
log_end_msg $?
rm -f $PIDFILE
}

case "$1" in
start)
echo -n "Starting $DESC: "
daemon --name=$NAME --unsafe --pidfile=$PIDFILE --output=$LOGDIR/$NAME.log -- $DAEMON $DAEMON_OPTS
echo "$NAME."
;;
daemon_start || exit 1
;;
stop)
echo -n "Stopping $DESC: "
daemon --name=$NAME --stop
echo "$NAME."
;;
daemon_stop || exit 1
;;
restart)
echo -n "Restarting $DESC: "
daemon --name=$NAME --restart
echo "$NAME."
daemon_stop
daemon_start || exit 1
;;
status)
if running; then
echo "running"
exit 0
else
echo "stopped"
exit 1
fi
status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
;;
*)
N=/etc/init.d/$NAME
# echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2
echo "Usage: $N {start|stop|restart|status}" >&2
exit 1
;;
Expand Down

1 comment on commit 465e4bb

@ethan-eb
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a result of this change $LOGDIR is unused, and there is no equivalent to --output in start-stop-daemon ... any suggestions?

Please sign in to comment.