[Pkg-nagios-devel] nagios nagios-common.config,NONE,1.1 nagios-common.copyright,NONE,1.1 nagios-common.docs,NONE,1.1 nagios-common.examples,NONE,1.1 nagios-common.init.d,NONE,1.1 nagios-common.postinst,NONE,1.1 nagios-common.postrm,NONE,1.1 nagios-common.preinst,NONE,1.1 BUGS.Debian,1.1.1.1,1.2 changelog,1.8,1.9 control,1.5,1.6 nagios-common.dirs,1.1,1.2 nagios-common.install,1.1,1.2 rules,1.7,1.8 config,1.2,NONE copyright,1.3,NONE dirs,1.1.1.1,NONE docs,1.2,NONE examples,1.2,NONE init.d,1.3,NONE nagios-mysql.install,1.4,NONE nagios-pgsql.install,1.4,NONE postinst,1.4,NONE postrm,1.2,NONE preinst,1.1.1.1,NONE prerm,1.1.1.1,NONE

joerg@haydn.debian.org joerg@haydn.debian.org


Update of /cvsroot/pkg-nagios/nagios
In directory haydn:/tmp/cvs-serv21054

Modified Files:
	BUGS.Debian changelog control nagios-common.dirs 
	nagios-common.install rules 
Added Files:
	nagios-common.config nagios-common.copyright 
	nagios-common.docs nagios-common.examples nagios-common.init.d 
	nagios-common.postinst nagios-common.postrm 
	nagios-common.preinst 
Removed Files:
	config copyright dirs docs examples init.d 
	nagios-mysql.install nagios-pgsql.install postinst postrm 
	preinst prerm 
Log Message:
Splitted. Works for me (package build, install to be tested tomorrow).
the 3 "old" packages now all depend on -common, which has all files that
are similar for all nagios packages, the variants only include the thing they
need different. They even dont have a doc directory, its a symlink to the one from
-common.
That split makes the debian/rules readable now, only a few things left that are ugly.
If you have some time and a machine to kill, please test it, build and installation.
And of course: upgrades from previous version.


--- NEW FILE: nagios-common.config ---
#!/bin/sh -e
   
# Source debconf library.
. /usr/share/debconf/confmodule
   
# Configure apache?
db_subst "nagios/configapache" "webserver" "Apache" || true
db_input medium "nagios/configapache" || true
db_go

# Check their answer.
db_get nagios/configapache
if [ "$RET" != "None" ]; then
	db_input high nagios/adminpassword || true
	db_input medium nagios/wwwsuid || true
        db_go
else
	true
fi

# If the Netsaint configuration exists, warn...
if [ -f /etc/netsaint/netsaint.cfg ]; then
	db_input medium nagios/upgradefromnetsaint || true
	db_go
fi

--- NEW FILE: nagios-common.copyright ---
This package was debianized by Turbo Fredriksson <turbo@debian.org>
on Thu, 20 Jun 2002 08:28:44 +0200.

It was downloaded from http://www.nagios.org/

Upstream Author: Ethan Galstad <nagios@nagios.org>

Current Debian Maintainers: Joerg Jaspert <joerg@debian.org>
			   				Jeremy T. Bouse <jbouse@debian.org>
							Tony Mancill <tony@mancill.com>
							Sean Finney <seanius@seanius.net>
							Guido Trotter <ultrotter@quaqua.net>
Mailing-List: 				pkg-nagios-devel@lists.alioth.debian.org

Copyright:

Nagios is released under the terms of the GPL license.
See /usr/share/common-licenses/GPL for the full license.

--- NEW FILE: nagios-common.docs ---
README
UPGRADING
debian/README.mysql
contrib/database/create_mysql
contrib/database/create_pgsql

--- NEW FILE: nagios-common.examples ---
sample-config/nagios.cfg
sample-config/resource.cfg
sample-config/template-object/hosts.cfg

--- NEW FILE: nagios-common.init.d ---
#! /bin/sh
#
# skeleton	example file to build /etc/init.d/ scripts.
#		This file should be used to construct scripts for /etc/init.d.
#
#		Written by Miquel van Smoorenburg <miquels@cistron.nl>.
#		Modified for Debian GNU/Linux
#		by Ian Murdock <imurdock@gnu.ai.mit.edu>.
#
# Version:	@(#)skeleton  1.8  03-Mar-1998  miquels@cistron.nl
#
# This file was automatically customized by dh-make on Mon, 17 Jan 2000 19:30:36 +0000
# Hacked into netsaint shape by bjb.

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/sbin/nagios
NAME=nagios
DESC=nagios
NICENESS=5
NAMEDPIPE=/var/run/nagios/nagios.cmd
PIDFILE=/var/run/nagios/nagios.pid
CONFIG=/etc/nagios/nagios.cfg

test -f $DAEMON || exit 0

set -e

