File: init.d

package info (click to toggle)
tama 1.0-3
  • links: PTS
  • area: main
  • in suites: slink
  • size: 128 kB
  • ctags: 72
  • sloc: ansic: 1,044; makefile: 55; sh: 45
file content (57 lines) | stat: -rw-r--r-- 1,407 bytes parent folder | download
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
#!/bin/sh
#
# start and stop the net tamagotchi server.

test -x /usr/sbin/tamad || exit 0

case "$1" in
	start)
echo -n "Starting net tamagotchi server: tamad"
		cd /var/lib/tama/ || exit 1
umask 077

		# Check if there is a process to match what's in the pid
		# file, by sending signal 0, which has no effect. This 
		# also checks to see if there is a pid file at all, BTW.
		if start-stop-daemon --quiet --stop --signal 0 \
			--pidfile /var/run/tama.pid --name tamad 2>/dev/null
		then
			echo " already running."
			exit
		fi

		su nobody -c '/sbin/start-stop-daemon --start --quiet --exec \
			/usr/sbin/tamad --pidfile /var/run/tama.pid' \
			>> /var/log/tama.log 2>&1 &

		echo $! > /var/run/tama.pid
		echo "."
		;;
	stop)
echo -n "Stopping net tamagotchi server: tamad"
		# Check if there is a process to match what's in the 
		# pid file, by sending signal 0, which has no effect.
		# This also checks to see if there is a pid file at 
		# all, BTW.
		if start-stop-daemon --quiet --stop --signal 0 \
			--pidfile /var/run/tama.pid --user nobody \
			--name tamad 2>/dev/null
		then
			start-stop-daemon --quiet --stop \
				--exec /usr/sbin/tamad \
				--pidfile /var/run/tama.pid \
				--user nobody \
				--name tamad
			echo "."
		else
			echo " not running."
		fi

		rm -f /var/run/tama.pid
		;;
	*)
		echo "Usage: /etc/init.d/tama {start|stop|restart|force-reload}"
		exit 1
esac

exit 0