-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsvc
54 lines (40 loc) · 1.34 KB
/
svc
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
#!/bin/bash
######################################################################
## ##
## Script for easier basic services management ##
## Language: Bash ##
## Author: Michal "Mcgiwer" Dziczkowski <[email protected]> ##
## ##
######################################################################
function initd
{
# Definition of basic variables
path="/etc/init.d"
prg="${path}/$1"
cmd=$2
# Checking if the user who's running the script has root permissions
if [ $(id -u) -gt 0 ]; then
echo -e "\nThis command requires root permissions\n";
exit 0
fi
# Check if the required parameters have been given by the user
if [ -z "{$prg}" -o -z "${cmd}" ]; then
# if not then display how to use it
echo -e "\n\t
USAGE:\n\t
initd <name> <command>, where:\n
<name> - service to handle
<command> - what to do with it.\n
Possible options: start, stop, restart
\n"
else
# else define the command to execute
initd=`${prg} ${cmd}`
fi
# Check if the command was sucessfull
if [ "$?" -eq 0 ]; then
echo -e "\n[Success] Command: ${cmd} on ${prg}\n"
else
echo -e "\n[Failed] Command: ${cmd} on ${prg}\n"
fi
}