File: init

package info (click to toggle)
prime-net 19.1-2
  • links: PTS
  • area: non-free
  • in suites: potato
  • size: 308 kB
  • sloc: sh: 126; makefile: 52
file content (90 lines) | stat: -rw-r--r-- 2,323 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
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
#!/bin/sh
#
# Start and stop the prime-net client.

test -x /usr/bin/prime-net || exit 0

case "$1" in
	start)
		echo -n "Starting GIMPS client: prime-net"
		cd /var/lib/prime-net || exit 1

		# 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/prime-net.pid \
			--name prime-net 2>/dev/null
		then
			echo " already running."
			exit
		fi

		# Figure out where start-stop-daemon is (it's moved between
		# bo and hamm, and it isn't in the path inside a su).
		if [ -x /sbin/start-stop-daemon ]; then
			ssd=/sbin/start-stop-daemon
		else
			ssd=/usr/sbin/start-stop-daemon
		fi

		su daemon -c "$ssd --start --quiet \
			--exec ./prime-net \
			--pidfile /var/run/prime-net.pid" &

		pid=$!
		echo $pid > /var/run/prime-net.pid

		# To use loadwatcher, uncomment the next two lines. Note 
		# that, depending on the loadwatcher installaiton, you may 
		# have to specify the path. The sleep is there so to leave 
		# time to start-stop-daemon to actually start prime-net.
		#sleep 5
		#loadwatcher -p $pid

		echo "."
		;;
	stop)
		echo -n "Stopping the GIMPS client: prime-net"
		# 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/prime-net.pid --user daemon \
			--name prime-net 2>/dev/null
		then
			start-stop-daemon --quiet --stop \
				--exec /usr/bin/prime-net \
				--pidfile /var/run/prime-net.pid \
				--user daemon \
				--name prime-net
			echo "."
		else
			echo " not running."
		fi

		rm -f /var/run/prime-net.pid

		# If running loadwatcher will stop as soon as it notices 
		# the process no longer exists
		;;
	force-reload|restart)
		# -HUP has no effect on the client.
		# Check if the daemon is actually running.
		if start-stop-daemon --quiet --stop --signal 0 \
			--pidfile /var/run/prime-net.pid \
			--name prime-net \
			--user daemon 2>/dev/null
		then
			$0 stop
			sleep 3
			$0 start
		fi
		;;
	*)
		echo "Usage: /etc/init.d/prime-net {start|stop|restart|force-reload}"
		exit 1
esac

exit 0