summaryrefslogtreecommitdiff
path: root/templates/irc_bot
diff options
context:
space:
mode:
authorMicah Anderson <micah@riseup.net>2011-04-11 12:30:51 -0400
committerMicah Anderson <micah@riseup.net>2011-04-11 12:30:51 -0400
commit7735baa65f0dc37f94d4854fd62c817de94d64f2 (patch)
tree1a4e7a70e27897e08e0e0bb754b4b4d1f2889967 /templates/irc_bot
parent2f2eb1cb12a57d8a85801086b6fbfce19e9c7a1b (diff)
parentf2df62c9d17d481a3d616a4f2de9496638fadc0a (diff)
Merge commit 'f2df62c9d17d481a3d616a4f2de9496638fadc0a'
Conflicts: manifests/defaults/commands.pp
Diffstat (limited to 'templates/irc_bot')
-rw-r--r--templates/irc_bot/CentOS/nagios-nsa.sh.erb104
-rw-r--r--templates/irc_bot/Debian/nagios-nsa.sh.erb71
-rw-r--r--templates/irc_bot/nsa.cfg.erb13
3 files changed, 188 insertions, 0 deletions
diff --git a/templates/irc_bot/CentOS/nagios-nsa.sh.erb b/templates/irc_bot/CentOS/nagios-nsa.sh.erb
new file mode 100644
index 0000000..1561afd
--- /dev/null
+++ b/templates/irc_bot/CentOS/nagios-nsa.sh.erb
@@ -0,0 +1,104 @@
+#!/bin/sh
+#
+# nagios-nsa - manage nagios irc bot
+#
+# chkconfig: - 99 01
+# description: Nagios Simple IRC Agent
+
+### BEGIN INIT INFO
+# Provides: nagios-nsa
+# Required-Start: $nagios
+# Required-Stop: $nagios
+# Default-Start: 2 3 4 5
+# Default-Stop: 1 6 0
+# Short-Description: Nagios Simple IRC Agent
+### END INIT INFO
+
+# Source function library.
+. /etc/rc.d/init.d/functions
+
+exec="/usr/local/bin/riseup-nagios-server.pl"
+prog="nsa"
+PIDFILE=<%= nagios_nsa_pidfile %>
+SOCKFILE=<%= nagios_nsa_socket %>
+
+[ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
+
+lockfile=/var/lock/subsys/$prog
+mkdir -p /var/run/nagios-nsa 2>/dev/null
+chown nagios /var/run/nagios-nsa
+
+start() {
+ [ -x $exec ] || exit 5
+ [ -f $config ] || exit 6
+ echo -n $"Starting $prog: "
+ daemon --pidfile $PIDFILE --user nagios /usr/local/bin/riseup-nagios-server.pl
+ retval=$?
+ echo
+ [ $retval -eq 0 ] && touch $lockfile
+ return $retval
+}
+
+stop() {
+ echo -n $"Stopping $prog: "
+ killproc -p $PIDFILE $prog
+ retval=$?
+ echo
+ [ $retval -eq 0 ] && rm -f $lockfile
+ return $retval
+}
+
+restart() {
+ stop
+ start
+}
+
+reload() {
+ restart
+}
+
+force_reload() {
+ restart
+}
+
+rh_status() {
+ # run checks to determine if the service is running or use generic status
+ status -p $PIDFILE $prog
+}
+
+rh_status_q() {
+ rh_status >/dev/null 2>&1
+}
+
+
+case "$1" in
+ start)
+ rh_status_q && exit 0
+ $1
+ ;;
+ stop)
+ rh_status_q || exit 0
+ $1
+ ;;
+ restart)
+ $1
+ ;;
+ reload)
+ rh_status_q || exit 7
+ $1
+ ;;
+ force-reload)
+ force_reload
+ ;;
+ status)
+ rh_status
+ ;;
+ condrestart|try-restart)
+ rh_status_q || exit 0
+ restart
+ ;;
+ *)
+ echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
+ exit 2
+esac
+exit $?
diff --git a/templates/irc_bot/Debian/nagios-nsa.sh.erb b/templates/irc_bot/Debian/nagios-nsa.sh.erb
new file mode 100644
index 0000000..6e608db
--- /dev/null
+++ b/templates/irc_bot/Debian/nagios-nsa.sh.erb
@@ -0,0 +1,71 @@
+#! /bin/sh
+
+### BEGIN INIT INFO
+# Provides: nagios-nsa
+# Required-Start: $remote_fs $syslog $nagios
+# Required-Stop: $remote_fs $syslog $nagios
+# Default-Start: 2 3 4 5
+# Default-Stop: 1 6 0
+# Short-Description: Nagios Simple IRC Agent
+### END INIT INFO
+
+PIDFILE=<%= nagios_nsa_pidfile %>
+SOCKFILE=<%= nagios_nsa_socket %>
+
+. /lib/lsb/init-functions
+
+start() {
+ log_daemon_msg "Starting nagios IRC bot" "nagios-nsa"
+ if start-stop-daemon --start --quiet --oknodo --pidfile $PIDFILE --user nagios --chuid nagios --exec /usr/local/bin/riseup-nagios-server.pl; then
+ log_end_msg 0
+ else
+ log_end_msg 1
+ fi
+}
+
+stop () {
+ log_daemon_msg "Stopping nagios IRC bot" "nagios-nsa"
+ if start-stop-daemon --stop --quiet --pidfile $PIDFILE; then
+ log_end_msg 0
+ else
+ log_end_msg 1
+ fi
+}
+
+remove_socket() {
+ [ -e $SOCKFILE ] && rm $SOCKFILE
+}
+
+cleanup() {
+ if [ -r $PIDFILE ]; then
+ ps -p `cat $PIDFILE` | grep -v 'PID' || {
+ echo "not running"
+ remove_socket
+ }
+ else
+ echo "no pid file"
+ remove_socket
+ fi
+}
+
+case $1
+in
+ start)
+ start
+ ;;
+ stop)
+ stop
+ ;;
+ restart)
+ stop
+ cleanup
+ start
+ ;;
+ status)
+ status_of_proc -p $PIDFILE /usr/local/bin/riseup-nagios-server.pl && exit 0 || exit $?
+ ;;
+ *)
+ log_action_msg "Usage: /etc/init.d/nagios-nsa {start|stop|restart|status}"
+ exit 1
+esac
+
diff --git a/templates/irc_bot/nsa.cfg.erb b/templates/irc_bot/nsa.cfg.erb
new file mode 100644
index 0000000..7cba62c
--- /dev/null
+++ b/templates/irc_bot/nsa.cfg.erb
@@ -0,0 +1,13 @@
+%Nsa = (
+ 'socket' => '<%= nagios_nsa_socket %>',
+ 'server' => '<%= nagios_nsa_server %>',
+ 'port' => '<%= nagios_nsa_port %>',
+ 'nickname' => '<%= nagios_nsa_nickname %>',
+ 'password' => '<%= nagios_nsa_password %>',
+ # this needs libio-socket-ssl-perl
+ # doesn't actually works because Net::IRC is braindead and tries to use IO::Socket::SSL->read/write instead of the builtin print, see http://search.cpan.org/dist/IO-Socket-SSL/SSL.pm
+ #'SSL' => 0,
+ 'channel' => '<%= nagios_nsa_channel %>',
+ 'pidfile' => '<%= nagios_nsa_pidfile %>', # set to undef to disable
+ 'realname' => "<%= nagios_nsa_realname %>",
+);