-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinitscript.sh
executable file
·84 lines (79 loc) · 1.65 KB
/
initscript.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/bin/bash
#
# groupsync Init script for running the groupsync daemon
#
# chkconfig: 35 60 50
#
### BEGIN INIT INFO
# Provides: groupsync
# Required-Start: $network $syslog
# Required-Stop: $network $syslog
# Default-Start: 35
# Default-Stop: 01246
# Short-Description: Groupsync daemon
# Description: Start and stop the Groupsync daemon
### END INIT INFO
#
# Variables
GROUPSYNC_USER=sakai
GROUPSYNC_HOME="$(dirname $(readlink -f "$0"))"
# Source function library.
#. /etc/rc.d/init.d/functions
groupsync_pid() {
echo `ps aux | grep -i groupsync-service | grep -v grep | awk '{ print $2 }'`
}
start() {
pid=$(groupsync_pid)
if [ -n "$pid" ]; then
echo "Groupsync is already running (pid: $pid)"
else
echo "Starting Groupsync"
if [ `whoami` = "$GROUPSYNC_USER" ]; then
nohup ${GROUPSYNC_HOME}/run.sh >/dev/null 2>/dev/null &
else
nohup /bin/su ${GROUPSYNC_USER} -c ${GROUPSYNC_HOME}/run.sh >/dev/null 2>/dev/null &
fi
fi
return 0
}
stop() {
pid=$(groupsync_pid)
if [ -n "$pid" ]
then
echo "Stopping Groupsync"
kill "$pid"
else
echo "Groupsync is not running"
fi
return 0
}
status() {
pid=$(groupsync_pid)
if [ -n "$pid" ]
then
echo "Groupsync is running with pid: $pid"
else
echo "Groupsync is not running"
fi
return 0
}
case $1 in
start)
start
;;
stop)
stop
;;
restart)
stop
sleep 5
start
;;
status)
status
;;
*)
echo $"Usage: $0 {start|stop|restart|status}"
exit 1
esac
exit $RETVAL