Added init script for abusehelper botnets
$abusehelper_botnets is an array of botnet paths to be started at boot, for example: $abusehelper_botnets = ["/var/lib/ah2/botnet1", "/var/lib/ah2/botnet2"]
This commit is contained in:
parent
3704a86d50
commit
603df85cea
3 changed files with 123 additions and 1 deletions
81
abusehelper/files/botnet.init
Normal file
81
abusehelper/files/botnet.init
Normal file
|
@ -0,0 +1,81 @@
|
|||
#!/bin/sh
|
||||
|
||||
# chkconfig: 2345 85 60
|
||||
# description: AbuseHelper botnets
|
||||
# processname: botnet
|
||||
|
||||
### BEGIN INIT INFO
|
||||
# Provides: botnet
|
||||
# Required-Start: $local_fs $network $syslog
|
||||
# Should-Start:
|
||||
# Required-Stop:
|
||||
# Default-Start: 2 3 4 5
|
||||
# Default-Stop: 0 1 6
|
||||
# Short-Description: AbuseHelper botnets
|
||||
# Description: AbuseHelper botnets
|
||||
### END INIT INFO
|
||||
|
||||
if [ $(id -u) != "0" ]; then
|
||||
echo "This script must be run with root privileges." && exit 1
|
||||
fi
|
||||
|
||||
if [ -s /etc/default/botnet ]; then
|
||||
. /etc/default/botnet
|
||||
elif [ -s /etc/sysconfig/botnet ]; then
|
||||
. /etc/sysconfig/botnet
|
||||
fi
|
||||
|
||||
if [ -z "${BOTUSER}" ]; then
|
||||
echo "$0: no BOTUSER defined"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "${BOTNETS}" ]; then
|
||||
echo "$0: no BOTNETS defined"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
start_botnets() {
|
||||
for botnet in ${BOTNETS}; do
|
||||
echo -n "${botnet}: "
|
||||
test -d ${botnet} || { echo "No such directory."; continue; }
|
||||
su -s /bin/sh - ${BOTUSER} \
|
||||
-c "umask 007 ; cd ${botnet} && botnet start ."
|
||||
done
|
||||
}
|
||||
|
||||
stop_botnets() {
|
||||
for botnet in ${BOTNETS}; do
|
||||
echo -n "${botnet}: "
|
||||
test -d ${botnet} || { echo "No such directory."; continue; }
|
||||
su -s /bin/sh - ${BOTUSER} \
|
||||
-c "umask 007 ; cd ${botnet} && botnet stop ."
|
||||
done
|
||||
}
|
||||
|
||||
restart_botnets() {
|
||||
for botnet in ${BOTNETS}; do
|
||||
echo -n "${botnet}: "
|
||||
test -d ${botnet} || { echo "No such directory."; continue; }
|
||||
su -s /bin/sh - ${BOTUSER} \
|
||||
-c "umask 007 ; cd ${botnet} && botnet restart ."
|
||||
done
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
start_botnets
|
||||
;;
|
||||
stop)
|
||||
stop_botnets
|
||||
;;
|
||||
restart)
|
||||
restart_botnets
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $0 {start|stop|restart}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
exit 0
|
Loading…
Add table
Add a link
Reference in a new issue