311
by James Westby
Add an init script. |
1 |
#!/bin/sh
|
2 |
||
3 |
BASEDIR=/srv/package-import.canonical.com/new/ |
|
316
by Package Import Role
Drop mass_import.sh and do that stuff in the init script. |
4 |
PATH=${BASEDIR}scripts:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin |
311
by James Westby
Add an init script. |
5 |
NAME=mass-import |
316
by Package Import Role
Drop mass_import.sh and do that stuff in the init script. |
6 |
DAEMON=${BASEDIR}scripts/mass_import.py |
7 |
PIDFILE=${BASEDIR}mass-import.pid |
|
8 |
STOPFILE=${BASEDIR}STOP_PLEASE |
|
357
by James Westby
Have the init script chuid to the pkg_import user. |
9 |
USER=pkg_import |
316
by Package Import Role
Drop mass_import.sh and do that stuff in the init script. |
10 |
export LANG="en_GB.UTF-8" |
11 |
export PATH
|
|
12 |
export PYTHONPATH=${BASEDIR}scripts/python-debian/:${BASEDIR} |
|
13 |
export BZR_PLUGIN_PATH=${BASEDIR}scripts/plugins/ |
|
14 |
export TMPDIR=${BASEDIR}tmp |
|
15 |
export BZR_EMAIL="Bazaar Package Importer <james.westby@ubuntu.com>" |
|
311
by James Westby
Add an init script. |
16 |
|
17 |
usage() { |
|
18 |
echo "Usage: $0 {start|stop|restart|status|graceful-stop}" |
|
19 |
}
|
|
20 |
||
21 |
d_start() { |
|
22 |
start-stop-daemon --quiet --start --name $NAME --pidfile $PIDFILE \ |
|
357
by James Westby
Have the init script chuid to the pkg_import user. |
23 |
--background --make-pidfile --exec $DAEMON -c $USER -- |
311
by James Westby
Add an init script. |
24 |
}
|
25 |
||
26 |
d_stop() { |
|
323
by Package Import Role
Handle the co-ordination of starting/stopping better. |
27 |
start-stop-daemon --stop --pidfile $PIDFILE --exec /usr/bin/python
|
311
by James Westby
Add an init script. |
28 |
}
|
29 |
||
30 |
case "$1" in |
|
31 |
start)
|
|
32 |
echo -n "Starting $NAME" |
|
314
by Package Import Role
Force removal of file to avoid message on non-existance. |
33 |
rm -f $STOPFILE
|
311
by James Westby
Add an init script. |
34 |
d_start |
35 |
echo "." |
|
36 |
;;
|
|
37 |
stop)
|
|
38 |
echo -n "Stopping $NAME" |
|
39 |
d_stop |
|
40 |
echo "." |
|
41 |
;;
|
|
42 |
restart)
|
|
43 |
echo -n "Restarting $NAME" |
|
44 |
d_stop |
|
45 |
sleep 1
|
|
46 |
d_start |
|
47 |
echo "." |
|
48 |
;;
|
|
49 |
graceful-stop)
|
|
50 |
echo -n "Requesting stop of $NAME" |
|
51 |
touch $STOPFILE
|
|
52 |
echo "." |
|
53 |
;;
|
|
54 |
*)
|
|
55 |
usage |
|
56 |
exit 1 |
|
57 |
;;
|
|
58 |
esac
|
|
59 |