Code

Split package into "pnp4nagios-bin" and "pnp4nagios-web".
authorSebastian Harl <sh@tokkee.org>
Thu, 3 Feb 2011 11:23:18 +0000 (12:23 +0100)
committerSebastian Harl <sh@tokkee.org>
Thu, 3 Feb 2011 11:23:18 +0000 (12:23 +0100)
In theory, this allows to run the two parts on different hosts. Also, this
way, the rather large /usr/share is shipped in an arch=all package.

16 files changed:
debian/control
debian/dirs [deleted file]
debian/pnp4nagios-bin.default [new file with mode: 0644]
debian/pnp4nagios-bin.init [new file with mode: 0644]
debian/pnp4nagios-bin.install [new file with mode: 0644]
debian/pnp4nagios-bin.postinst [new file with mode: 0644]
debian/pnp4nagios-bin.postrm [new file with mode: 0644]
debian/pnp4nagios-web.install [new file with mode: 0644]
debian/pnp4nagios-web.links [new file with mode: 0644]
debian/pnp4nagios-web.postinst [new file with mode: 0644]
debian/pnp4nagios-web.postrm [new file with mode: 0644]
debian/pnp4nagios.default [deleted file]
debian/pnp4nagios.init [deleted file]
debian/postinst [deleted file]
debian/postrm [deleted file]
debian/rules

index ab07b896f9a5536e1b194d92c3089bf4cb1e3619..80691ec802b119caa427ff334f3c52c4ef5d0354 100644 (file)
@@ -8,14 +8,47 @@ Standards-Version: 3.9.1
 Homepage: http://www.pnp4nagios.org/
 
 Package: pnp4nagios
+Architecture: all
+Depends: pnp4nagios-bin, pnp4nagios-web, ${misc:Depends}
+Description: Nagios addon to create graphs from performance data
+ PNP is a graphing tool for Nagios that analyzes performance data provided by
+ plugins and stores them automatically into Round Robin Databases (RRD). It
+ fully integrates itself into the Nagios Monitoring Website.
+ .
+ PNP's goal is to be easily configurable and maintainable.
+ .
+ This is a metapackage depending on all parts of PNP4Nagios.
+
+Package: pnp4nagios-bin
 Architecture: any
-Depends: rrdtool, librrds-perl, libapache2-mod-php5 | php5, php5-gd,
- libfpdi-php, libkohana-php,
+Depends: librrds-perl, adduser, ${shlibs:Depends}, ${misc:Depends}
+Recommends: pnp4nagios-web, nagios3 | icinga
+Suggests: rrdcached
+Description: Nagios addon to create graphs from performance data (binaries)
+ PNP is a graphing tool for Nagios that analyzes performance data provided by
+ plugins and stores them automatically into Round Robin Databases (RRD). It
+ fully integrates itself into the Nagios Monitoring Website.
+ .
+ PNP's goal is to be easily configurable and maintainable.
+ .
+ This package contains the NPCD-related binaries and process_perfdata.pl.
+
+Package: pnp4nagios-web
+Architecture: all
+Depends: libapache2-mod-php5 | php5, php5-gd,
+ libkohana-php,
+ libfpdi-php,
  libjs-jquery, libjs-jquery-ui,
- adduser, ${shlibs:Depends}, ${misc:Depends}
-Description: Nagios addon to create graphs from performance data
+ rrdtool,
+ adduser,
+ ${misc:Depends}
+Recommends: pnp4nagios-bin
+Suggests: rrdcached
+Description: Nagios addon to create graphs from performance data (web interface)
  PNP is a graphing tool for Nagios that analyzes performance data provided by
  plugins and stores them automatically into Round Robin Databases (RRD). It
  fully integrates itself into the Nagios Monitoring Website.
  .
  PNP's goal is to be easily configurable and maintainable.
