228.1.1
by Marius Kruger
add super cool linux startup script for loggerhead |
1 |
#!/bin/sh
|
2 |
### BEGIN INIT INFO
|
|
3 |
# Required-Start: $local_fs $remote_fs $network
|
|
4 |
# Default-Start: 3 5
|
|
5 |
# Default-Stop: 0 1 2 6
|
|
6 |
# Short-Description: Loggerhead
|
|
7 |
# Description: Manage Loggerhead (a web viewer for projects in bazaar)
|
|
8 |
### END INIT INFO
|
|
9 |
||
10 |
# Configure this please: #
|
|
11 |
LOGGERHEAD_PATH=/opt/loggerhead |
|
12 |
LOG_FOLDER=/var/log/loggerhead |
|
13 |
LOG_FILE=$LOG_FOLDER/loggerheadd.log |
|
14 |
PREFIX=/loggerhead |
|
15 |
PORT=8080 |
|
16 |
||
17 |
# You can add additional options to serve-branches here:
|
|
18 |
START_CMD="$LOGGERHEAD_PATH/serve-branches --prefix=$PREFIX --log-folder=$LOG_FOLDER --port=$PORT /var/lib/gforge/bzrroot/" |
|
19 |
||
20 |
#
|
|
21 |
# main part
|
|
22 |
#
|
|
228.1.5
by Marius Kruger
extract stop and start methods |
23 |
|
24 |
start_loggerhead(){
|
|
25 |
python $START_CMD > $LOG_FILE 2>&1 & |
|
26 |
echo "Started loggerhead. (See $LOG_FOLDER for details.)" |
|
27 |
}
|
|
28 |
||
29 |
stop_loggerhead(){
|
|
30 |
pkill -f "$START_CMD" |
|
31 |
proccess=`pgrep -fl "$START_CMD"` |
|
32 |
if [ -z "$proccess" ]; then |
|
33 |
echo "Loggerhead was stopped." |
|
34 |
fi
|
|
35 |
}
|
|
36 |
||
228.1.1
by Marius Kruger
add super cool linux startup script for loggerhead |
37 |
case "$1" in |
38 |
start)
|
|
228.1.5
by Marius Kruger
extract stop and start methods |
39 |
start_loggerhead |
228.1.1
by Marius Kruger
add super cool linux startup script for loggerhead |
40 |
;;
|
41 |
stop)
|
|
228.1.5
by Marius Kruger
extract stop and start methods |
42 |
stop_loggerhead |
228.1.1
by Marius Kruger
add super cool linux startup script for loggerhead |
43 |
;;
|
44 |
status)
|
|
45 |
proccess=`pgrep -fl "$START_CMD"` |
|
46 |
echo "$proccess" |
|
47 |
netstat -anp |grep -e ":$PORT" |
|
48 |
if [ -z "$proccess" ]; then |
|
228.1.4
by Marius Kruger
fix whitespace |
49 |
echo "Loggerhead is not running." |
50 |
else
|
|
51 |
echo "Loggerhead is running." |
|
228.1.5
by Marius Kruger
extract stop and start methods |
52 |
fi
|
228.1.4
by Marius Kruger
fix whitespace |
53 |
;;
|
228.1.3
by Marius Kruger
add restart |
54 |
restart)
|
228.1.5
by Marius Kruger
extract stop and start methods |
55 |
stop_loggerhead |
56 |
start_loggerhead |
|
228.1.4
by Marius Kruger
fix whitespace |
57 |
;;
|
228.1.1
by Marius Kruger
add super cool linux startup script for loggerhead |
58 |
*)
|
228.1.3
by Marius Kruger
add restart |
59 |
echo "Usage: loggerheadd { start | stop | status | restart }" |
228.1.4
by Marius Kruger
fix whitespace |
60 |
exit 1 |
228.1.1
by Marius Kruger
add super cool linux startup script for loggerhead |
61 |
esac
|