Lines 8-14
PATH=/sbin:/usr/sbin:/bin:/usr/bin
Link Here
|
8 |
export PATH |
8 |
export PATH |
9 |
|
9 |
|
10 |
VERSION="service version 0.91-alt" |
10 |
VERSION="service version 0.91-alt" |
11 |
SERVICEDIR="/etc/init.d" |
11 |
SERVICEDIR=/etc/init.d |
|
|
12 |
SYSTEMCTL=/bin/systemctl |
13 |
SYSTEMD_SERVICE_DIR=/lib/systemd/system |
14 |
SYSTEMD_CGROUP_DIR=/sys/fs/cgroup/systemd |
12 |
SERVICE= |
15 |
SERVICE= |
13 |
OPTIONS= |
16 |
OPTIONS= |
14 |
|
17 |
|
Lines 30-42
usage()
Link Here
|
30 |
[ -n "$1" ] && exit "$1" || exit |
33 |
[ -n "$1" ] && exit "$1" || exit |
31 |
} |
34 |
} |
32 |
|
35 |
|
|
|
36 |
systemd_status= |
37 |
systemd_is_active() |
38 |
{ |
39 |
if [ -z "$systemd_status" ]; then |
40 |
[ -x "$SYSTEMCTL" -a \ |
41 |
-d "$SYSTEMD_CGROUP_DIR" ] && |
42 |
mountpoint -q "$SYSTEMD_CGROUP_DIR" |
43 |
systemd_status=$? |
44 |
fi |
45 |
return $systemd_status |
46 |
} |
47 |
|
33 |
check_service() |
48 |
check_service() |
34 |
{ |
49 |
{ |
35 |
[ -n "${SERVICE##*/*}" ] || |
50 |
[ -n "${SERVICE##*/*}" ] || |
36 |
fatal "$SERVICE: Invalid service name" |
51 |
fatal "$SERVICE: Invalid service name" |
37 |
|
52 |
|
38 |
[ -x "$SERVICEDIR/$SERVICE" ] || |
53 |
[ -x "$SERVICEDIR/$SERVICE" ] && return 0 |
39 |
fatal "$SERVICE: Unrecognized service" |
54 |
|
|
|
55 |
[ -f "$SYSTEMD_SERVICE_DIR/$SERVICE.service" ] && |
56 |
systemd_is_active && |
57 |
return 0 |
58 |
|
59 |
fatal "$SERVICE: Unrecognized service" |
40 |
} |
60 |
} |
41 |
|
61 |
|
42 |
if [ $# -eq 0 ]; then |
62 |
if [ $# -eq 0 ]; then |
Lines 69-75
case "$1" in
Link Here
|
69 |
shift |
89 |
shift |
70 |
check_service |
90 |
check_service |
71 |
cd / || exit |
91 |
cd / || exit |
72 |
"$SERVICEDIR/$SERVICE" "$@" |
92 |
if systemd_is_active; then |
73 |
exit $? |
93 |
exec "$SYSTEMCTL" "$@" "$SERVICE.service" |
|
|
94 |
else |
95 |
exec "$SERVICEDIR/$SERVICE" "$@" |
96 |
fi |
97 |
exit |
74 |
;; |
98 |
;; |
75 |
esac |
99 |
esac |