#
# Is this function useful at all?
# start-stop-daemon should handle this work!
#
check_started () {
    if [ -f /usr/lib/nagios/plugins/check_nagios ]; then
	if /usr/lib/nagios/plugins/check_nagios -F /var/cache/nagios/status.log -e 5 -C 'nagios' > /dev/null; then
	    return 0    # Is started
	else
	    return 1    # Isn't started
	fi
    elif [ -f /usr/lib/netsaint/plugins/check_netsaint ]; then
	if /usr/lib/netsaint/plugins/check_netsaint -F /var/cache/nagios/status.log -e 5 -C 'nagios' > /dev/null; then
	    return 0    # Is started
	else
	    return 1    # Isn't started
	fi
    elif [ -f $PIDFILE ]; then
    	# Try discovering if nagios is alive checking its pid
	if kill -CHLD $( cat $PIDFILE ) ; then
	    return 1    # Isn't started
	else
	    return 0    # Is started
	fi
    else
    	return 1	# Isn't started
    fi
}

get_config () {
    set -- `grep ^$1 $CONFIG | sed 's@=@ @'`
    echo $2
}

check_config () {
    if $DAEMON -v $CONFIG >/dev/null 2>&1 ; then
	# First get the user/group etc Nagios is running as
	nagios_user=`get_config nagios_user`
	nagios_group=`get_config nagios_group`
	log_file=`get_config log_file`
	log_dir=`dirname $log_file`

	# Chown the log directory to this user/group so that
	# Nagios can write there.
	chown -R $nagios_user.$nagios_group $log_dir

	return 0    # Config is ok
    else
    	# config is not okay, so let's barf the error to the user
        $DAEMON -v $CONFIG
	return 1    # Config not ok
    fi
}

check_named_pipe () {
    if [ -p $NAMEDPIPE ]; then
	return 1   # a named pipe exists
    else
	return 0   # no named pipe exists
    fi
}

case "$1" in
  start)
	echo -n "Starting $DESC: "
	if ! check_started; then
	    if ! check_named_pipe; then
		echo "named pipe exists - removing"
		rm -f $NAMEDPIPE
	    fi

	    if check_config; then
		rm -f $NAMEDPIPE		
		nice -$NICENESS \
		    start-stop-daemon --start --quiet \
		    --pidfile $PIDFILE \
		    --make-pidfile --background --exec $DAEMON -- $CONFIG
		echo "$NAME."
	    else
		echo "errors in config!"
	    fi
	else
	    echo "already running"
	fi
	;;
  stop)
	echo -n "Stopping $DESC: "
	start-stop-daemon --stop --quiet --pidfile $PIDFILE \
		--oknodo --exec $DAEMON
	echo "$NAME."
	rm -f $PIDFILE
	rm -f $NAMEDPIPE
	;;
  reload|force-reload)
	echo "Reloading $DESC configuration files."
	# Check first
	if check_config; then
	    if check_started; then
		start-stop-daemon --stop --signal 1 --quiet --pidfile \
		    $PIDFILE --exec $DAEMON
	    else
		echo "Not running."
	    fi
	else
	    echo "Errors in config file. Not reloading."
	fi
  	;;
  restart)
	echo -n "Restarting $DESC: "
	$0 stop
	sleep 2
	$0 start
	;;
  *)
	N=/etc/init.d/$NAME
	echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2
	exit 1
	;;
esac

exit 0

--- NEW FILE: nagios-common.postinst ---
#! /bin/sh
# postinst script for nagios
#
# see: dh_installdeb(1)

set -e

# Source debconf library.
. /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 /usr/doc/packaging-manual/
#
# quoting from the policy:
#     Any necessary prompting should almost always be confined to the
#     post-installation script, and should be protected with a conditional
#     so that unnecessary prompting doesn't happen if a package's
#     installation fails and the `postinst' is called with `abort-upgrade',
#     `abort-remove' or `abort-deconfigure'.

# Restart apache/apache-ssl
restartapache () {
	if [ -x "/etc/init.d/apache2" ]; then
		invoke-rc.d apache2 reload || true
	else
	    for apache in $webservers; do
		    if [ -x "/etc/init.d/$apache" ]; then
				invoke-rc.d $apache reload || true
		    fi
	    done
    fi
}

# Automatic Apache Configuration:
configapache () {
	removeoldapache
    for apache in $webservers; do
	if [ -d "/etc/$apache/conf.d" ]; then
		ln -s /etc/nagios/apache.conf /etc/$apache/conf.d/nagios
	fi
    done

    restartapache
}

# Remove old entries in httpd.conf
removeoldapache () {
    for apache in $webservers; do

	if [ "$apache" = "apache2" ]; then
	    conf=apache2.conf
	else
	    conf=httpd.conf
	fi

	if grep -qs "^Include /etc/nagios/apache.conf" /etc/$webserver/$conf; then
		mv -f /etc/$webserver/$conf /etc/$webserver/$conf.old.nagios
		grep -v "^Include /etc/nagios/apache.conf" /etc/$webserver/$conf.old.nagios \
			> /etc/$webserver/$conf
	fi
	if ! grep -qs "^Include /etc/$webserver/conf.d" /etc/$webserver/$conf; then
		cp -f /etc/$webserver/$conf /etc/$webserver/$conf.old.nagios
		echo "Include /etc/$webserver/conf.d" >> /etc/$webserver/$conf
		mkdir -p /etc/$webserver/$conf
	fi
	if [ -f /etc/$webserver/$conf.old.nagios ]; then
		mv -f /etc/$webserver/$conf.old.nagios /etc/$webserver/$conf.old
	fi
    done
}

