File: init.d

package info (click to toggle)
darkstat 3.0.715-1
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 816 kB
  • sloc: ansic: 6,542; sh: 355; makefile: 172; php: 15
file content (127 lines) | stat: -rw-r--r-- 2,784 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#! /bin/sh
### BEGIN INIT INFO
# Provides:          darkstat
# Required-Start: $remote_fs $network
# Required-Stop:  $remote_fs 
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: start darkstat monitoring system at boot time
### END INIT INFO
#
# Please read /usr/share/doc/darkstat/README.Debian

set -e

. /lib/lsb/init-functions

PATH=/bin:/usr/bin:/sbin:/usr/sbin
DAEMON="/usr/sbin/darkstat"
NAME="darkstat"
DESC="darkstat network daemon"
INIT="/etc/darkstat/init.cfg"
HOMEDIR="/var/lib/darkstat"
PIDFILE="/var/run/$NAME.pid"
DIR="/var/lib/darkstat"

test -f $DAEMON || exit 0

test -f $INIT || exit 0


INTERFACE=""
PORT=""
BINDIP=""
LOCAL=""
DNS=""
DAYLOG=""
DB="--import darkstat.db --export darkstat.db"
FILTER=""

. $INIT

if [ "$START_DARKSTAT" = "no" ] ; then
  log_warning_msg "please change the value of START_DARKSTAT in $INIT, in order to start darkstat"
  exit 0
fi

test "$START_DARKSTAT" = "yes" || exit 0

case "$1" in
start)
  log_begin_msg "Starting $DESC : $NAME "
  if start-stop-daemon --start --quiet -b --exec $DAEMON -- \
      $INTERFACE \
      $PORT \
      --chroot $DIR \
      --pidfile $PIDFILE \
      $BINDIP \
      $LOCAL \
      $FIP \
      $DNS \
      $DAYLOG \
      $DB \
      $OPTIONS \
      -f "$FILTER"; then
      log_success_msg "done"
  else
      log_progress_msg "already running"
  fi
  log_end_msg 0
  ;;
stop)
  log_begin_msg "Stopping $DESC : $NAME... "
  if [ ! -f "$PIDFILE" ] ; then
	  log_progress_msg "not running"
  else
      if start-stop-daemon --quiet --oknodo --stop --name $NAME --pidfile $PIDFILE --retry 30; then
           rm -f $PIDFILE
	   log_success_msg "stopped"
      else
           log_progress_msg "not running"
      fi
  fi
  log_end_msg 0
  ;;
restart | force-reload)
  log_begin_msg "Restarting $DESC : $NAME "
  if [ ! -f "$PIDFILE" ] ; then 
     log_progress_msg "not running " 
  else
     if start-stop-daemon --stop --oknodo --name $NAME --pidfile $PIDFILE --retry 30; then
          rm -f $PIDFILE
      else
         log_progress_msg "$DESC : $NAME is not running"
         rm -f $PIDFILE
     fi
  fi
  sleep 1
  start-stop-daemon --start --quiet -b --exec $DAEMON -- \
      $INTERFACE \
      $PORT \
      --chroot $DIR \
      --pidfile $PIDFILE \
      $BINDIP \
      $LOCAL \
      $FIP \
      $DNS \
      $DAYLOG \
      $DB \
      $OPTIONS \
      -f "$FILTER"
  log_success_msg "done"  
  log_end_msg 0
  ;;
debug-run)
  log_success_msg "$0: this option is not longer available."
  log_success_msg "$0: please run darkstat with --no-daemon option"
  log_success_msg "$0: for more info please check darkstat(8)."
  ;;

*)
  N=/etc/init.d/$NAME
   log_success_msg "Usage: $N {start|stop|restart|force-reload|debug-run}" >&2
  exit 1
  ;;
esac

exit 0