-
Notifications
You must be signed in to change notification settings - Fork 179
/
kms.sh
executable file
·79 lines (75 loc) · 1.6 KB
/
kms.sh
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
#!/bin/bash
# Author: Dakkidaze <[email protected]>
DAEMON=/usr/local/kms/vlmcsd
STAT=2
check_running(){
PID=`ps -ef | grep -v grep | grep -i "vlmcsd" | awk '{print $2}'`
if [ ! -z $PID ]; then
STAT=0
else
STAT=1
fi
}
do_restart() {
check_running
if [ $STAT = 0 ]; then
echo "Restarting KMS Server..."
kill $PID
elif [ $STAT = 1 ]; then
echo "Not started, starting now"
fi
$DAEMON -L 0.0.0.0:1688 -l vlmcsd.log
check_running
if [ $STAT = 0 ]; then
echo "Succeeded."
elif [ $STAT = 1 ]; then
echo "Failed."
fi
}
do_stop() {
check_running
if [ $STAT = 0 ]; then
echo "Shutting down KMS Server..."
kill $PID
check_running
if [ $STAT = 0 ]; then
echo "Failed."
elif [ $STAT = 1 ]; then
echo "Succeeded."
fi
elif [ $STAT = 1 ]; then
echo "Not running, no kill."
fi
}
do_status() {
check_running
if [ $STAT = 0 ]; then
echo "KMS Server is running."
elif [ $STAT = 1 ]; then
echo "KMS Server is not running."
fi
}
do_start() {
check_running
if [ $STAT = 0 ]; then
echo "KMS Server is already running."
exit 0;
elif [ $STAT = 1 ]; then
echo "KMS Server is not running, starting now..."
$DAEMON -L 0.0.0.0:1688 -l vlmcsd.log
fi
check_running
if [ $STAT = 0 ]; then
echo "Succeeded."
elif [ $STAT = 1 ]; then
echo "Failed."
fi
}
case "$1" in
start|stop|restart|status)
do_$1
;;
*)
echo "Usage: $0 start | stop | restart | status "
;;
esac