summaryrefslogtreecommitdiffstats
path: root/ubuntu/maverick/kdenetwork/debian/lisa-trinity.init
blob: 54212288a220d4c2fdb3d866806acca300ab2b00 (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
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
#! /bin/sh
### BEGIN INIT INFO
# Provides:          lisa-trinity
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
### END INIT INFO


PATH=/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/sbin/lisa
NAME=lisa-trinity
PIDFILE=/var/run/$NAME.pid
DESC="LAN Information Server"

test -f $DAEMON || exit 0

set -e

is_running ()
{
	if [ -e "$PIDFILE" ]
	then
		#checking if program is running
		if [ -L /proc/`cat $PIDFILE`/exe ]
		then
		#checking for stale pidfile
			if grep -q $NAME /proc/`cat $PIDFILE`/cmdline 
			then
				#program is running and is called lisa
				return 0
			fi
		fi
		rm -f $PIDFILE
	fi
	#program is not running
	return 1
}

case "$1" in
  start)
  	if is_running
	then
		echo "$DESC is already running. Not doing anything"
		exit 0
	fi
	echo -n "Starting $DESC: "
	start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON \
		> /dev/null
	echo $(pidof lisa) > $PIDFILE
	echo "$NAME."
	;;
  stop)
  	if ! is_running
	then
		echo "$DESC is not running. Not doing anything"
		exit 0
	fi
	echo -n "Stopping $DESC: "
	start-stop-daemon --stop --quiet --oknodo --pidfile $PIDFILE \
		--exec $DAEMON
	rm -f $PIDFILE
	echo "$NAME."
	;;
  reload|force-reload)
	echo "Reloading $DESC configuration files."
	start-stop-daemon --stop --quiet --signal 1 --pidfile $PIDFILE \
		--exec $DAEMON
	;;
  status)
	echo -n "$DESC is "
	if ! is_running
	then 
		echo -n "not "
	fi
	echo "running."

  	;;
  restart)
	echo -n "Restarting $DESC: "
	start-stop-daemon --stop --quiet --oknodo --pidfile $PIDFILE \
		--exec $DAEMON
	rm -f $PIDFILE
	sleep 1
	start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON \
		> /dev/null
	echo $(pidof lisa) > $PIDFILE
	echo "$NAME."
	;;
  cond-restart)
  	if ! is_running
	then
		echo "$DESC is not running. Not doing anything"
		exit 0
	fi
	echo -n "Restarting $DESC: "
	start-stop-daemon --stop --quiet --oknodo --pidfile $PIDFILE \
		--exec $DAEMON
	rm -f $PIDFILE
	sleep 1
	start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON \
		> /dev/null
	echo $(pidof lisa) > $PIDFILE
	echo "$NAME."
	;;
  *)
	N=/etc/init.d/$NAME
	echo "Usage: $N {start|stop|restart|cond-restart|status|reload|force-reload}" >&2
	exit 1
	;;
esac

exit 0