-
Notifications
You must be signed in to change notification settings - Fork 2
/
galaxy_service.sh
executable file
·66 lines (55 loc) · 1.52 KB
/
galaxy_service.sh
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
#!/bin/sh
# vi: fdm=marker
### BEGIN INIT INFO
# Provides: galaxy
# Required-Start: $local_fs $network $named $time $syslog
# Required-Stop: $local_fs $network $named $time $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Description: Galaxy
### END INIT INFO
SCRIPT=/home/vagrant/galaxy/run.sh
RUNAS=vagrant
PIDFILE=/home/vagrant/galaxy/paster.pid
LOGFILE=/home/vagrant/galaxy/paster.log
# Start {{{1
################################################################
start() {
if [ -f $PIDFILE ] && kill -0 $(cat $PIDFILE); then
echo 'Service already running' >&2
return 1
fi
echo 'Starting service…' >&2
local CMD="$SCRIPT --daemon --log-file=\"$LOGFILE\" --pid-file=\"$PIDFILE\""
su -c "$CMD" $RUNAS
echo 'Service started' >&2
}
# Stop {{{1
################################################################
stop() {
if [ ! -f "$PIDFILE" ] || ! kill -0 $(cat "$PIDFILE"); then
echo 'Service not running' >&2
return 1
fi
echo 'Stopping service…' >&2
$SCRIPT --stop-daemon
echo 'Service stopped' >&2
}
# Status {{{1
################################################################
status() {
if [ -f $PIDFILE ] && kill -0 $(cat $PIDFILE); then
echo 'Service is currently running with PID '$(cat $PIDFILE)'.' >&2
else
echo 'Service is stopped.' >&2
fi
}
# Main {{{1
################################################################
case "$1" in
start) start ;;
stop) stop ;;
restart) stop ; start ;;
status) status ;;
*) echo "Usage: $0 {start|stop|restart|status}"
esac