summaryrefslogtreecommitdiffstats
path: root/ivan/ivan-startup
blob: 8a7f8daa8a5b3c5bf154fdc44ea9949025a3169b (plain)
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
#! /bin/sh
#
### BEGIN INIT INFO
# Provides:          evan
# Required-Start:    $remote_fs $network
# Required-Stop:     $remote_fs $network
# Should-Start:      $syslog $named
# Should-Stop:       $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start evan daemons
# Description:       

### END INIT INFO
#
# Based on Lubomir Bulej's Redhat init script.

DAEMON="/root/bin/evan"
PIDFILE="/var/lock/evan"
NAME="evan"
DESC="evan daemons"
TCONF="/etc/evan"

test -f $DAEMON || exit 0

[ -r /etc/default/evan ] && . /etc/default/evan


start() {
  [ -e $PIDFILE ] && echo "$PIDFILE already exists" && return 
  $DAEMON $EXTRA -d "$@" &
  echo $(($$+1)) > $PIDFILE #TODO fix this ugly hack!
}
stop() {
  [ ! -e $PIDFILE ] && echo "$PIDFILE does not exist" && return
  kill `cat $PIDFILE`
  #killall evan
  rm $PIDFILE
}

reload() {
  echo "do nothing"
  # do nothing
}

restart() {
  stop "$@"
  start "$@"
}

case "$1" in
  start)
    echo -n "Starting $DESC:" 
    start
  ;;
  stop)
    echo -n "Stopping $DESC:" 
    stop
  ;;
  reload|force-reload)
    echo -n "Reloading $DESC configuration:" 
    reload
  ;;
  restart)
    echo -n "Restarting $DESC:" 
    restart
  ;;
  *)
    echo "Usage: /etc/init.d/$NAME {start|stop|reload|restart|force-reload}"
    exit 1
  ;;
esac
echo "done"
exit 0