-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathptelnetd-initd
executable file
·95 lines (87 loc) · 1.59 KB
/
ptelnetd-initd
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#!/bin/bash
# This is the init script for starting up the
# Ptelnetd Honeypot
#
# chkconfig: 345 91 10
# description: Starts and stops the ptelnetd daemon.
#
# This is a slightly modified version of the script found on this page:
# http://www.satollo.net/how-to-install-tomcat-and-java-6-on-centos-5-2
#
# Point this to your Tomcat installation.
proc="ptelnetd"
startup=/opt/tomcat/bin/startup.sh
shutdown=/opt/tomcat/bin/shutdown.sh
#AWK only works when called from a function like this.
_getPID()
{
echo `ps -ef | grep -v grep | grep "ptelnetd" | grep "honeypot" | awk '{print $2}'`
}
PID="$(_getPID)"
start(){
if [ "$PID" ]
then
echo "$proc is already running with PID $PID."
else
echo -n $"Starting $proc service: "
/usr/local/sbin/ptelnetd -honeypot
echo
fi
}
stop(){
if [ "$PID" ]
then
echo -n "Stopping $proc service: "
kill $PID
echo
limit=10
PID="$(_getPID)"
while [ "$PID" ]
do
if [ $limit == 0 ]
then
echo "$proc taking too long to shutdown, killing the process..."
kill -9 $PID
break
fi
sleep 2
limit=$((limit-1))
PID="$(_getPID)"
done
else
echo "$proc is not currently running."
fi
}
restart(){
stop
echo "Sleeping 10 to allow ptelnetd to stop"
sleep 10
start
}
status(){
if [ "$PID" ]
then
echo "$proc is running with PID $PID."
else
echo "$proc is not running."
fi
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
status) #It works now!
status
;;
restart)
restart
;;
*)
echo $"Usage: $0 {start|stop|status|restart}"
exit 1
esac
exit 0