-
Notifications
You must be signed in to change notification settings - Fork 0
/
odb.init
executable file
·111 lines (103 loc) · 1.75 KB
/
odb.init
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#!/bin/bash
#
# ODB
#
# chkconfig: 2345 96 04
# description: ODB init
#
# pidfile: /var/run/keystone/odb.pid
### BEGIN INIT INFO
# Provides: odb
# Required-Start: $local_fs $network $syslog
# Required-Stop: $local_fs $syslog
# Should-Start: $syslog
# Should-Stop: $network $syslog
# Default-Start: 3 4 5
# Default-Stop: 0 2 1 6
# Short-Description: ODB
# Description: TODO!
### END INIT INFO
# Source function library.
. /etc/init.d/functions
prog="ODB"
pidfile=/var/run/keystone/odb.pid
lckfile=/var/lock/subsys/odb-lock
binfile=/usr/share/odb/ironcloud_start
start() {
if [ -f "$pidfile" ]; then
pid=`cat $pidfile`
checkpid $pid
r=$?
if [ "$r" -eq 0 ]; then
cmd=$(basename $binfile)
echo -n "$cmd is already running (pid $pid)"; passed
echo
exit 0
fi
fi
echo -n "Starting $prog: "
cd /usr/share/odb
/sbin/start-stop-daemon --start -b -c root:root --make-pidfile --pidfile $pidfile --exec $binfile --
sleep 5
if [ -f "$pidfile" ]; then
checkpid `cat $pidfile`
r=$?
if [ "$r" -eq 0 ]; then
touch $lckfile
success
else
failure
fi
else
failure
fi
echo
return
}
stop() {
echo -n "Stopping $prog: "
if [ -n "`pidofproc -p $pidfile $binfile`" ] ; then
killproc -p $pidfile $binfile
else
failure $"Stopping $prog"
fi
retval=$?
[ $retval -eq 0 ] && rm -f $lckfile
echo
return $retval
}
rh_status() {
status -p $pidfile $binfile
}
restart() {
stop
start
}
case "$1" in
start)
start
;;
stop)
stop
;;
status)
rh_status
retval=$?
if [ $retval -eq 3 -a -f $lckfile ] ; then
retval=2
fi
;;
restart)
restart
;;
condrestart)
if [ -n "`pidofproc -p $pidfile $binfile`" ] ; then
restart
fi
;;
*)
echo "Usage: service odb {start|stop|status|restart|condrestart}"
exit 1
;;
esac
exit $?