Subversion Repositories

?revision_form?Rev ?revision_input??revision_submit??revision_endform?

Rev 3 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 magnus 1
#!/bin/sh
2
### BEGIN INIT INFO
3
# Provides:          pyscrabble
4
# Required-Start:    $local_fs $remote_fs
5
# Required-Stop:     $local_fs $remote_fs
6
# Default-Start:     2 3 4 5
7
# Default-Stop:      S 0 1 6
8
# Short-Description: PyScrabble server
9
# Description:       Controls the PyScrabble server
10
### END INIT INFO
11
#
12
# Author:	Will Gray <graywh@gmail.com>
13
# Version:	1
14
#
15
 
16
set -e
17
 
18
PATH=/sbin:/bin:/usr/bin
19
DESC="PyScrabble server"
20
NAME=python
21
NAME2=pyscrabble-server
22
DAEMON=/usr/games/pyscrabble-server
23
PIDFILE=/var/run/$NAME2.pid
24
SCRIPTNAME=/etc/init.d/$NAME2
25
 
26
# Gracefully exit if the package has been removed.
27
test -x $DAEMON || exit 0
28
 
29
USER="pyscrabble"
30
 
31
# Read config file if it is present.
32
if [ -r /etc/default/$NAME2 ]
33
then
34
	. /etc/default/$NAME2
35
fi
36
 
37
#
38
#	Function that starts the daemon/service.
39
#
40
d_start() {
41
	start-stop-daemon --start --quiet --background --make-pidfile --pidfile $PIDFILE \
42
		--chuid "$USER" --exec $DAEMON \
43
		|| echo -n " already running"
44
}
45
 
46
#
47
#	Function that stops the daemon/service.
48
#
49
d_stop() {
50
	start-stop-daemon --stop --quiet --pidfile $PIDFILE \
51
		--name $NAME \
52
		|| echo -n " not running"
53
        rm -f $PIDFILE
54
}
55
 
56
case "$1" in
57
  start)
58
	echo -n "Starting $DESC: $NAME2"
59
	d_start
60
	echo "."
61
	;;
62
  stop)
63
	echo -n "Stopping $DESC: $NAME2"
64
	d_stop
65
	echo "."
66
	;;
67
  #reload)
68
	#
69
	#	If the daemon can reload its configuration without
70
	#	restarting (for example, when it is sent a SIGHUP),
71
	#	then implement that here.
72
	#
73
	#	If the daemon responds to changes in its config file
74
	#	directly anyway, make this an "exit 0".
75
	#
76
	# echo -n "Reloading $DESC configuration..."
77
	# d_reload
78
	# echo "done."
79
  #;;
80
  restart|force-reload)
81
	#
82
	#	If the "reload" option is implemented, move the "force-reload"
83
	#	option to the "reload" entry above. If not, "force-reload" is
84
	#	just the same as "restart".
85
	#
86
	echo -n "Restarting $DESC: $NAME2"
87
	d_stop
88
	# One second might not be time enough for a daemon to stop,
89
	# if this happens, d_start will fail (and dpkg will break if
90
	# the package is being upgraded). Change the timeout if needed
91
	# be, or change d_stop to have start-stop-daemon use --retry.
92
	# Notice that using --retry slows down the shutdown process somewhat.
93
	sleep 1
94
	d_start
95
	echo "."
96
	;;
97
  *)
98
	# echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
99
	echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
100
	exit 1
101
	;;
102
esac
103
 
104
exit 0