summaryrefslogtreecommitdiffstats
path: root/init.d/noise
blob: 991f14b7b9d25da067599926266b0d20b1fdc265 (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
#!/bin/sh -e
### BEGIN INIT INFO
# Provides:          noise
# Required-Start:    $remote_fs $syslog dbus
# Required-Stop:     $remote_fs $syslog dbus
# Default-Start:     2 3 4 5
# Default-Stop:      1
# Short-Description: Start the noise "Telnet" server
# Description:       System mode startup script for
#                    the noise "Telnet" server.
### END INIT INFO

DAEMON=/root/noise/noise-server

test -x $DAEMON || exit 1

noise_pid() {
	ps aux | grep tcpserver | grep noise-as-user | awk '{print$2}'
}

noise_start() {
	"$DAEMON" &
}

noise_stop() {
	kill "`noise_pid`"
}

case "$1" in
	start|stop)
		noise_${1}
		;;
	restart|reload|force-reload)
		noise_stop
		noise_start
		;;
	#force-stop) ;;
	status)
		kill -s 0 "`noise_pid`"
		exit $?
		;;
	*)
		echo "Usage: /etc/init.d/noise {start|stop|force-stop|restart|reload|force-reload|status}"
		exit 1
		;;
esac

exit 0