#!/bin/bash # lsb functions, to use those ugly colors.. . /lib/lsb/init-functions ### some default values ### PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin DEFAULT_DAEMON=/usr/bin/freepopsd DEFAULT_PIDFILE=/var/run/freepopsd.pid DEFAULT_CHROOTED_DAEMON_OPTS=" -n -s nobody.nogroup" DEFAULT_DAEMON_OPTS=" -n" NAME=freepopsd DESC="freepops daemon" ### /etc/default/ loading ### # Include freepops defaults if available. Used variables are: # DAEMON, DAEMON_OPTS, CHROOTED_DAEMON_OPTS, PIDFILE, CHROOT # all have a DEFAULT_ here, except CHROOT that is empty if the # daemon should run in the normal environment if [ -f /etc/default/freepops ] ; then . /etc/default/freepops fi if [ -z "$DAEMON" ] ; then DAEMON=$DEFAULT_DAEMON fi if [ -z "$PIDFILE" ] ; then PIDFILE=$DEFAULT_PIDFILE fi if [ -z "$DAEMON_OPTS" ] ; then DAEMON_OPTS=$DEFAULT_DAEMON_OPTS fi if [ -z "$CHROOTED_DAEMON_OPTS" ] ; then CHROOTED_DAEMON_OPTS=$DEFAULT_CHROOTED_DAEMON_OPTS fi test -x $DAEMON || exit 0 set -e ### helpers ### start_freepopsd () { if [ -z "$CHROOT" ] ; then log_daemon_msg "Starting $DESC" "$NAME" start-stop-daemon --start -b --quiet -m -p $PIDFILE \ --exec $DAEMON -- $DAEMON_OPTS log_end_msg $? else log_daemon_msg "Starting $DESC" "(chroot) $NAME" start-stop-daemon --start -b --quiet -m -p $PIDFILE \ -r $CHROOT --exec $DAEMON -- $CHROOTED_DAEMON_OPTS log_end_msg $? fi } stop_freepopsd () { if [ -z "$CHROOT" ] ; then log_daemon_msg "Stopping $DESC" "$NAME" start-stop-daemon --stop --quiet -p $PIDFILE log_end_msg $? else log_daemon_msg "Stopping $DESC" "(chroot) $NAME" start-stop-daemon --stop --quiet -p $PIDFILE log_end_msg $? fi rm $PIDFILE } ### real code ### case "$1" in start) start_freepopsd ;; stop) stop_freepopsd ;; restart|force-reload) stop_freepopsd sleep 1 start_freepopsd ;; *) N=/etc/init.d/freepops echo "Usage: $N {start|stop|restart}" >&2 exit 1 ;; esac exit 0