Merge tmakinen/puppet

This commit is contained in:
Ossi Salmi 2013-02-04 16:10:27 +02:00
commit 4b3c310936
4 changed files with 136 additions and 2 deletions

View 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

View file

@ -1,4 +1,12 @@
# Install abusehelper from svn.
# Install abusehelper.
#
# === Global variables
#
# $abusehelper_botnets
# Array of botnet paths to start at boot.
#
# $abusehelper_user
# User botnets run as. Defaults to 'abusehel'.
#
class abusehelper {
@ -105,4 +113,47 @@ class abusehelper {
}
}
if !$abusehelper_user {
$abusehelper_user = "abusehel"
}
if $abusehelper_botnets {
file { "/etc/sysconfig/botnet":
ensure => present,
name => $::operatingsystem ? {
"debian" => "/etc/default/botnet",
"ubuntu" => "/etc/default/botnet",
default => "/etc/sysconfig/botnet",
},
mode => "0644",
owner => "root",
group => "root",
content => template("abusehelper/botnet.sysconfig.erb"),
before => Service["botnet"],
}
file { "/etc/init.d/botnet":
ensure => present,
mode => "0755",
owner => "root",
group => "root",
source => "puppet:///modules/abusehelper/botnet.init",
notify => Exec["add-service-botnet"],
}
exec { "add-service-botnet":
path => "/bin:/usr/bin:/sbin:/usr/sbin",
command => $::operatingsystem ? {
"debian" => "update-rc.d botnet defaults",
"ubuntu" => "update-rc.d botnet defaults",
default => "chkconfig --add botnet",
},
refreshonly => true,
before => Service["botnet"],
}
service { "botnet":
enable => true,
}
}
}

View file

@ -0,0 +1,2 @@
BOTUSER="<%= abusehelper_user %>"
BOTNETS="<%= abusehelper_botnets.join(" ") %>"

View file

@ -52,7 +52,7 @@ class ruby::rails {
} else {
require ruby::rubygems
package { "rubygem-rails":
ensure => "2.3.15",
ensure => "2.3.16",
name => "rails",
provider => "gem",
}