abusehelper: Cleaned up botnet.init, handle botnets which specify startup file

This commit is contained in:
Ossi Salmi 2013-06-04 14:40:06 +03:00
parent 1d4e10e224
commit dd0d11df05

View file

@ -35,30 +35,41 @@ if [ -z "${BOTNETS}" ]; then
exit 1
fi
botnet_action() {
action="$1"
botnet="$2"
echo -n "${botnet}: "
if [ -d ${botnet} ]; then
startup="."
elif [ -f ${botnet} ]; then
startup="$(basename ${botnet})"
botnet="$(dirname ${botnet})"
else
echo "No such file or directory."
return 1
fi
su -s /bin/sh - ${BOTUSER} \
-c "umask 007 ; cd ${botnet} && botnet ${action} ${startup}"
}
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 ."
botnet_action start ${botnet}
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 ."
botnet_action stop ${botnet}
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 ."
botnet_action restart ${botnet}
done
}