-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsystemctl
82 lines (52 loc) · 2.17 KB
/
systemctl
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
#!/bin/sh
processes=$(ls /etc/init.d/) # Find avaliable services
################################################
if [ -z "$0" ]; then #Check for list command.
echo "This command line utility is for the easy management of Services using init.d paths."
exit 1
fi
################################################
if [ "$1" = -l ]; then #Check for list command.
echo $processes
exit 1
fi
################################################
if [ -z $1 ]; then #Check if user inputted any service data.
echo "Please select a Service. To see all avaliable Services run: systemctl -l"
exit 1
fi
################################################
if [ -z $2 ]; then #Check if state exists
/etc/init.d/$1
exit 1
fi
################################################
if [ -e /etc/init.d/$1 ]; then #Check if spcified serviceserctl stop led exists.
echo "Service exists."
if [ "$2" == 'stop' ] && [ -e /etc/init.d/$1 ]; then #Check if args are valid and write data
/etc/init.d/$1 $2
echo "Service "$1" Stopped"
elif [ "$2" == 'start' ] && [ -e /etc/init.d/$1 ]; then #Check if args are valid and write data
/etc/init.d/$1 $2
echo "Service "$1" Started"
elif [ "$2" == 'disable' ] && [ -e /etc/init.d/$1 ]; then #Check if args are valid and write data
/etc/init.d/$1 $2
echo "Service "$1" Disabled"
elif [ "$2" == 'enable' ] && [ -e /etc/init.d/$1 ]; then #Check if args are valid and write data
/etc/init.d/$1 $2
echo "Service "$1" Enabled"
elif [ "$2" == 'restart' ] && [ -e /etc/init.d/$1 ]; then #Check if args are valid and write data
/etc/init.d/$1 $2
echo "Service "$1" Restarted"
elif [ "$2" == 'reload' ] && [ -e /etc/init.d/$1 ]; then #Check if args are valid and write data
/etc/init.d/$1 $2
echo "Service "$1" Reloaded"
else
/etc/init.d/$1
exit 1
fi
else
echo "Service does not exist. Run systemctl -l to see avaliable services."
exit 1
fi
################################################