633
|
1 |
service_GETOPTS=''
|
|
2 |
|
|
3 |
SERVICE_NOOP=
|
|
4 |
SERVICE_TYPE=
|
|
5 |
|
|
6 |
function service_help {
|
|
7 |
echo <<EOM
|
|
8 |
|
|
9 |
EOM
|
|
10 |
}
|
|
11 |
|
|
12 |
function service_opt {
|
|
13 |
local opt=$1
|
|
14 |
local optarg="$2"
|
|
15 |
|
|
16 |
case $opt in
|
|
17 |
n) SERVICE=0 ;;
|
|
18 |
*) return 1
|
|
19 |
esac
|
|
20 |
}
|
|
21 |
|
|
22 |
function service_init {
|
|
23 |
if [ -e /bin/systemctl ]; then
|
|
24 |
SERVICE_TYPE=systemd
|
|
25 |
|
|
26 |
elif [ -e /sbin/initctl ]; then
|
|
27 |
SERVICE_TYPE=upstart
|
|
28 |
|
|
29 |
else
|
|
30 |
SERVICE_TYPE=service
|
|
31 |
fi
|
|
32 |
}
|
|
33 |
|
|
34 |
function service_status {
|
|
35 |
local service=$1
|
|
36 |
|
|
37 |
if [ $SERVICE_TYPE = upstart ]; then
|
|
38 |
cmd_test service $service status | grep -q start
|
|
39 |
else
|
|
40 |
cmd_test service $service status > /dev/null
|
|
41 |
fi
|
|
42 |
}
|
|
43 |
|
|
44 |
function service_restart {
|
|
45 |
local service=$1
|
|
46 |
|
|
47 |
cmd service $service restart
|
|
48 |
}
|