docs/example-init.d-script
changeset 27 bce1f781f127
parent 26 a7f74dd6d4e5
child 28 91800c6af63b
equal deleted inserted replaced
26:a7f74dd6d4e5 27:bce1f781f127
     1 #!/bin/sh
       
     2 
       
     3 PATH=/sbin:/bin:/usr/sbin:/usr/bin
       
     4 
       
     5 pidfile_nexus=/var/run/fixbot_nexus.pid pidfile_logwatch=/var/run/fixbot_logwatch.pid
       
     6 logfile_nexus=/var/log/fixbot_nexus.log logfile_logwatch=/var/log/fixbot_logwatch.log
       
     7 
       
     8 RUN_DIR=/var/lib/fixbot/
       
     9 RUN_UID=nobody RUN_GID=nogroup
       
    10 NEXUS_OPTIONS=
       
    11 LOGWATCH_OPTIONS=
       
    12 
       
    13 args_nexus= args_logwatch=
       
    14 
       
    15 [ -r /etc/default/fixbot ] && . /etc/default/fixbot
       
    16 
       
    17 case "$1" in
       
    18     start)
       
    19         echo "Starting fixbot:"
       
    20         echo -n "   nexus... "
       
    21 
       
    22         start-stop-daemon --start --quiet --exec /usr/bin/twistd -- \
       
    23             --uid="$RUN_UID"                \
       
    24             --gid="$RUN_GID"                \
       
    25             --pidfile="$pidfile_nexus"      \
       
    26             --rundir="$RUN_DIR"             \
       
    27             --logfile="$logfile_nexus"      \
       
    28             fixbot_nexus                    \
       
    29             $NEXUS_OPTIONS                  \
       
    30         && echo "[OK]" || echo "[FAIL]"
       
    31         
       
    32         echo -n "   logwatch... "
       
    33 
       
    34         start-stop-daemon --start --quiet --exec /usr/bin/twistd -- \
       
    35             --uid="$RUN_UID"                \
       
    36             --gid="$RUN_GID"                \
       
    37             --pidfile="$pidfile_logwatch"   \
       
    38             --rundir="$RUN_DIR"             \
       
    39             --logfile="$logfile_logwatch"   \
       
    40             fixbot_logwatch                 \
       
    41             $LOGWATCH_OPTIONS               \
       
    42         && echo "[OK]" || echo "[FAIL]"
       
    43     ;;
       
    44 
       
    45     stop)
       
    46         echo -n "Stopping fixbot:   "
       
    47         
       
    48         echo -n "logwatch...    "	
       
    49         start-stop-daemon --stop --quiet    \
       
    50             --pidfile "$pidfile_logwatch"
       
    51 
       
    52         echo -n "nexus...   "
       
    53         start-stop-daemon --stop --quiet    \
       
    54             --pidfile "$pidfile_nexus"
       
    55         
       
    56         echo "done"
       
    57     ;;
       
    58 
       
    59     restart)
       
    60         $0 stop
       
    61         $0 start
       
    62     ;;
       
    63 
       
    64     force-reload)
       
    65         $0 restart
       
    66     ;;
       
    67 
       
    68     *)
       
    69         echo "Usage: $0 {start|stop|restart|force-reload}" >&2
       
    70         exit 1
       
    71     ;;
       
    72 esac
       
    73 
       
    74 exit 0