+ .
+ This package contains the web-interface for PNP4Nagios.
diff --git a/debian/dirs b/debian/dirs
deleted file mode 100644 (file)
index 1e4d277..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-usr/sbin
-usr/share/doc/pnp4nagios/examples/
diff --git a/debian/pnp4nagios-bin.default b/debian/pnp4nagios-bin.default
new file mode 100644 (file)
index 0000000..737a536
--- /dev/null
@@ -0,0 +1,7 @@
+# Default settings for the pnp4nagios init script.
+
+# Should NPCD be started? ("yes" to enable)
+RUN="yes"
+
+# Additional options that are passed to the daemon.
+DAEMON_OPTS="-d -f /etc/pnp4nagios/npcd.cfg"
diff --git a/debian/pnp4nagios-bin.init b/debian/pnp4nagios-bin.init
new file mode 100644 (file)
index 0000000..bfb1113
--- /dev/null
@@ -0,0 +1,231 @@
+#!/bin/sh
+#
+# init.d script for NPCD of PNP4Nagios
+#
+# Based on a example script of Javier Fernandez-Sanguino
+# Copyright (c) 2007 Javier Fernandez-Sanguino <jfs@debian.org>
+# Copyright (c) 2009 Sven Velt <sven@velt.de>
+#
+### BEGIN INIT INFO
+# Provides:          pnp4nagios-bin
+# Required-Start:    $network $local_fs $remote_fs
+# Required-Stop:     $network $local_fs $remote_fs
+# Should-Start:
+# Should-Stop:
+# Default-Start:     2 3 4 5
+# Default-Stop:      0 1 6
+# Short-Description: Nagios Performance C Daemon
+# Description:       Speed up processing of Nagios' performance data
+### END INIT INFO
+
+PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
+
+DAEMON=/usr/sbin/npcd
+NAME=npcd
+DESC="Nagios Performance C Daemon (PNP4Nagios)"
+LOGDIR=/var/log/pnp4nagios
+
+PIDFILE=/var/run/$NAME.pid
+
+test -x $DAEMON || exit 0
+
+. /lib/lsb/init-functions
+
+# Default options, these can be overriden by the information
+# at /etc/default/$NAME
+DAEMON_OPTS=""
+DIETIME=10
+STARTTIME=2
+LOGFILE=$LOGDIR/$NAME.log
+
+# Include defaults if available
+if [ -f /etc/default/pnp4nagios ] ; then
+       . /etc/default/pnp4nagios
+fi
+
+# Check if RUN is set to "yes" in /etc/defaults/pnp4nagios
+if [ "x$RUN" != "xyes" ] ; then
+#    log_failure_msg "$NAME disabled, please adjust the configuration to your needs "
+#    log_failure_msg "and then set RUN to 'yes' in /etc/default/$NAME to enable it."
+    exit 0
+fi
+
+set -e
+
+running_pid() {
+# Check if a given process pid's cmdline matches a given name
+    pid=$1
+    name=$2
+    [ -z "$pid" ] && return 1
+    [ ! -d /proc/$pid ] &&  return 1
+    cmd=`cat /proc/$pid/cmdline | tr "\000" "\n"|head -n 1 |cut -d : -f 1`
+    # Is this the expected server
+    [ "$cmd" != "$name" ] &&  return 1
+    return 0
+}
+
+running() {
+# Check if the process is running looking at /proc
+# (works for all users)
+
+    # No pidfile, probably no daemon present
+    [ ! -f "$PIDFILE" ] && return 1
+    pid=`cat $PIDFILE`
+    running_pid $pid $DAEMON || return 1
+    return 0
+}
+
+start_server() {
+# Start the process using the wrapper
+        start_daemon -p $PIDFILE $DAEMON $DAEMON_OPTS
+        errcode=$?
+        return $errcode
+}
+
+stop_server() {
+# Stop the process using the wrapper
+        killproc -p $PIDFILE $DAEMON
+        errcode=$?
+       return $errcode
+}
+
+reload_server() {
+    [ ! -f "$PIDFILE" ] && return 1
+    pid=pidofproc $PIDFILE # This is the daemon's pid
+    # Send a SIGHUP
+    kill -1 $pid
+    return $?
+}
+
+force_stop() {
+# Force the process to die killing it manually
+       [ ! -e "$PIDFILE" ] && return
+       if running ; then
+               kill -15 $pid
+       # Is it really dead?
+               sleep "$DIETIME"s
+               if running ; then
+                       kill -9 $pid
+                       sleep "$DIETIME"s
+                       if running ; then
+                               echo "Cannot kill $NAME (pid=$pid)!"
+                               exit 1
+                       fi
+               fi
+       fi
+       rm -f $PIDFILE
+}
+
+
+case "$1" in
+  start)
+       log_daemon_msg "Starting $DESC " "$NAME"
+        # Check if it's running first
+        if running ;  then
+            log_progress_msg "apparently already running"
+            log_end_msg 0
+            exit 0
+        fi
+        if start_server ; then
+            # NOTE: Some servers might die some time after they start,
+            # this code will detect this issue if STARTTIME is set
+            # to a reasonable value
+            [ -n "$STARTTIME" ] && sleep $STARTTIME # Wait some time 
+            if  running ;  then
+                # It's ok, the server started and is running
+                log_end_msg 0
+            else
+                # It is not running after we did start
+                log_end_msg 1
+            fi
+        else
+            # Either we could not start it
+            log_end_msg 1
+        fi
+       ;;
+  stop)
+        log_daemon_msg "Stopping $DESC" "$NAME"
+        if running ; then
+            # Only stop the server if we see it running
+                       errcode=0
+            stop_server || errcode=$?
+            log_end_msg $errcode
+        else
+            # If it's not running don't do anything
+            log_progress_msg "apparently not running"
+            log_end_msg 0
+            exit 0
+        fi
+        ;;
+  force-stop)
+        # First try to stop gracefully the program
+        $0 stop
+        if running; then
+            # If it's still running try to kill it more forcefully
+            log_daemon_msg "Stopping (force) $DESC" "$NAME"
+                       errcode=0
+            force_stop || errcode=$?
+            log_end_msg $errcode
+        fi
+       ;;
+  restart|force-reload)
+        log_daemon_msg "Restarting $DESC" "$NAME"
+               errcode=0
+        stop_server || errcode=$?
+        # Wait some sensible amount, some server need this
+        [ -n "$DIETIME" ] && sleep $DIETIME
+        start_server || errcode=$?
+        [ -n "$STARTTIME" ] && sleep $STARTTIME
+        running || errcode=$?
+        log_end_msg $errcode
+       ;;
+  status)
+
+        log_daemon_msg "Checking status of $DESC" "$NAME"
+        if running ;  then
+            log_progress_msg "running"
+            log_end_msg 0
+        else
+            log_progress_msg "apparently not running"
+            log_end_msg 1
+            exit 1
+        fi
+        ;;
+  # Use this if the daemon cannot reload
+  reload)
+        log_warning_msg "Reloading $NAME daemon: not implemented, as the daemon"
+        log_warning_msg "cannot re-read the config file (use restart)."
+        ;;
+  # And this if it cann
+  #reload)
+          #
+          # If the daemon can reload its config files on the fly
+          # for example by sending it SIGHUP, do it here.
+          #
+          # If the daemon responds to changes in its config file
+          # directly anyway, make this a do-nothing entry.
+          #
+          # log_daemon_msg "Reloading $DESC configuration files" "$NAME"
+          # if running ; then
+          #    reload_server
+          #    if ! running ;  then
+          # Process died after we tried to reload
+          #       log_progress_msg "died on reload"
+          #       log_end_msg 1
+          #       exit 1
+          #    fi
+          # else
+          #    log_progress_msg "server is not running"
+          #    log_end_msg 1
+          #    exit 1
+          # fi
+                                                                                    #;;
+
+  *)
+       N=/etc/init.d/$NAME
+       echo "Usage: $N {start|stop|force-stop|restart|force-reload|status}" >&2
+       exit 1
+       ;;
+esac
+
+exit 0
diff --git a/debian/pnp4nagios-bin.install b/debian/pnp4nagios-bin.install
new file mode 100644 (file)
index 0000000..97e44ae
--- /dev/null
@@ -0,0 +1,10 @@
+etc/pnp4nagios/nagios.cfg
+etc/pnp4nagios/check_commands/
+etc/pnp4nagios/*.cfg
+usr/lib/pnp4nagios/
+usr/sbin/npcd
+usr/share/doc/pnp4nagios/examples/*.cfg
+usr/share/doc/pnp4nagios/examples/check_commands/
+var/log/pnp4nagios/stats/
+var/lib/pnp4nagios/perfdata/
+var/spool/pnp4nagios/
diff --git a/debian/pnp4nagios-bin.postinst b/debian/pnp4nagios-bin.postinst
new file mode 100644 (file)
index 0000000..d3bc340
--- /dev/null
@@ -0,0 +1,70 @@
+#!/bin/sh
+# postinst script for pnp4nagios-bin
+#
+# see: dh_installdeb(1)
+
+set -e
+
+# 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>
+#        * <postinst> `abort-remove'
+#        * <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
+
+setperm() {
+       user="$1"
+       group="$2"
+       mode="$3"
+       file="$4"
+       shift 4
+       # only do something when no setting exists
+       if ! dpkg-statoverride --list "$file" >/dev/null 2>&1; then
+               chown "$user":"$group" "$file"
+               chmod "$mode" "$file"
+       fi
+}
+
+case "$1" in
+       configure)
+               if ! getent passwd nagios > /dev/null ; then
+                       echo 'Adding system-user for nagios' 1>&2
+                       adduser --system --group --home /var/lib/nagios \
+                               --disabled-login --force-badname nagios > /dev/null
+               fi
+               setperm nagios www-data 750 /var/lib/pnp4nagios
+               setperm nagios nagios   755 /var/lib/pnp4nagios/perfdata
+               setperm nagios www-data 750 /var/log/pnp4nagios
+               setperm nagios nagios   750 /var/log/pnp4nagios/stats
+               setperm nagios nagios   770 /var/spool/pnp4nagios
+               setperm nagios nagios   770 /var/spool/pnp4nagios/nagios
+               setperm nagios nagios   770 /var/spool/pnp4nagios/npcd
+
+               if [ -d /etc/nagios3/conf.d/ ]; then
+                       if [ ! -e /etc/nagios3/conf.d/pnp4nagios.cfg ]; then
+                               ln -s /etc/pnp4nagios/nagios.cfg /etc/nagios3/conf.d/pnp4nagios.cfg
+                       fi
+               fi
+       ;;
+
+       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
+
diff --git a/debian/pnp4nagios-bin.postrm b/debian/pnp4nagios-bin.postrm
new file mode 100644 (file)
index 0000000..7e12fcd
--- /dev/null
@@ -0,0 +1,48 @@
+#!/bin/sh
+# postrm script for pnp4nagios-bin
+#
+# see: dh_installdeb(1)
+
+set -e
+
+# summary of how this script can be called:
+#        * <postrm> `remove'
+#        * <postrm> `purge'
+#        * <old-postrm> `upgrade' <new-version>
+#        * <new-postrm> `failed-upgrade' <old-version>
+#        * <new-postrm> `abort-install'
+#        * <new-postrm> `abort-install' <old-version>
+#        * <new-postrm> `abort-upgrade' <old-version>
+#        * <disappearer's-postrm> `disappear' <overwriter>
+#          <overwriter-version>
+# for details, see http://www.debian.org/doc/debian-policy/ or
+# the debian-policy package
+
+
+case "$1" in
+       purge|remove)
+               if [ -d /etc/nagios3/conf.d/ ]; then
+                       if [ -L /etc/nagios3/conf.d/pnp4nagios.cfg ]; then
+                               ls -l /etc/nagios3/conf.d/pnp4nagios.cfg | grep -q /etc/pnp4nagios/nagios.cfg
+                               if [ $? -eq 0 ]; then
+                                       rm -f /etc/nagios3/conf.d/pnp4nagios.cfg
+                               fi
+                       fi
+               fi
+       ;;
+       upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
+       ;;
+
+       *)
+               echo "postrm 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
+
diff --git a/debian/pnp4nagios-web.install b/debian/pnp4nagios-web.install
new file mode 100644 (file)
index 0000000..84b5156
--- /dev/null
@@ -0,0 +1,13 @@
+etc/pnp4nagios/apache.conf
+etc/pnp4nagios/background.pdf
+etc/pnp4nagios/templates/
+etc/pnp4nagios/pages/
+etc/pnp4nagios/templates.special/
+etc/pnp4nagios/pnp4nagios_release
+etc/pnp4nagios/config.php
+usr/share/doc/pnp4nagios/examples/templates.special/
+usr/share/doc/pnp4nagios/examples/pages/
+usr/share/doc/pnp4nagios/examples/ssi/
+usr/share/pnp4nagios/html/
+var/log/pnp4nagios/kohana/
+var/lib/pnp4nagios/
diff --git a/debian/pnp4nagios-web.links b/debian/pnp4nagios-web.links
new file mode 100644 (file)
index 0000000..9864443
--- /dev/null
@@ -0,0 +1,4 @@
+/usr/share/php/fpdf /usr/share/pnp4nagios/html/application/vendor/fpdf
+/usr/share/php/fpdi /usr/share/pnp4nagios/html/application/vendor/fpdi
+/usr/share/javascript/jquery/jquery.min.js /usr/share/pnp4nagios/html/media/js/jquery-min.js
+/usr/share/javascript/jquery-ui/jquery-ui.js /usr/share/pnp4nagios/html/media/js/jquery-ui.min.js
diff --git a/debian/pnp4nagios-web.postinst b/debian/pnp4nagios-web.postinst
new file mode 100644 (file)
index 0000000..d2fd8aa
--- /dev/null
@@ -0,0 +1,81 @@
+#!/bin/sh
+# postinst script for pnp4nagios-web
+#
+# see: dh_installdeb(1)
+
+set -e
+
+# 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>
+#        * <postinst> `abort-remove'
+#        * <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
+
+setperm() {
+       user="$1"
+       group="$2"
+       mode="$3"
+       file="$4"
+       shift 4
+       # only do something when no setting exists
+       if ! dpkg-statoverride --list "$file" >/dev/null 2>&1; then
+               chown "$user":"$group" "$file"
+               chmod "$mode" "$file"
+       fi
+}
+
+case "$1" in
+       configure)
+               if ! getent passwd nagios > /dev/null ; then
+                       echo 'Adding system-user for nagios' 1>&2
+                       adduser --system --group --home /var/lib/nagios \
+                               --disabled-login --force-badname nagios > /dev/null
+               fi
+               setperm nagios www-data 750 /var/lib/pnp4nagios
+               setperm nagios nagios   755 /var/lib/pnp4nagios/perfdata
+               setperm nagios www-data 750 /var/log/pnp4nagios
+               setperm nagios nagios   750 /var/log/pnp4nagios/stats
+
+               a2reload="false"
+
+               if [ -d /etc/apache2/conf.d/ ]; then
+                       if [ ! -e /etc/apache2/conf.d/pnp4nagios.conf ]; then
+                               ln -s /etc/pnp4nagios/apache.conf /etc/apache2/conf.d/pnp4nagios.conf
+                               a2reload="true"
+                       fi
+               fi
+
+               if [ -d /etc/apache2/mods-enabled ]; then
+                       if [ ! -e /etc/apache2/mods-enabled/rewrite.load ]; then
+                               a2enmod rewrite
+                               a2reload="true"
+                       fi
+               fi
+
+               if [ "$a2reload" = "true" ]; then
+                       invoke-rc.d apache2 reload
+               fi
+       ;;
+
+       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
+
diff --git a/debian/pnp4nagios-web.postrm b/debian/pnp4nagios-web.postrm
new file mode 100644 (file)
index 0000000..40781ab
--- /dev/null
@@ -0,0 +1,48 @@
+#!/bin/sh
+# postrm script for pnp4nagios-web
+#
+# see: dh_installdeb(1)
+
+set -e
+
+# summary of how this script can be called:
+#        * <postrm> `remove'
+#        * <postrm> `purge'
+#        * <old-postrm> `upgrade' <new-version>
+#        * <new-postrm> `failed-upgrade' <old-version>
+#        * <new-postrm> `abort-install'
+#        * <new-postrm> `abort-install' <old-version>
+#        * <new-postrm> `abort-upgrade' <old-version>
+#        * <disappearer's-postrm> `disappear' <overwriter>
+#          <overwriter-version>
+# for details, see http://www.debian.org/doc/debian-policy/ or
+# the debian-policy package
+
+
+case "$1" in
+       purge|remove)
+               if [ -d /etc/apache2/conf.d/ ]; then
+                       if [ -L /etc/apache2/conf.d/pnp4nagios.cfg ]; then
+                               ls -l /etc/apache2/conf.d/pnp4nagios.cfg | grep -q /etc/pnp4nagios/apache.cfg
+                               if [ $? -eq 0 ]; then
+                                       rm -f /etc/apache2/conf.d/pnp4nagios.cfg
+                               fi
+                       fi
+               fi
+       ;;
+       upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
+       ;;
+
+       *)
+               echo "postrm 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
+
diff --git a/debian/pnp4nagios.default b/debian/pnp4nagios.default
deleted file mode 100644 (file)
index 737a536..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-# Default settings for the pnp4nagios init script.
-
-# Should NPCD be started? ("yes" to enable)
-RUN="yes"
-
-# Additional options that are passed to the daemon.
-DAEMON_OPTS="-d -f /etc/pnp4nagios/npcd.cfg"
diff --git a/debian/pnp4nagios.init b/debian/pnp4nagios.init
deleted file mode 100644 (file)
index 0021d0f..0000000
+++ /dev/null
@@ -1,231 +0,0 @@
-#!/bin/sh
-#
-# init.d script for NPCD of PNP4Nagios
-#
-# Based on a example script of Javier Fernandez-Sanguino
-# Copyright (c) 2007 Javier Fernandez-Sanguino <jfs@debian.org>
-# Copyright (c) 2009 Sven Velt <sven@velt.de>
-#
-### BEGIN INIT INFO
-# Provides:          pnp4nagios
-# Required-Start:    $network $local_fs $remote_fs
-# Required-Stop:     $network $local_fs $remote_fs
-# Should-Start:
-# Should-Stop:
-# Default-Start:     2 3 4 5
-# Default-Stop:      0 1 6
-# Short-Description: Nagios Performance C Daemon
-# Description:       Speed up processing of Nagios' performance data
-### END INIT INFO
-
-PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
-
-DAEMON=/usr/sbin/npcd
-NAME=npcd
-DESC="Nagios Performance C Daemon (PNP4Nagios)"
-LOGDIR=/var/log/pnp4nagios
-
-PIDFILE=/var/run/$NAME.pid
-
-test -x $DAEMON || exit 0
-
-. /lib/lsb/init-functions
-
-# Default options, these can be overriden by the information
-# at /etc/default/$NAME
-DAEMON_OPTS=""
-DIETIME=10
-STARTTIME=2
-LOGFILE=$LOGDIR/$NAME.log
-
-# Include defaults if available
-if [ -f /etc/default/pnp4nagios ] ; then
-       . /etc/default/pnp4nagios
-fi
-
-# Check if RUN is set to "yes" in /etc/defaults/pnp4nagios
-if [ "x$RUN" != "xyes" ] ; then
-#    log_failure_msg "$NAME disabled, please adjust the configuration to your needs "
-#    log_failure_msg "and then set RUN to 'yes' in /etc/default/$NAME to enable it."
-    exit 0
-fi
-
-set -e
-
-running_pid() {
-# Check if a given process pid's cmdline matches a given name
-    pid=$1
-    name=$2
-    [ -z "$pid" ] && return 1
-    [ ! -d /proc/$pid ] &&  return 1
-    cmd=`cat /proc/$pid/cmdline | tr "\000" "\n"|head -n 1 |cut -d : -f 1`
-    # Is this the expected server
-    [ "$cmd" != "$name" ] &&  return 1
-    return 0
-}
-
-running() {
-# Check if the process is running looking at /proc
-# (works for all users)
-
-    # No pidfile, probably no daemon present
-    [ ! -f "$PIDFILE" ] && return 1
-    pid=`cat $PIDFILE`
-    running_pid $pid $DAEMON || return 1
-    return 0
-}
-
-start_server() {
-# Start the process using the wrapper
-        start_daemon -p $PIDFILE $DAEMON $DAEMON_OPTS
-        errcode=$?
-        return $errcode
-}
-
-stop_server() {
-# Stop the process using the wrapper
-        killproc -p $PIDFILE $DAEMON
-        errcode=$?
-       return $errcode
-}
-
-reload_server() {
-    [ ! -f "$PIDFILE" ] && return 1
-    pid=pidofproc $PIDFILE # This is the daemon's pid
-    # Send a SIGHUP
-    kill -1 $pid
-    return $?
-}
-
-force_stop() {
-# Force the process to die killing it manually
-       [ ! -e "$PIDFILE" ] && return
-       if running ; then
-               kill -15 $pid
-       # Is it really dead?
-               sleep "$DIETIME"s
-               if running ; then
-                       kill -9 $pid
-                       sleep "$DIETIME"s
-                       if running ; then
-                               echo "Cannot kill $NAME (pid=$pid)!"
-                               exit 1
-                       fi
-               fi
-       fi
-       rm -f $PIDFILE
-}
-
-
-case "$1" in
-  start)
-       log_daemon_msg "Starting $DESC " "$NAME"
-        # Check if it's running first
-        if running ;  then
-            log_progress_msg "apparently already running"
-            log_end_msg 0
-            exit 0
-        fi
-        if start_server ; then
-            # NOTE: Some servers might die some time after they start,
-            # this code will detect this issue if STARTTIME is set
-            # to a reasonable value
-            [ -n "$STARTTIME" ] && sleep $STARTTIME # Wait some time 
-            if  running ;  then
-                # It's ok, the server started and is running
-                log_end_msg 0
-            else
-                # It is not running after we did start
-                log_end_msg 1
-            fi
-        else
-            # Either we could not start it
-            log_end_msg 1
-        fi
-       ;;
-  stop)
-        log_daemon_msg "Stopping $DESC" "$NAME"
-        if running ; then
-            # Only stop the server if we see it running
-                       errcode=0
-            stop_server || errcode=$?
-            log_end_msg $errcode
-        else
-            # If it's not running don't do anything
-            log_progress_msg "apparently not running"
-            log_end_msg 0
-            exit 0
-        fi
-        ;;
-  force-stop)
-        # First try to stop gracefully the program
-        $0 stop
-        if running; then
-            # If it's still running try to kill it more forcefully
-            log_daemon_msg "Stopping (force) $DESC" "$NAME"
-                       errcode=0
-            force_stop || errcode=$?
-            log_end_msg $errcode
-        fi
-       ;;
-  restart|force-reload)
-        log_daemon_msg "Restarting $DESC" "$NAME"
-               errcode=0
-        stop_server || errcode=$?
-        # Wait some sensible amount, some server need this
-        [ -n "$DIETIME" ] && sleep $DIETIME
-        start_server || errcode=$?
-        [ -n "$STARTTIME" ] && sleep $STARTTIME
-        running || errcode=$?
-        log_end_msg $errcode
-       ;;
-  status)
-
-        log_daemon_msg "Checking status of $DESC" "$NAME"
-        if running ;  then
-            log_progress_msg "running"
-            log_end_msg 0
-        else
-            log_progress_msg "apparently not running"
-            log_end_msg 1
-            exit 1
-        fi
-        ;;
-  # Use this if the daemon cannot reload
-  reload)
-        log_warning_msg "Reloading $NAME daemon: not implemented, as the daemon"
-        log_warning_msg "cannot re-read the config file (use restart)."
-        ;;
-  # And this if it cann
-  #reload)
-          #
-          # If the daemon can reload its config files on the fly
-          # for example by sending it SIGHUP, do it here.
-          #
-          # If the daemon responds to changes in its config file
-          # directly anyway, make this a do-nothing entry.
-          #
-          # log_daemon_msg "Reloading $DESC configuration files" "$NAME"
-          # if running ; then
-          #    reload_server
-          #    if ! running ;  then
-          # Process died after we tried to reload
-          #       log_progress_msg "died on reload"
-          #       log_end_msg 1
-          #       exit 1
-          #    fi
-          # else
-          #    log_progress_msg "server is not running"
-          #    log_end_msg 1
-          #    exit 1
-          # fi
-                                                                                    #;;
-
-  *)
-       N=/etc/init.d/$NAME
-       echo "Usage: $N {start|stop|force-stop|restart|force-reload|status}" >&2
-       exit 1
-       ;;
-esac
-
-exit 0
diff --git a/debian/postinst b/debian/postinst
deleted file mode 100644 (file)
index a9c3e82..0000000
+++ /dev/null
@@ -1,91 +0,0 @@
-#!/bin/sh
-# postinst script for pnp4nagios
-#
-# see: dh_installdeb(1)
-
-set -e
-
-# 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>
-#        * <postinst> `abort-remove'
-#        * <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
-
-setperm() {
-       user="$1"
-       group="$2"
-       mode="$3"
-       file="$4"
-       shift 4
-       # only do something when no setting exists
-       if ! dpkg-statoverride --list "$file" >/dev/null 2>&1; then
-               chown "$user":"$group" "$file"
-               chmod "$mode" "$file"
-       fi
-}
-
-case "$1" in
-       configure)
-               if ! getent passwd nagios > /dev/null ; then
-                       echo 'Adding system-user for nagios' 1>&2
-                       adduser --system --group --home /var/lib/nagios \
-                               --disabled-login --force-badname nagios > /dev/null
-               fi
-               setperm nagios www-data 750 /var/lib/pnp4nagios
-               setperm nagios nagios   755 /var/lib/pnp4nagios/perfdata
-               setperm nagios www-data 750 /var/log/pnp4nagios
-               setperm nagios nagios   750 /var/log/pnp4nagios/stats
-               setperm nagios nagios   770 /var/spool/pnp4nagios
-               setperm nagios nagios   770 /var/spool/pnp4nagios/nagios
-               setperm nagios nagios   770 /var/spool/pnp4nagios/npcd
-
-               if [ -d /etc/nagios3/conf.d/ ]; then
-                       if [ ! -e /etc/nagios3/conf.d/pnp4nagios.cfg ]; then
-                               ln -s /etc/pnp4nagios/nagios.cfg /etc/nagios3/conf.d/pnp4nagios.cfg
-                       fi
-               fi
-
-               a2reload="false"
-
-               if [ -d /etc/apache2/conf.d/ ]; then
-                       if [ ! -e /etc/apache2/conf.d/pnp4nagios.conf ]; then
-                               ln -s /etc/pnp4nagios/apache.conf /etc/apache2/conf.d/pnp4nagios.conf
-                               a2reload="true"
-                       fi
-               fi
-
-               if [ -d /etc/apache2/mods-enabled ]; then
-                       if [ ! -e /etc/apache2/mods-enabled/rewrite.load ]; then
-                               a2enmod rewrite
-                               a2reload="true"
-                       fi
-               fi
-
-               if [ "$a2reload" = "true" ]; then
-                       invoke-rc.d apache2 reload
-               fi
-       ;;
-
-       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
-
-
diff --git a/debian/postrm b/debian/postrm
deleted file mode 100644 (file)
index d8f0d3e..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-#!/bin/sh
-# postrm script for pnp4nagios
-#
-# see: dh_installdeb(1)
-
-set -e
-
-# summary of how this script can be called:
-#        * <postrm> `remove'
-#        * <postrm> `purge'
-#        * <old-postrm> `upgrade' <new-version>
-#        * <new-postrm> `failed-upgrade' <old-version>
-#        * <new-postrm> `abort-install'
-#        * <new-postrm> `abort-install' <old-version>
-#        * <new-postrm> `abort-upgrade' <old-version>
-#        * <disappearer's-postrm> `disappear' <overwriter>
-#          <overwriter-version>
-# for details, see http://www.debian.org/doc/debian-policy/ or
-# the debian-policy package
-
-
-case "$1" in
-       purge|remove)
-               if [ -d /etc/nagios3/conf.d/ ]; then
-                       if [ -L /etc/nagios3/conf.d/pnp4nagios.cfg ]; then
-                               ls -l /etc/nagios3/conf.d/pnp4nagios.cfg | grep -q /etc/pnp4nagios/nagios.cfg
-                               if [ $? -eq 0 ]; then
-                                       rm -f /etc/nagios3/conf.d/pnp4nagios.cfg
-                               fi
-                       fi
-               fi
-
-               if [ -d /etc/apache2/conf.d/ ]; then
-                       if [ -L /etc/apache2/conf.d/pnp4nagios.cfg ]; then
-                               ls -l /etc/apache2/conf.d/pnp4nagios.cfg | grep -q /etc/pnp4nagios/apache.cfg
-                               if [ $? -eq 0 ]; then
-                                       rm -f /etc/apache2/conf.d/pnp4nagios.cfg
-                               fi
-                       fi
-               fi
-       ;;
-       upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
-       ;;
-
-       *)
-               echo "postrm 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
-
-
index 6962bd4215d028aa68d5fea97137d4fa7dc1de71..7f945b28741e2d3f7ab8b2f976b565de00419336 100755 (executable)
@@ -77,104 +77,116 @@ install: build
        dh_prep
        dh_installdirs
 
-       $(MAKE) DESTDIR=$(CURDIR)/debian/pnp4nagios \
+       $(MAKE) DESTDIR=$(CURDIR)/debian/tmp \
                INSTALL_OPTS="--owner=root --group=root" install install-config
 
        # Ignore install.php (for future debugging don't delete it)
-       touch debian/pnp4nagios/usr/share/pnp4nagios/html/install.ignore
+       touch debian/tmp/usr/share/pnp4nagios/html/install.ignore
+
+       mkdir -p debian/tmp/usr/share/doc/pnp4nagios/examples/
 
        # Move template config dir to /etc/pnp4nagios/templates
-       rmdir debian/pnp4nagios/usr/share/pnp4nagios/html/templates
-       mkdir debian/pnp4nagios/etc/pnp4nagios/templates
-       mv debian/pnp4nagios/usr/share/pnp4nagios/html/templates.special \
-               debian/pnp4nagios/usr/share/doc/pnp4nagios/examples/
-       mkdir debian/pnp4nagios/etc/pnp4nagios/templates.special
+       rmdir debian/tmp/usr/share/pnp4nagios/html/templates
+       mkdir debian/tmp/etc/pnp4nagios/templates
+       mv debian/tmp/usr/share/pnp4nagios/html/templates.special \
+               debian/tmp/usr/share/doc/pnp4nagios/examples/
+       mkdir debian/tmp/etc/pnp4nagios/templates.special
 
-       mv debian/pnp4nagios/usr/bin/npcd \
-               debian/pnp4nagios/usr/sbin/
-       mv debian/pnp4nagios/etc/pnp4nagios/npcd.cfg-sample \
-               debian/pnp4nagios/etc/pnp4nagios/npcd.cfg
+       mkdir -p debian/tmp/usr/sbin/
+       mv debian/tmp/usr/bin/npcd \
+               debian/tmp/usr/sbin/
+       mv debian/tmp/etc/pnp4nagios/npcd.cfg-sample \
+               debian/tmp/etc/pnp4nagios/npcd.cfg
 
-       mv debian/pnp4nagios/etc/pnp4nagios/process_perfdata.cfg-sample \
-               debian/pnp4nagios/etc/pnp4nagios/process_perfdata.cfg
+       mv debian/tmp/etc/pnp4nagios/process_perfdata.cfg-sample \
+               debian/tmp/etc/pnp4nagios/process_perfdata.cfg
 
-       mv debian/pnp4nagios/etc/pnp4nagios/rra.cfg-sample \
-               debian/pnp4nagios/etc/pnp4nagios/rra.cfg
+       mv debian/tmp/etc/pnp4nagios/rra.cfg-sample \
+               debian/tmp/etc/pnp4nagios/rra.cfg
 
-       mv debian/pnp4nagios/etc/pnp4nagios/nagios.cfg-sample \
-               debian/pnp4nagios/usr/share/doc/pnp4nagios/examples/nagios.cfg
+       mv debian/tmp/etc/pnp4nagios/nagios.cfg-sample \
+               debian/tmp/usr/share/doc/pnp4nagios/examples/nagios.cfg
 
-       mv debian/pnp4nagios/etc/pnp4nagios/misccommands.cfg-sample \
-               debian/pnp4nagios/usr/share/doc/pnp4nagios/examples/misccommands.cfg
+       mv debian/tmp/etc/pnp4nagios/misccommands.cfg-sample \
+               debian/tmp/usr/share/doc/pnp4nagios/examples/misccommands.cfg
 
-       mkdir debian/pnp4nagios/usr/share/doc/pnp4nagios/examples/check_commands
-       mv debian/pnp4nagios/etc/pnp4nagios/check_commands/check_nwstat.cfg-sample \
-               debian/pnp4nagios/usr/share/doc/pnp4nagios/examples/check_commands/check_nwstat.cfg
+       mkdir debian/tmp/usr/share/doc/pnp4nagios/examples/check_commands
+       mv debian/tmp/etc/pnp4nagios/check_commands/check_nwstat.cfg-sample \
+               debian/tmp/usr/share/doc/pnp4nagios/examples/check_commands/check_nwstat.cfg
 
-       mkdir debian/pnp4nagios/usr/share/doc/pnp4nagios/examples/pages
-       mv debian/pnp4nagios/etc/pnp4nagios/pages/web_traffic.cfg-sample \
-               debian/pnp4nagios/usr/share/doc/pnp4nagios/examples/pages/web_traffic.cfg
+       mkdir debian/tmp/usr/share/doc/pnp4nagios/examples/pages
+       mv debian/tmp/etc/pnp4nagios/pages/web_traffic.cfg-sample \
+               debian/tmp/usr/share/doc/pnp4nagios/examples/pages/web_traffic.cfg
 
-       cp -av contrib/ssi debian/pnp4nagios/usr/share/doc/pnp4nagios/examples/
+       cp -av contrib/ssi debian/tmp/usr/share/doc/pnp4nagios/examples/
 
        # Remove external PHP classes/libraries: FPDF, FPDF-TPL, FPDI
-       rm -r debian/pnp4nagios/usr/share/pnp4nagios/html/application/vendor/fpdf
-       # Link them into ".../vendor/"
-       dh_link /usr/share/php/fpdf /usr/share/pnp4nagios/html/application/vendor/fpdf
-       dh_link /usr/share/php/fpdi /usr/share/pnp4nagios/html/application/vendor/fpdi
+       rm -r debian/tmp/usr/share/pnp4nagios/html/application/vendor/fpdf
 
        # Remove external JavaScript files: jQuery and jQuery-UI
-       rm debian/pnp4nagios/usr/share/pnp4nagios/html/media/js/jquery-min.js
-       rm debian/pnp4nagios/usr/share/pnp4nagios/html/media/js/jquery-ui.min.js
-       # Link them
-       dh_link /usr/share/javascript/jquery/jquery.min.js /usr/share/pnp4nagios/html/media/js/jquery-min.js
-       dh_link /usr/share/javascript/jquery-ui/jquery-ui.js /usr/share/pnp4nagios/html/media/js/jquery-ui.min.js
+       rm debian/tmp/usr/share/pnp4nagios/html/media/js/jquery-min.js
+       rm debian/tmp/usr/share/pnp4nagios/html/media/js/jquery-ui.min.js
 
        # Clean up some files
-       rmdir debian/pnp4nagios/usr/bin
-       mv debian/pnp4nagios/etc/pnp4nagios/check_commands/check_all_local_disks.cfg-sample \
-               debian/pnp4nagios/etc/pnp4nagios/check_commands/check_all_local_disks.cfg
-       rm debian/pnp4nagios/etc/pnp4nagios/check_commands/check_nrpe.cfg-sample
+       rmdir debian/tmp/usr/bin
+       mv debian/tmp/etc/pnp4nagios/check_commands/check_all_local_disks.cfg-sample \
+               debian/tmp/etc/pnp4nagios/check_commands/check_all_local_disks.cfg
+       rm debian/tmp/etc/pnp4nagios/check_commands/check_nrpe.cfg-sample
 
        # Add Debian specific config and placeholder files
-       #touch debian/pnp4nagios/etc/pnp4nagios/pages/.placeholder
-       cp -av debian/nagios.cfg debian/pnp4nagios/etc/pnp4nagios/
-       cp -av debian/check_commands/* debian/pnp4nagios/etc/pnp4nagios/check_commands/
+       #touch debian/tmp/etc/pnp4nagios/pages/.placeholder
+       cp -av debian/nagios.cfg debian/tmp/etc/pnp4nagios/
+       cp -av debian/check_commands/* debian/tmp/etc/pnp4nagios/check_commands/
 
-       cp -av sample-config/httpd.conf debian/pnp4nagios/etc/pnp4nagios/apache.conf
+       cp -av sample-config/httpd.conf debian/tmp/etc/pnp4nagios/apache.conf
 
        # Add subdirs to /var/spool/pnp4nagios/ to prepare for different modes
-       mkdir debian/pnp4nagios/var/spool/pnp4nagios/nagios
-       mkdir debian/pnp4nagios/var/spool/pnp4nagios/npcd
+       mkdir debian/tmp/var/spool/pnp4nagios/nagios
+       mkdir debian/tmp/var/spool/pnp4nagios/npcd
 
        # Delete not used and empty directories
-       #rmdir debian/pnp4nagios/usr/share/pnp4nagios/html/application/logs/
-       rmdir debian/pnp4nagios/usr/share/pnp4nagios/html/application/cache/
-       rmdir debian/pnp4nagios/usr/share/pnp4nagios/html/application/hooks/
-       #rmdir debian/pnp4nagios/usr/share/pnp4nagios/html/application/libraries/
+       #rmdir debian/tmp/usr/share/pnp4nagios/html/application/logs/
+       rmdir debian/tmp/usr/share/pnp4nagios/html/application/cache/
+       rmdir debian/tmp/usr/share/pnp4nagios/html/application/hooks/
+       #rmdir debian/tmp/usr/share/pnp4nagios/html/application/libraries/
+
+       dh_install --sourcedir=debian/tmp --fail-missing
 
 # Build architecture-independent files here.
 binary-indep: build install
-# We have nothing to do by default.
+       dh_testdir
+       dh_testroot
+       dh_installchangelogs -i ChangeLog
+       dh_installdocs -A -i AUTHORS README
+       dh_installexamples -i
+       dh_installinit -i
+       dh_installman -i
+       dh_link -i
+       dh_compress -i
+       dh_fixperms -i
+       dh_installdeb -i
+       dh_gencontrol -i
+       dh_md5sums -i
+       dh_builddeb -i
 
 # Build architecture-dependent files here.
 binary-arch: build install
        dh_testdir
        dh_testroot
-       dh_installchangelogs ChangeLog
-       dh_installdocs AUTHORS README
-       dh_installexamples
-       dh_installinit
-       dh_installman
-       dh_link
-       dh_strip
-       dh_compress
-       dh_fixperms
-       dh_installdeb
-       dh_shlibdeps
-       dh_gencontrol
-       dh_md5sums
-       dh_builddeb
+       dh_installchangelogs -a ChangeLog
+       dh_installdocs -A -a AUTHORS README
+       dh_installexamples -a
+       dh_installinit -a
+       dh_installman -a
+       dh_link -a
+       dh_strip -a
+       dh_compress -a
+       dh_fixperms -a
+       dh_installdeb -a
+       dh_shlibdeps -a
+       dh_gencontrol -a
+       dh_md5sums -a
+       dh_builddeb -a
 
 binary: binary-indep binary-arch
 .PHONY: build clean binary-indep binary-arch binary install