forked from omobagrp/csoc-installation-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGCRdionaeaAlerts
More file actions
92 lines (78 loc) · 1.96 KB
/
GCRdionaeaAlerts
File metadata and controls
92 lines (78 loc) · 1.96 KB
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
#!/bin/bash
### BEGIN INIT INFO
# Provides: GCRdionaeaAlerts
# Required-Start: dionaea
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop:
# Short-Description: GCRdionaeaAlerts
### END INIT INFO
DEBUGME="no"
if [[ $DEBUGME == "yes" ]]; then
# Close STDOUT
exec 1<&-
# Close STDERR
exec 2<&-
LOG_FILE=/opt/dionaea/var/GCRdebug.log
# Open STDOUT as $LOG_FILE file for read and write.
exec 1<>$LOG_FILE
# Redirect STDERR to STDOUT
exec 2>&1
# Display shell commands with expanded args
#set -x
fi
# after placing file into init.d, must run:
# sudo update-rc.d dionaea defaults
. /lib/lsb/init-functions
BASEDIR="/opt/dionaea"
PIDFOLDER="/opt/dionaea/var/"
PIDFILE="/opt/dionaea/var/GCRdionaeaAlerts.pid"
LOGFILE="/opt/dionaea/var/log/GCRdionaeaAlerts.log"
NAME="GCRdionaeaAlerts"
DAEMON="/usr/bin/python3 /opt/dionaea/bin/GCRdionaeaAlerts.py"
USER="dionaea"
GROUP="dionaea"
if [[ $DEBUGME == "yes" ]]; then
printf "PIDFILE = $PIDFILE\n"
printf "LOGFILE = $LOGFILE\n"
printf "DAEMON = $DAEMON\n"
fi
if [ ! -d "$PIDFOLDER" ]; then
mkdir $PIDFOLDER
fi
case $1 in
start)
cd $BASEDIR
# $DAEMON > $LOGFILE 2>> $LOGFILE &
start-stop-daemon --start --quiet -u $USER -g $GROUP --remove-pidfile --make-pidfile --pidfile $PIDFILE --exec $DAEMON > $LOGFILE 2>> $LOGFILE &
log_daemon_msg "$DAEMON started ..."
log_end_msg 0
;;
stop)
if [ -e $PIDFILE ]; then
kill `cat $PIDFILE`
rm $PIDFILE
log_daemon_msg "$DAEMON stopped ..."
log_end_msg 0
else
log_daemon_msg "$DAEMON is *NOT* running"
log_end_msg 1
fi
;;
logs)
cat $LOGFILE
;;
status)
if [ -e $PIDFILE ]; then
status_of_proc -p $PIDFILE $DAEMON "$NAME process" && exit 0 || exit $?
else
log_daemon_msg "$DAEMON is not running ..."
log_end_msg 0
fi
;;
*)
# For invalid arguments, print the usage message.
echo "Usage: $0 {start|stop|logs|status}"
exit 2
;;
esac