Skip to content

Commit ca78d00

Browse files
committed
Initial commit
Signed-off-by: Teddysun <[email protected]>
1 parent 6231bfb commit ca78d00

File tree

2 files changed

+226
-0
lines changed

2 files changed

+226
-0
lines changed

kms

+117
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
#!/bin/bash
2+
# chkconfig: 2345 90 10
3+
# description: A secure socks5 proxy, designed to protect your Internet traffic.
4+
5+
### BEGIN INIT INFO
6+
# Provides: KMS Emulator
7+
# Required-Start: $network $syslog
8+
# Required-Stop: $network
9+
# Default-Start: 2 3 4 5
10+
# Default-Stop: 0 1 6
11+
# Short-Description: Build yourself KMS Server
12+
# Description: Start or stop the KMS Server
13+
### END INIT INFO
14+
15+
# Author: Teddysun <[email protected]>
16+
17+
# Source function library
18+
. /etc/rc.d/init.d/functions
19+
20+
# Check that networking is up.
21+
[ ${NETWORKING} ="yes" ] || exit 0
22+
23+
NAME="KMS Server"
24+
DAEMON=/usr/bin/vlmcsd
25+
PID_DIR=/var/run
26+
PID_FILE=$PID_DIR/vlmcsd.pid
27+
LOG_DIR=/var/log
28+
LOG_FILE=$LOG_DIR/vlmcsd.log
29+
RET_VAL=0
30+
31+
[ -x $DAEMON ] || exit 0
32+
33+
if [ ! -d $PID_DIR ]; then
34+
mkdir -p $PID_DIR
35+
if [ $? -ne 0 ]; then
36+
echo "Creating PID directory $PID_DIR failed"
37+
exit 1
38+
fi
39+
fi
40+
41+
if [ ! -d $LOG_DIR ]; then
42+
mkdir -p $LOG_DIR
43+
if [ $? -ne 0 ]; then
44+
echo "Creating LOG directory $LOG_DIR failed"
45+
exit 1
46+
fi
47+
fi
48+
49+
check_running() {
50+
if [ -r $PID_FILE ]; then
51+
read PID < $PID_FILE
52+
if [ -d "/proc/$PID" ]; then
53+
return 0
54+
else
55+
rm -f $PID_FILE
56+
return 1
57+
fi
58+
else
59+
return 2
60+
fi
61+
}
62+
63+
do_status() {
64+
check_running
65+
case $? in
66+
0)
67+
echo "$NAME (pid $PID) is running..."
68+
;;
69+
1|2)
70+
echo "$NAME is stopped"
71+
RET_VAL=1
72+
;;
73+
esac
74+
}
75+
76+
do_start() {
77+
if check_running; then
78+
echo "$NAME (pid $PID) is already running..."
79+
return 0
80+
fi
81+
$DAEMON -p $PID_FILE -l $LOG_FILE
82+
sleep 0.3
83+
if check_running; then
84+
echo "Starting $NAME success"
85+
else
86+
echo "Starting $NAME failed"
87+
RET_VAL=1
88+
fi
89+
}
90+
91+
do_stop() {
92+
if check_running; then
93+
kill -9 $PID
94+
rm -f $PID_FILE
95+
echo "Stopping $NAME success"
96+
else
97+
echo "$NAME is stopped"
98+
RET_VAL=1
99+
fi
100+
}
101+
102+
do_restart() {
103+
do_stop
104+
do_start
105+
}
106+
107+
case "$1" in
108+
start|stop|restart|status)
109+
do_$1
110+
;;
111+
*)
112+
echo "Usage: $0 { start | stop | restart | status }"
113+
RET_VAL=1
114+
;;
115+
esac
116+
117+
exit $RET_VAL

kms-debian

+109
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
#!/bin/bash
2+
3+
### BEGIN INIT INFO
4+
# Provides: KMS Emulator
5+
# Required-Start: $network $local_fs $remote_fs
6+
# Required-Stop: $network $local_fs $remote_fs
7+
# Default-Start: 2 3 4 5
8+
# Default-Stop: 0 1 6
9+
# Short-Description: Build yourself KMS Server
10+
# Description: Start or stop the KMS Server
11+
### END INIT INFO
12+
13+
# Author: Teddysun <[email protected]>
14+
15+
NAME="KMS Server"
16+
DAEMON=/usr/bin/vlmcsd
17+
PID_DIR=/var/run
18+
PID_FILE=$PID_DIR/vlmcsd.pid
19+
LOG_DIR=/var/log
20+
LOG_FILE=$LOG_DIR/vlmcsd.log
21+
RET_VAL=0
22+
23+
[ -x $DAEMON ] || exit 0
24+
25+
if [ ! -d $PID_DIR ]; then
26+
mkdir -p $PID_DIR
27+
if [ $? -ne 0 ]; then
28+
echo "Creating PID directory $PID_DIR failed"
29+
exit 1
30+
fi
31+
fi
32+
33+
if [ ! -d $LOG_DIR ]; then
34+
mkdir -p $LOG_DIR
35+
if [ $? -ne 0 ]; then
36+
echo "Creating LOG directory $LOG_DIR failed"
37+
exit 1
38+
fi
39+
fi
40+
41+
check_running() {
42+
if [ -r $PID_FILE ]; then
43+
read PID < $PID_FILE
44+
if [ -d "/proc/$PID" ]; then
45+
return 0
46+
else
47+
rm -f $PID_FILE
48+
return 1
49+
fi
50+
else
51+
return 2
52+
fi
53+
}
54+
55+
do_status() {
56+
check_running
57+
case $? in
58+
0)
59+
echo "$NAME (pid $PID) is running..."
60+
;;
61+
1|2)
62+
echo "$NAME is stopped"
63+
RET_VAL=1
64+
;;
65+
esac
66+
}
67+
68+
do_start() {
69+
if check_running; then
70+
echo "$NAME (pid $PID) is already running..."
71+
return 0
72+
fi
73+
$DAEMON -p $PID_FILE -l $LOG_FILE
74+
sleep 0.3
75+
if check_running; then
76+
echo "Starting $NAME success"
77+
else
78+
echo "Starting $NAME failed"
79+
RET_VAL=1
80+
fi
81+
}
82+
83+
do_stop() {
84+
if check_running; then
85+
kill -9 $PID
86+
rm -f $PID_FILE
87+
echo "Stopping $NAME success"
88+
else
89+
echo "$NAME is stopped"
90+
RET_VAL=1
91+
fi
92+
}
93+
94+
do_restart() {
95+
do_stop
96+
do_start
97+
}
98+
99+
case "$1" in
100+
start|stop|restart|status)
101+
do_$1
102+
;;
103+
*)
104+
echo "Usage: $0 { start | stop | restart | status }"
105+
RET_VAL=1
106+
;;
107+
esac
108+
109+
exit $RET_VAL

0 commit comments

Comments
 (0)