1 |
diff -up e-smith-base-5.8.0/root/sbin/e-smith/service.bz9672.servicesystemd e-smith-base-5.8.0/root/sbin/e-smith/service |
2 |
--- e-smith-base-5.8.0/root/sbin/e-smith/service.bz9672.servicesystemd 2016-02-04 18:14:13.000000000 -0500 |
3 |
+++ e-smith-base-5.8.0/root/sbin/e-smith/service 2016-07-23 09:28:59.034000000 -0400 |
4 |
@@ -1,13 +1,53 @@ |
5 |
#! /bin/sh |
6 |
+# prevent initscript to use systemctl |
7 |
+export SYSTEMCTL_SKIP_REDIRECT=1 |
8 |
+. /etc/rc.d/init.d/functions |
9 |
|
10 |
-runlevel=$(runlevel | cut -d" " -f2) |
11 |
+# what is our current runlevel |
12 |
+runlevel=$(systemctl get-default) |
13 |
+SERVICE=$1 |
14 |
+USAGE="Usage: service SERVICENAME [ACTION]" |
15 |
|
16 |
-if [ "$runlevel" = "4" ] |
17 |
+#if no servicename is provided return usage |
18 |
+if [[ "${SERVICE}" == "" ]] |
19 |
+then |
20 |
+ echo ${USAGE} >&2 |
21 |
+ exit |
22 |
+fi |
23 |
+ |
24 |
+if [ "$runlevel" = "multi-user.target" ] |
25 |
then |
26 |
if ls /etc/rc7.d/S??$1 >/dev/null 2>/dev/null |
27 |
then |
28 |
script=$(ls /etc/rc7.d/S??$1 | head -1) |
29 |
exec $script $2 |
30 |
+ |
31 |
+ elif ls /usr/lib/systemd/system/${SERVICE}.service >/dev/null 2>/dev/null || ls /etc/systemd/system/${SERVICE}.service >/dev/null 2>/dev/null |
32 |
+ then |
33 |
+ if [[ "$2" == "" ]] ; then |
34 |
+ echo "'$1' requires an action" 1>&2 |
35 |
+ echo ${USAGE} >&2 |
36 |
+ exit |
37 |
+ elif [[ $2 == "status" ]] ; then |
38 |
+ exec /bin/systemctl status -n0 ${SERVICE} |
39 |
+ exit |
40 |
+ elif [[ $2 == "start" ]] ; then |
41 |
+ echo -n "Starting ${SERVICE}" 2>/dev/null |
42 |
+ elif [[ $2 == "stop" ]] ; then |
43 |
+ echo -n "Stopping ${SERVICE}" 2>/dev/null |
44 |
+ elif [[ $2 == "restart" ]] ; then |
45 |
+ echo -n "Restarting ${SERVICE}" 2>/dev/null |
46 |
+ else |
47 |
+ echo -n "Sending $2 signal to ${SERVICE}" 2>/dev/null |
48 |
+ fi |
49 |
+ /bin/systemctl $2 ${SERVICE}.service> /dev/null |
50 |
+ if [ $? -ne 0 ]; then |
51 |
+ echo_failure |
52 |
+ else |
53 |
+ echo_success |
54 |
+ fi |
55 |
+ echo |
56 |
+ exit |
57 |
fi |
58 |
|
59 |
echo "'$1' is not a valid service name" 1>&2 |