# Do postinst
case "$1" in
    configure|upgrade)

    # Apache/Apache-SSL location. Apache2 is overwritten below
	htpasswd="/usr/bin/htpasswd"

	db_get nagios/configapache
	webserver="$RET"
	case "$webserver" in
	    Apache)        webservers="apache";;
	    Apache2)       webservers="apache2" ; htpasswd="/usr/bin/htpasswd2";;
	    Apache-SSL)    webservers="apache-ssl";;
	    Both)          webservers="apache apache-ssl";;
	    *)             webservers="";;
	esac

	if [ -e "/usr/bin/htpasswd-caudium" ]; then
	    htpasswd="/usr/bin/htpasswd-caudium"
	fi

	if [ ! -z "$webservers" ]; then
		configapache
	fi

	if [ -e "$htpasswd" ]; then
	    db_get nagios/adminpassword
	    if [ -z "$RET" ]; then
		echo "Not setting blank password for nagiosadmin"
	    elif [ ! -f /etc/nagios/htpasswd.users ] ; then
		# The passwd file don't exists
		$htpasswd -c -b /etc/nagios/htpasswd.users nagiosadmin "$RET"
	    elif ! cat /etc/nagios/htpasswd.users | grep -q ^nagiosadmin; then
		# File exists, but there's no nagiosadmin in there!?
		$htpasswd -b /etc/nagios/htpasswd.users nagiosadmin "$RET"
	    else
		echo "Nagiosadmin already existing with password. To change the"
		echo "password, please use the $htpasswd command."
	    fi
	else
	    echo "There is no htpasswd command, so I can't create the password file"
	    echo "for you. You will have to figure out a way to create a .htpasswd"
	    echo "file yourself. When you do, it should be called:"
	    echo "	/etc/nagios/htpasswd.users"
	    echo "and be mode 0640, owned by root, group www-data."
	    echo "	chown root.www-data /etc/nagios/htpasswd.users"
	    echo "	chmod 0640 /etc/nagios/htpasswd.users"
	fi

	db_get nagios/wwwsuid
	if [ "$RET" = "true" ] ; then
		chown nagios /usr/lib/cgi-bin/nagios/*cgi
		chmod u+s /usr/lib/cgi-bin/nagios/*cgi
		perl -wpi -e 's[^check_external_commands=0][check_external_commands=1]' /etc/nagios/nagios.cfg
	else
		chmod u-s /usr/lib/cgi-bin/nagios/*cgi
		perl -wpi -e 's[^check_external_commands=1][check_external_commands=0]' /etc/nagios/nagios.cfg
	fi

	# We are finished with debconf
	db_stop

	if [ -f /etc/nagios/htpasswd.users ]; then
	    # Make sure some files aren't world readable, may contain sensitive information
	    chmod 640 /etc/nagios/htpasswd.users /etc/nagios/cgi.cfg /etc/nagios/resource.cfg
	    chgrp www-data /etc/nagios/htpasswd.users
	fi

        UDIR=/usr/share/nagios ; EDIR=/etc/nagios

	## Conf files have moved:
        for f in `find $UDIR/robots.txt $UDIR/*html 2> /dev/null`; do
		if [ -f $f -a ! -L $f ] ; then
                	mv -f $f /etc/nagios/
		fi
        done

	## Sym links for conf files:
        for f in `find $EDIR/robots.txt $EDIR/*html 2> /dev/null`; do
		if [ ! -e /usr/share/nagios/htdocs/`basename $f` ] ; then
                	ln -s $f /usr/share/nagios/htdocs/
		fi
        done

	for s in `find $UDIR/index.html $UDIR/main.html $UDIR/side.html $UDIR/robots.txt 2> /dev/null`; do
	    if [ ! -h $s ] ; then
		rm -f $s
	    fi
	done
	
	;;
    abort-upgrade|abort-remove|abort-deconfigure)
	;;
    *)
        echo "postinst called with unknown argument \`$1'" >&2
        exit 0
	;;
esac

# Setup the address to the default gateway
if [ ! -f /etc/nagios/hosts.cfg ]; then
    set -- `route -n | grep '^0.0.0.0' | head -n1`
    DEFAULTGW=$2

    TMPFILE=`tempfile -p nag.`
    zcat /usr/share/doc/nagios-*/examples/hosts.cfg.gz | sed "s/@DEFAULT_GW@/$DEFAULTGW/" > $TMPFILE
    mv $TMPFILE /etc/nagios/hosts.cfg
fi

if [ ! -L /usr/lib/nagios/plugins/check_nagios -a \
     ! -f /usr/lib/nagios/plugins/check_nagios -a \
       -e /usr/lib/nagios/plugins/check_netsaint ]
then
    (cd /usr/lib/nagios/plugins ; \
     ln -s /usr/lib/nagios/plugins/check_netsaint check_nagios)
fi

# Make sure the config file is readable by both nagios
# and apache
chown -R nagios.www-data /var/log/nagios /etc/nagios /var/run/nagios /var/cache/nagios
chmod 750 /etc/nagios/cgi.cfg

#DEBHELPER#

