-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathetc-init.d-gargoyle
136 lines (110 loc) · 3.08 KB
/
etc-init.d-gargoyle
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
#! /bin/sh
### BEGIN INIT INFO
# Provides: gargoyle_pscand
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop:
# Short-Description: Gargoyle Portscan detection daemon
### END INIT INFO
set -e
# /etc/init.d/gargoyle_pscand: start and stop the Gargoyle portscan detection daemon
# End system needs lsb-core functionality
. /lib/lsb/init-functions
# Define LSB log_* functions.
# To be replaced by LSB functions
# Defined here for distributions that don't define
# log_daemon_msg
log_daemon_msg () {
echo $@
}
# To be replaced by LSB functions
# Defined here for distributions that don't define
# log_end_msg
log_end_msg () {
retval=$1
if [ $retval -eq 0 ]; then
echo "."
else
echo " failed!"
fi
return $retval
}
# Are we running from init?
run_by_init() {
([ "$previous" ] && [ "$runlevel" ]) || [ "$runlevel" = S ]
}
check_for_upstart() {
if init_is_upstart; then
exit $1
fi
}
check_dev_null() {
if [ ! -c /dev/null ]; then
if [ "$1" = log_end_msg ]; then
log_end_msg 1 || true
fi
if ! run_by_init; then
log_action_msg "/dev/null is not a character device!" || true
fi
exit 1
fi
}
export PATH="${PATH:+$PATH:}/usr/sbin:/sbin"
case "$1" in
start)
# check_for_upstart 1
# check_dev_null
cd APPDIR
VERS=$(./gargoyle_pscand -v |grep Ver |awk {'print $3'})
log_daemon_msg "Starting Gargoyle Portscan detection daemon version $VERS" || true
./gargoyle_config &
sleep 1
./gargoyle_pscand &
sleep 4
log_daemon_msg "Starting Gargoyle Portscan analysis daemon version $VERS" || true
./gargoyle_pscand_analysis &
log_daemon_msg "Starting Gargoyle Portscan monitoring daemon version $VERS" || true
./gargoyle_pscand_monitor &
log_daemon_msg "Starting Gargoyle Logscan daemon version $VERS" || true
./gargoyle_lscand_bruteforce_detect &
# Only start SSH bruteforce if ssh is running
if [ "$(ps -ef|grep sshd |grep -v grep)" ];then
log_daemon_msg "Starting Gargoyle Logscan SSH bruteforce daemon version $VERS" || true
./gargoyle_lscand_ssh_bruteforce &
fi
log_end_msg 0 || true
;;
stop)
# check_for_upstart 0
log_daemon_msg "Stopping Gargoyle Portscan detection daemon" || true
for p in $(ps -ef |grep -v grep|grep gargoyle_ |awk {'print $2'})
do kill -2 $p
done
;;
reload|force-reload)
#check_for_upstart 1
;;
restart)
# check_for_upstart 1
log_daemon_msg "Restarting Gargoyle Portscan detection daemon" || true
check_dev_null log_end_msg
/usr/bin/pkill -2 gargoyle_pscand
cd APPDIR
LD_LIBRARY_PATH=lib
if start-stop-daemon --start --oknodo --exec ./gargoyle_pscand ; then
log_end_msg 0 || true
else
log_end_msg 1 || true
fi
;;
status)
# check_for_upstart 1
# pgrep gargoyle_pscand
ps -ef |grep -v grep|grep gargoyle_pscand$ |awk {'print $2'}
;;
*)
log_action_msg "Usage: /etc/init.d/gargoyle_pscand {start|stop|restart|status}" || true
exit 1
esac
exit 0