Title: [opsview] [13192] Support for Ubuntu's Upstart.
- Revision
- 13192
- Author
- pknight
- Date
- 2013-08-09 12:25:23 +0100 (Fri, 09 Aug 2013)
Log Message
Support for Ubuntu's Upstart.
Modified Paths
Added Paths
Added: trunk/opsview-web/bin/opsview-web_daemon
===================================================================
--- trunk/opsview-web/bin/opsview-web_daemon (rev 0)
+++ trunk/opsview-web/bin/opsview-web_daemon 2013-08-09 11:25:23 UTC (rev 13192)
@@ -0,0 +1,21 @@
+#!/bin/bash
+
+# Foreground daemon that waits to catch SIGTERM to stop Opsview's web server.
+# Primarily for Ubuntu's Upstart.
+
+LOG='/var/log/opsview/upstart'
+
+function stop_opsview_web {
+ echo "TERMINATE signal detected, stopping opsview-web" >> $LOG
+ /usr/local/opsview-web/bin/opsview-web stop
+ exit
+}
+
+trap stop_opsview_web TERM
+
+echo "Starting opsview-web" >> $LOG
+/usr/local/opsview-web/bin/opsview-web start &
+
+while true; do
+ sleep 100d
+done
Added: trunk/opsview-web/debian/postinst
===================================================================
--- trunk/opsview-web/debian/postinst (rev 0)
+++ trunk/opsview-web/debian/postinst 2013-08-09 11:25:23 UTC (rev 13192)
@@ -0,0 +1,76 @@
+#!/bin/sh
+# postinst script for opsview-web
+#
+# see: dh_installdeb(1)
+#
+# AUTHORS:
+# Copyright (C) 2003-2013 Opsview Limited. All rights reserved
+#
+# This file is part of Opsview
+#
+# Opsview is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# Opsview is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Opsview; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+set -e
+
+# Include debconf
+. /usr/share/debconf/confmodule
+
+# summary of how this script can be called:
+# * <postinst> `configure' <most-recently-configured-version>
+# * <old-postinst> `abort-upgrade' <new version>
+# * <conflictor's-postinst> `abort-remove' `in-favour' <package>
+# <new-version>
+# * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
+# <failed-install-package> <version> `removing'
+# <conflicting-package> <version>
+# for details, see http://www.debian.org/doc/debian-policy/ or
+# the debian-policy package
+
+die() {
+ echo $1
+ exit 1
+}
+
+case "$1" in
+
+ configure)
+ if lsb_release -i | grep -q Ubuntu; then
+ echo "Configuring Upstart"
+ # Remove current startup and shutdown scripts from init.
+ rm -f /etc/init.d/opsview-web
+ update-rc.d opsview-web remove
+ # Create Upstart files.
+ cp /usr/local/nagios/installer/opsview-web-upstart-init.d /etc/init.d/opsview
+ ln -s /lib/init/upstart-job /etc/init.d/opsview-web-upstart
+ cp /usr/local/opsview-web/installer/opsview-web-upstart.conf /etc/init/opsview-web-upstart.conf
+ fi
+ ;;
+
+ install|upgrade|abort-upgrade|abort-remove|abort-deconfigure)
+ ;;
+
+ *)
+ echo "postinst called with unknown argument \`$1'" >&2
+ exit 1
+ ;;
+
+esac
+
+# dh_installdeb will replace this with shell code automatically
+# generated by other debhelper scripts.
+
+#DEBHELPER#
+
+exit 0
Modified: trunk/opsview-web/debian/prerm
===================================================================
--- trunk/opsview-web/debian/prerm 2013-08-09 11:15:13 UTC (rev 13191)
+++ trunk/opsview-web/debian/prerm 2013-08-09 11:25:23 UTC (rev 13192)
@@ -25,12 +25,23 @@
set -e
+if [ -f /usr/local/opsview-web/bin/opsview-web ]; then
+ /usr/local/opsview-web/bin/opsview-web stop || true
+fi
+
case "$1" in
+
+ remove|deconfigure|upgrade)
+ # Remove Ubuntu Upstart's files.
+ rm -f /etc/init/opsview-web-upstart.conf /etc/init.d/opsview-web /etc/init.d/opsview-web-upstart 2> /dev/null
+ ;;
+
+ failed-upgrade)
+ ;;
+
*)
- if [ -f /usr/local/opsview-web/bin/opsview-web ]; then
- /usr/local/opsview-web/bin/opsview-web stop || true
- fi
- ;;
+ ;;
+
esac
@@ -40,4 +51,3 @@
#DEBHELPER#
exit 0
-
Added: trunk/opsview-web/installer/opsview-web-upstart-init.d
===================================================================
--- trunk/opsview-web/installer/opsview-web-upstart-init.d (rev 0)
+++ trunk/opsview-web/installer/opsview-web-upstart-init.d 2013-08-09 11:25:23 UTC (rev 13192)
@@ -0,0 +1,10 @@
+#!/bin/bash
+
+case "$1" in
+ stop|start|restart)
+ /etc/init.d/opsview-web-upstart "$@"
+ ;;
+ *)
+ /usr/local/opsview-web/bin/opsview-web "$@"
+ ;;
+esac
Added: trunk/opsview-web/installer/opsview-web-upstart.conf
===================================================================
--- trunk/opsview-web/installer/opsview-web-upstart.conf (rev 0)
+++ trunk/opsview-web/installer/opsview-web-upstart.conf 2013-08-09 11:25:23 UTC (rev 13192)
@@ -0,0 +1,24 @@
+# opsview-web service for Ubuntu's Upstart
+
+description "Opsview web server"
+author "Opsview Ltd."
+
+start on runlevel [2345] or started JOB=opsview-upstart
+stop on starting rc RUNLEVEL=[016] or stopping JOB=opsview-upstart
+
+expect fork
+kill timeout 300
+respawn limit 2 5
+
+pre-start script
+ bash -- <<EOS
+ if [[ ! $( pgrep -x '(nagios|opsviewd|rc.opsview)' ) ]]; then
+ echo "Opsview needs to be running" >> /var/log/opsview/upstart
+ exit 1
+ fi
+EOS
+end script
+
+script
+ /usr/local/opsview-web/bin/opsview-web_daemon
+end script
_______________________________________________
Opsview-checkins mailing list
Opsview-checkins@lists.opsview.org
http://lists.opsview.org/lists/listinfo/opsview-checkins