--- NEW FILE: nagios-common.postrm ---
#!/bin/sh
# postrm script for nagios
#
# see: dh_installdeb(1)

set -e

# Source debconf library.
. /usr/share/debconf/confmodule

# 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' <r>overwrit>r> <new-version>
# for details, see /usr/doc/packaging-manual/

reloadapache () {
	if [ -x "/etc/init.d/apache2" ]; then
		invoke-rc.d apache2 reload || true
	else
	    for apache in $webservers; do
		    if [ -x "/etc/init.d/$apache" ]; then
				invoke-rc.d $apache reload || true
		    fi
	    done
    fi
}

case "$1" in
    purge|remove|abort-install|abort-upgrade|failed-upgrade|disappear)
	if [ "$1" = "purge" ]; then
	    db_purge
	    # Remove logfiles
	    rm -Rf /var/log/nagios /etc/nagios /usr/lib/nagios/plugins/check_nagios
	else
	    # Remove apache config if wanted.
	    db_get nagios/configapache
	    webserver="$RET"
	    case "$webserver" in
		Apache)        webservers="apache";;
		Apache2)       webservers="apache2";;
		Apache-SSL)    webservers="apache-ssl";;
		Both)          webservers="apache apache-ssl";;
		*)             webservers="";;
	    esac

		db_stop

	    for apache in $webservers; do
			rm /etc/$apache/conf.d/nagios
		done
	    
	    if [ ! -z "$webservers" ]; then
			reloadapache
	    fi
	fi
        ;;
    upgrade)
	;;
    *)
        echo "postrm called with unknown argument \`$1'" >&2
        exit 0
esac

# In case it has something to add:
#DEBHELPER#



--- NEW FILE: nagios-common.preinst ---
#! /bin/sh
# preinst script for nagios
#
# see: dh_installdeb(1)

set -e

# summary of how this script can be called:
#        * <new-preinst> `install'
#        * <new-preinst> `install' <old-version>
#        * <new-preinst> `upgrade' <old-version>
#        * <old-preinst> `abort-upgrade' <new-version>

case "$1" in
    install|upgrade)
	if id nagios >/dev/null 2>&1 ; then
		# We have a nagios user.
		if [ `id nagios -g -n` != "nagios" ] ; then
			addgroup --system nagios || true 
			usermod -g nagios nagios
		fi
	else
		adduser --system --disabled-password --group --no-create-home --home /var/log/nagios --quiet nagios
	fi

	;;
    abort-upgrade)
	;;
    *)
        echo "preinst called with unknown argument \`$1'" >&2
        exit 0
	;;
esac


exit 0

Index: BUGS.Debian
===================================================================
RCS file: /cvsroot/pkg-nagios/nagios/BUGS.Debian,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- BUGS.Debian	31 Oct 2004 09:59:28 -0000	1.1.1.1
+++ BUGS.Debian	9 Nov 2004 23:30:07 -0000	1.2
@@ -1,10 +1,4 @@
 Bugs left to close
 ~~~~~~~~~~~~~~~~~~
-#177847: Nothing is logged to nagios.log except starting messages
-#192508: services.cfg advertise check_ping!100.0,20%!500.0,60% but check_ping does not take args
 #186505: Inconsistent command_name naming in /etc/nagios/checkcommands.cfg
 #211169: Can't detect process status
-
-Wishlist/Won't fix
-~~~~~~~~~~~~~~~~~~
-#196802: Build system that sucks hairy freeking mammoths

Index: changelog
===================================================================
RCS file: /cvsroot/pkg-nagios/nagios/changelog,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- changelog	7 Nov 2004 23:18:46 -0000	1.8
+++ changelog	9 Nov 2004 23:30:07 -0000	1.9
@@ -27,6 +27,8 @@
       this new package and let all 3 depend on it. Move most of the Package
       dependencies to the -common package. Let all 3 packages depend on the new
       -common one, and let the common one depend on our Virtual Package "nagios".
