abusehelper: Cleaned up botnet.init, handle botnets which specify startup file
This commit is contained in:
parent
1d4e10e224
commit
dd0d11df05
1 changed files with 23 additions and 12 deletions
|
@ -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
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue