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