+      Also the -common conflicts with the nagios-package <= 2:1.2-3.6.
+      This fixes: "nagios-text removes /etc/nagios on purge" (Closes: #275596).
     - Remove ucf dependency, wasnt used.
     - Remove debconf warnings for upgrades from versions years ago noone has anymore.
     - Revised postinst script, dont modify apaches config directly, put a symlink in
@@ -42,7 +44,7 @@
     - adduser and debconf are now normal dependencies
     - added fix in init script for non-existant pidfile
 
- -- Joerg Jaspert <joerg@debian.org>  Wed,  3 Nov 2004 23:44:14 +0100
+ -- Joerg Jaspert <joerg@debian.org>  Wed, 10 Nov 2004 00:20:33 +0100
 
 nagios (2:1.2-3.6) unstable; urgency=high
 

Index: control
===================================================================
RCS file: /cvsroot/pkg-nagios/nagios/control,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- control	7 Nov 2004 23:18:46 -0000	1.5
+++ control	9 Nov 2004 23:30:07 -0000	1.6
@@ -8,7 +8,9 @@
 
 Package: nagios-common
 Architecture: all
-Depends: nagios, ${shlibs:Depends}, fileutils (>=4.0y) | coreutils (>= 4.5.3), apache | httpd, mailx, nagios-plugins (>= 1.3.1.0-6), adduser, debconf
+Depends: nagios, fileutils (>=4.0y) | coreutils (>= 4.5.3), apache | httpd, mailx, nagios-plugins (>= 1.3.1.0-6), adduser, debconf
+Conflicts: nagios-text (<= 2:1.2-3.6), nagios-mysql (<= 2:1.2-3.6), nagios-pgsql (<= 2:1.2-3.6)
+Replaces: netsaint, nagios
 Description: A host/service/network monitoring and management system
  Nagios is a replacement of the Netsaint project. It accept and uses the
  previous Netsaint modules transparently.

Index: nagios-common.dirs
===================================================================
RCS file: /cvsroot/pkg-nagios/nagios/nagios-common.dirs,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- nagios-common.dirs	7 Nov 2004 23:18:46 -0000	1.1
+++ nagios-common.dirs	9 Nov 2004 23:30:07 -0000	1.2
@@ -2,9 +2,14 @@
 etc/nagios/stylesheets
 usr/sbin
 usr/lib/nagios/plugins/eventhandlers
-usr/share/nagios/htdocs
 usr/share/nagios/pluginconfig
 var/log/nagios
 var/run/nagios
 var/lib/nagios
 var/cache/nagios
+usr/share/nagios/htdocs/media
+usr/share/nagios/htdocs/stylesheets
+usr/share/nagios/htdocs/contexthelp
+usr/share/nagios/htdocs/docs/images
+usr/share/nagios/htdocs/images/logos
+usr/share/nagios/htdocs/ssi

Index: nagios-common.install
===================================================================
RCS file: /cvsroot/pkg-nagios/nagios/nagios-common.install,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- nagios-common.install	7 Nov 2004 23:18:46 -0000	1.1
+++ nagios-common.install	9 Nov 2004 23:30:07 -0000	1.2
@@ -1,4 +1,16 @@
 contrib/eventhandlers/* usr/lib/nagios/plugins/eventhandlers
+contrib/traceroute.cgi usr/lib/cgi-bin/nagios/
+html/docs/robots.txt usr/share/nagios/htdocs/docs
+html/*.html usr/share/nagios/htdocs
+html/media/*.wav usr/share/nagios/htdocs/media
+html/stylesheets/*.css etc/nagios/stylesheets
+html/contexthelp/*.html usr/share/nagios/htdocs/contexthelp
+html/docs/*.html usr/share/nagios/htdocs/docs
+html/docs/images/* usr/share/nagios/htdocs/docs/images
+html/images/*.gif html/images/*.jpg html/images/*.png usr/share/nagios/htdocs/images
+html/images/logos/*.* usr/share/nagios/htdocs/images/logos
+sample-config/resource.cfg etc/nagios/
+sample-config/template-object/*.cfg etc/nagios/
 debian/apache.conf etc/nagios/
 debian/update-nagios usr/sbin/
 debian/upgrade-netsaint2nagios usr/sbin/

Index: rules
===================================================================
RCS file: /cvsroot/pkg-nagios/nagios/rules,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- rules	3 Nov 2004 22:58:11 -0000	1.7
+++ rules	9 Nov 2004 23:30:08 -0000	1.8
@@ -57,7 +57,6 @@
 	-rm -Rf {cgi,base}/*.mysql {cgi,base}/*.pgsql {cgi,base}/*.text
 	-rm {patch,patch-no-defaults,install,configure,build}-stamp
 	-rm debian/templates.merged subst
-	-rm debian/nagios-{text,mysql,pgsql}.nagios.init
 
 	dh_clean
 
@@ -127,14 +126,6 @@
 	  done);
 	touch binary-nagios-mysql-stamp
 
-binary-indep: 
-# install the same initscript in each package dir
-	for pkg in text pgsql mysql; do \
-		cp debian/init.d debian/nagios-$$pkg.nagios.init; \
-	done    
-	dh_installinit -a --name nagios
-
-
 build: build-stamp
 build-stamp: patch binary-nagios-text binary-nagios-pgsql binary-nagios-mysql
 	@echo "--- Compiling"
@@ -142,154 +133,135 @@
 	po2debconf debian/templates > debian/templates.merged
 	touch build-stamp
 
-binary-arch: build install nagios-text nagios-mysql nagios-pgsql
+binary-arch: build nagios-text nagios-mysql nagios-pgsql
 	dh_testdir -a
 	dh_testroot -a
 
+binary-indep: nagios-common
 
-nagios-text: install
+nagios-text:
 	@echo "--- Building: $@"
 	dh_installdirs 		 -p$@ -P$(b)/$@ 
-	dh_link              -p$@ -P$(b)/$@ 
-	dh_installdocs       -p$@ -P$(b)/$@
-	dh_installchangelogs -p$@ -P$(b)/$@ Changelog
-	dh_install			 -p$@ -P$(b)/$@
-	chmod +x $(maindir)/debian/nagios-text/usr/lib/nagios/plugins/check-imap;
+	/usr/bin/install -m 774 base/nagios.text debian/$@/usr/sbin/nagios
+	/usr/bin/install -m 755 base/nagios.text debian/$@/usr/lib/cgi-bin/nagios/nagios
+	for bin in $(CGIBINS); do \
+		/usr/bin/install -m 755 cgi/$$bin.cgi.text debian/$@/usr/lib/cgi-bin/nagios/$$bin.cgi; \
+	done;
+
+	dh_link              -p$@ -P$(b)/$@ usr/share/doc/nagios-common usr/share/doc/nagios-text
 	dh_strip             -p$@ -P$(b)/$@
-	dh_installexamples   -p$@ -P$(b)/$@
 	dh_compress          -p$@ -P$(b)/$@
 	dh_fixperms          -p$@ -P$(b)/$@
 	dh_installdeb        -p$@ -P$(b)/$@
 	dh_shlibdeps         -p$@ -P$(b)/$@
-	dh_installdebconf    -p$@ -P$(b)/$@
 	dh_gencontrol        -p$@ -P$(b)/$@
 	dh_makeshlibs        -p$@ -P$(b)/$@ -V
 	dh_md5sums           -p$@ -P$(b)/$@
 	dh_builddeb          -p$@ -P$(b)/$@
 
-nagios-mysql: install
+nagios-mysql:
 	@echo "--- Building: $@"
 	dh_installdirs 		 -p$@ -P$(b)/$@ 
-	dh_link              -p$@ -P$(b)/$@ 
-	dh_installdocs       -p$@ -P$(b)/$@
-	dh_installchangelogs -p$@ -P$(b)/$@ Changelog
-	dh_install			 -p$@ -P$(b)/$@
-	chmod +x $(maindir)/debian/nagios-mysql/usr/lib/nagios/plugins/check-imap;
+	/usr/bin/install -m 774 base/nagios.mysql debian/$@/usr/sbin/nagios
+	/usr/bin/install -m 755 base/nagios.mysql debian/$@/usr/lib/cgi-bin/nagios/nagios
+	for bin in $(CGIBINS); do \
+		/usr/bin/install -m 755 cgi/$$bin.cgi.mysql debian/$@/usr/lib/cgi-bin/nagios/$$bin.cgi; \
+	done;
+
+	dh_link              -p$@ -P$(b)/$@ usr/share/doc/nagios-common usr/share/doc/nagios-mysql
 	dh_strip             -p$@ -P$(b)/$@
-	dh_installexamples   -p$@ -P$(b)/$@
 	dh_compress          -p$@ -P$(b)/$@
 	dh_fixperms          -p$@ -P$(b)/$@
 	dh_installdeb        -p$@ -P$(b)/$@
 	dh_shlibdeps         -p$@ -P$(b)/$@
-	dh_installdebconf    -p$@ -P$(b)/$@
 	dh_gencontrol        -p$@ -P$(b)/$@
 	dh_makeshlibs        -p$@ -P$(b)/$@ -V
 	dh_md5sums           -p$@ -P$(b)/$@
 	dh_builddeb          -p$@ -P$(b)/$@
 
-nagios-pgsql: install
+nagios-pgsql:
 	@echo "--- Building: $@"
 	dh_installdirs 		 -p$@ -P$(b)/$@ 
-	dh_link              -p$@ -P$(b)/$@ 
-	dh_installdocs       -p$@ -P$(b)/$@
-	dh_installchangelogs -p$@ -P$(b)/$@ Changelog
-	dh_install			 -p$@ -P$(b)/$@
-	chmod +x $(maindir)/debian/nagios-pgsql/usr/lib/nagios/plugins/check-imap;
+	/usr/bin/install -m 774 base/nagios.pgsql debian/$@/usr/sbin/nagios
+	/usr/bin/install -m 755 base/nagios.pgsql debian/$@/usr/lib/cgi-bin/nagios/nagios
+	for bin in $(CGIBINS); do \
+		/usr/bin/install -m 755 cgi/$$bin.cgi.pgsql debian/$@/usr/lib/cgi-bin/nagios/$$bin.cgi; \
+	done;
+
+	dh_link              -p$@ -P$(b)/$@ usr/share/doc/nagios-common usr/share/doc/nagios-pgsql
 	dh_strip             -p$@ -P$(b)/$@
-	dh_installexamples   -p$@ -P$(b)/$@
 	dh_compress          -p$@ -P$(b)/$@
 	dh_fixperms          -p$@ -P$(b)/$@
 	dh_installdeb        -p$@ -P$(b)/$@
 	dh_shlibdeps         -p$@ -P$(b)/$@
-	dh_installdebconf    -p$@ -P$(b)/$@
 	dh_gencontrol        -p$@ -P$(b)/$@
 	dh_makeshlibs        -p$@ -P$(b)/$@ -V
 	dh_md5sums           -p$@ -P$(b)/$@
 	dh_builddeb          -p$@ -P$(b)/$@
 
+nagios-common:
+	@echo "--- Building: $@"
+	dh_installdirs 		 -p$@ -P$(b)/$@ 
+	dh_installdocs       -p$@ -P$(b)/$@
+	dh_installexamples   -p$@ -P$(b)/$@
+	dh_installchangelogs -p$@ -P$(b)/$@ Changelog
+	dh_installinit 		 -p$@ -P$(b)/$@ --name nagios
+	dh_install           -p$@ -P$(b)/$@
+# Remove checkcommands.cfg which is not to be shipped
+	rm -f $(maindir)/debian/$@/etc/nagios/checkcommands.cfg
+	chmod +x $(maindir)/debian/nagios-common/usr/lib/nagios/plugins/check-imap
+	chmod +x $(maindir)/debian/nagios-common/usr/lib/cgi-bin/nagios/traceroute.cgi
+	cat sample-config/nagios.cfg | \
+	sh $(maindir)/debian/scripts/addpluginseg | \
+	sed -e 's@command_file=/var/log/nagios/rw@command_file=/var/run/nagios@' \
+	    -e 's@temp_file=/var/log@temp_file=/var/cache@' \
+	    -e 's@state_retention_file=/var/log@state_retention_file=/var/cache@' \
+	    -e 's@status_file=/var/log@status_file=/var/cache@' \
+	    -e 's@^nagios_check_command@#nagios_check_command@' \
+	    > $(maindir)/debian/$@/etc/nagios/nagios.cfg.new;
+	cat sample-config/cgi.cfg | \
+	     sed -e "s@^#authorized_for_\(.*\)=.*@authorized_for_\1=nagiosadmin@" \
+	     > $(maindir)/debian/$@/etc/nagios/cgi.cfg.new;
+	cd $(maindir)/debian/$@/etc/nagios && \
+	mv nagios.cfg.new nagios.cfg && \
+	mv cgi.cfg.new cgi.cfg;
+	chmod 660 $(maindir)/debian/nagios-common/etc/nagios/resource.cfg
+
+	cd $(maindir)/debian/$@/usr/share/nagios/htdocs/docs/; \
+	for file in *.html; do \
+		echo -n "Modifying htdoc: $$file"; \
+		cat $$file | sed -e 's@/etc/rc.d/init.d/nagios@/etc/init.d/nagios@i' \
+						 -e 's@ etc/ @ /etc/nagios/ @i' \
+					  	 -e 's@/usr/local/nagios/etc@/etc/nagios@i' \
+					  	 -e 's@/usr/local/nagios/libexec@/usr/lib/nagios/plugins@i' \
+				  		 -e 's@/usr/local/nagios/bin@/usr/sbin@i' \
+				  		 -e 's@/usr/local/nagios/sbin@/usr/lib/cgi-bin/nagios@i' \
+				  		 -e 's@/usr/local/nagios/share@/usr/share/nagios/htdocs@i' \
+				  		 -e 's@/usr/local/nagios/share/ssi@/usr/share/nagios/htdocs/ssi@i' \
+				  		 -e 's@/usr/local/nagios/var@/var/log/nagios@i' \
+				  		 -e 's@/usr/local/nagios@/usr@i' \
+			      		> $$file.new && mv $$file.new $$file; \
+		echo; \
+	done;
+
+	dh_link              -p$@ -P$(b)/$@
+	dh_strip             -p$@ -P$(b)/$@
+	dh_compress          -p$@ -P$(b)/$@
+	dh_fixperms          -p$@ -P$(b)/$@ -Xnagios/resource.cfg -Xcheck-imap
+	dh_installdeb        -p$@ -P$(b)/$@
+	dh_installdebconf    -p$@ -P$(b)/$@
+	dh_shlibdeps         -p$@ -P$(b)/$@
+	dh_gencontrol        -p$@ -P$(b)/$@
+	dh_md5sums           -p$@ -P$(b)/$@
+	dh_builddeb          -p$@ -P$(b)/$@
+
 install: install-stamp
 install-stamp:
 	dh_testdir -a
 	dh_testroot -a
-	dh_installdirs -A
-
-# * Install files into each package.
-# * Move the hosts.cfg out of the way (into the examples dir)
-# * Update nagios.cfg with information about plugins-auto.cfg.
-# * Uncoment ^authorized_for_*' options in cgi.cfg.
-# * Setup paths in all htdocs files
-# FIXME: This one should be changed. Ideally the whole nagios thing would be changed
-# to complete automake and then use different build-trees. Or maybe build it 3 times and
-# just keep the debian/nagios-{package} dirs. Or something like this.
-	@( cd $(maindir)/base && cp nagios.text nagios; \
-	   cd $(maindir)/cgi && \
-	   for bin in $(CGIBINS); do \
-	     cp $$bin.cgi.text $$bin.cgi; \
-	   done; \
-	   for dir in text pgsql mysql; do \
-	     cd $(maindir)/; \
-	       set -e; $(MAKE) install install-config DESTDIR=$(maindir)/debian/nagios-$$dir \
-		 INSTALL_OPTS= COMMAND_OPTS= && echo $?; \
-	       install -m 755 base/nagios.$$dir $(maindir)/debian/nagios-$$dir/usr/lib/cgi-bin/nagios/nagios; \
-	       install -m 755 contrib/traceroute.cgi $(maindir)/debian/nagios-$$dir/usr/lib/cgi-bin/nagios/; \
-	       cat sample-config/nagios.cfg | \
-	         sh $(maindir)/debian/scripts/addpluginseg | \
-	         sed -e 's@command_file=/var/log/nagios/rw@command_file=/var/run/nagios@' \
-		     -e 's@temp_file=/var/log@temp_file=/var/cache@' \
-		     -e 's@state_retention_file=/var/log@state_retention_file=/var/cache@' \
-		     -e 's@status_file=/var/log@status_file=/var/cache@' \
-		     -e 's@^nagios_check_command@#nagios_check_command@' \
-		     > $(maindir)/debian/nagios-$$dir/etc/nagios/nagios.cfg.new; \
-	       cat sample-config/cgi.cfg | \
-	         sed -e "s@^#authorized_for_\(.*\)=.*@authorized_for_\1=nagiosadmin@" \
-		     > $(maindir)/debian/nagios-$$dir/etc/nagios/cgi.cfg.new; \
-	     cd $(maindir)/debian/nagios-$$dir/etc/nagios; \
-	       for file in `find . -name '*-sample'`; do \
-	         new=`echo $$file | sed 's@-sample@@'`; \
-		 	 mv $$file $$new; \
-	       done; \
-	       mv nagios.cfg.new nagios.cfg; \
-	       mv cgi.cfg.new cgi.cfg; \
-	       mkdir -p ../../usr/share/doc/nagios-$$dir/examples; \
-	       mv hosts.cfg ../../usr/share/doc/nagios-$$dir/examples/hosts.cfg; \
-	     if [ ! -d "$(maindir)/debian/nagios-$$dir/etc/nagios/stylesheets" ]; then \
-	       cd $(maindir)/debian/nagios-$$dir/usr/share/nagios/htdocs/; \
-	         mv stylesheets ../../../../etc/nagios/; \
-	     else \
-	       cd $(maindir)/debian/nagios-$$dir/usr/share/nagios/htdocs/stylesheets; \
-	         mv * ../../../../../etc/nagios/stylesheets/; \
-	     fi; \
-	     cd $(maindir)/debian/nagios-$$dir/usr/share/nagios/htdocs/docs/; \
-	       for file in *.html; do \
-		 echo -n "Modifying htdoc: $$file"; \
-		 cat $$file | sed -e 's@/etc/rc.d/init.d/nagios@/etc/init.d/nagios@i' \
-				  -e 's@ etc/ @ /etc/nagios/ @i' \
-				  -e 's@/usr/local/nagios/etc@/etc/nagios@i' \
-				  -e 's@/usr/local/nagios/libexec@/usr/lib/nagios/plugins@i' \
-				  -e 's@/usr/local/nagios/bin@/usr/sbin@i' \
-				  -e 's@/usr/local/nagios/sbin@/usr/lib/cgi-bin/nagios@i' \
-				  -e 's@/usr/local/nagios/share@/usr/share/nagios/htdocs@i' \
-				  -e 's@/usr/local/nagios/share/ssi@/usr/share/nagios/htdocs/ssi@i' \
-				  -e 's@/usr/local/nagios/var@/var/log/nagios@i' \
-				  -e 's@/usr/local/nagios@/usr@i' \
-			      > $$file.new && mv $$file.new $$file; \
-		 echo; \
-	       done; \
-	     echo install -m 755 $(maindir)/base/nagios.$$dir $(maindir)/debian/nagios-$$dir/usr/sbin/nagios; \
-	     install -m 755 $(maindir)/base/nagios.$$dir $(maindir)/debian/nagios-$$dir/usr/sbin/nagios; \
-	     for bin in $(CGIBINS); do \
-	       echo install -m 755 $(maindir)/cgi/$$bin.cgi.$$dir \
-		 $(maindir)/debian/nagios-$$dir/usr/lib/cgi-bin/nagios/$$bin.cgi; \
-	       install -m 755 $(maindir)/cgi/$$bin.cgi.$$dir \
-		 $(maindir)/debian/nagios-$$dir/usr/lib/cgi-bin/nagios/$$bin.cgi; \
-	     done; \
-	   done; \
-	)
-# Remove checkcommands.cfg which is not to be shipped
-	rm -f $(maindir)/debian/nagios-text/etc/nagios/checkcommands.cfg
-	rm -f $(maindir)/debian/nagios-mysql/etc/nagios/checkcommands.cfg
-	rm -f $(maindir)/debian/nagios-pgsql/etc/nagios/checkcommands.cfg
-
+# Wah, lets simply do the install bit ourself - its not much magic and makes our live with the
+# splitted packages easier. And we already redo most of the stuff from upstreams makefile to
+# seperate it for the splits...
 	touch $(maindir)/install-stamp
 
 debian/po/templates.pot: debian/templates
@@ -305,5 +277,5 @@
 	dpatch --with-cpp deapply-all
 	rm -rf patch-stamp debian/patched
 
-binary: binary-indep binary-arch
+binary: binary-arch binary-indep
 .PHONY: binary-indep binary-arch binary-nagios-text binary-nagios-pgsql binary-nagios-mysql binary install patch unpatch

--- config DELETED ---

--- copyright DELETED ---

--- dirs DELETED ---

--- docs DELETED ---

--- examples DELETED ---

--- init.d DELETED ---

--- nagios-mysql.install DELETED ---

--- nagios-pgsql.install DELETED ---

--- postinst DELETED ---

--- postrm DELETED ---

--- preinst DELETED ---

--- prerm DELETED ---