SliTaz Packages

Community Doc Forum Pro Shop Bugs Hg
.

Receipt for package "nagios"

# SliTaz package receipt.

PACKAGE="nagios"
VERSION="4.4.7"
CATEGORY="network"
SHORT_DESC="Host and network monitoring."
MAINTAINER="erjo@slitaz.org"
LICENSE="GPL2"
WEB_SITE="https://www.nagios.org/"

TARBALL="$PACKAGE-$VERSION.tar.gz"
WGET_URL="$SF_MIRROR/$PACKAGE/$TARBALL"

SUGGESTED="nagios-nrpe"
DEPENDS="apache libjpeg libltdl libpng nagios-plugins"
BUILD_DEPENDS="jpeg-dev libgd-dev libpng-dev libtool openssl-dev procps unzip"
# busybox ps and unzip do not supply the required options

# What is the latest version available today?
current_version()
{
    wget -O - https://sourceforge.net/projects/nagios/files/ 2>/dev/null | \
    sed '/scope="row/!d;/nagios-/!d;s|.*href="|"https://sourceforge.net|;q' | xargs wget -O - 2>/dev/null | \
    sed '/scope="row/!d;s|.*href="|"https://sourceforge.net|;q' | xargs wget -O - 2>/dev/null | \
    sed '/scope="row/!d;s|.*/nagios-||;s|.tar.*||;q'
}

# Rules to configure and make the package.
compile_rules()
{
    while read patch_file
      do
        if [ ! -f done.$patch_file ]
          then
            patch -p1 < $stuff/$patch_file || return 1
            touch done.$patch_file
        fi
      done <<EOT
$PACKAGE-Makefiles.u
EOT

    ./configure                            \
        --prefix=/usr                        \
        --infodir=/usr/share/info                \
        --mandir=/usr/share/man                    \
        --with-nagios-user=nagios                \
        --with-nagios-group=nagios                \
        --with-lockfile=/var/run/nagios/nagios.pid        \
        --with-checkresult-dir=/var/spool/nagios/checkresults    \
        --sysconfdir=/etc/nagios                \
        --with-httpd-conf=/etc/apache/conf.d            \
        --libexecdir=/usr/lib/nagios/plugins            \
        --sbindir=/usr/lib/nagios/cgi                \
        --datadir=/usr/share/nagios                \
        --localstatedir=/var/lib/nagios                \
        $CONFIGURE_ARGS 

    # 4.4.7 not required
#    sed -i s!HTMLDIR=.*!HTMLDIR=/usr/share/nagios! html/Makefile
    
    #~ make all && make DESTDIR=$DESTDIR fullinstall \
    #~ && make DESTDIR=$DESTDIR install-config
    make all &&
    make install &&
    make install-config &&
    make install-commandmode &&
    make install-webconf &&
    make install-classicui
}

# Rules to gen a SliTaz package suitable for Tazpkg.
genpkg_rules()
{
    mkdir -p $fs/etc/apache
    mkdir -p $fs/etc/init.d
    mkdir -p $fs/usr
    mkdir -p $fs/var/lib/nagios/rw
    mkdir -p $fs/var/log/nagios
    mkdir -p $fs/var/spool/nagios/checkresults

    cp -a $install/etc/apache    $fs/etc
    cp -a $install/etc/nagios    $fs/etc
    cp -a $stuff/nagios        $fs/etc/init.d
    install -o root -g root -m 644 $stuff/htpasswd.users \
                    $fs/etc/nagios/
    
    cp -a $install/usr/bin        $fs/usr
    cp -a $install/usr/lib        $fs/usr
    cp -a $install/usr/share    $fs/usr
    
    # Put documentation in a separate package
    rm -rf                $fs/usr/share/nagios/docs
    
    # Mofify Apache configuration for nagvis
    sed -i 's/Options None/Options FollowSymLinks/' \
        $fs/etc/apache/conf.d/nagios.conf

    # Fix permissions 
    chmod 755            $fs/usr/bin/nagios*
}

post_install()
{
    if ! grep -q nagios "$1/etc/passwd"
      then
        echo -n "Adding user and group nagios..."
        chroot "$1/" addgroup -S nagios
        chroot "$1/" adduser -S -D -H -G nagios nagios
        status
    fi
    
    # Fix permissions for files and directories
    chroot "$1/" chown -R    nagios.nagios        \
                /var/log/nagios        \
                /var/spool/nagios    \
                /var/lib/nagios        \
                /usr/share/nagios    \
                /etc/nagios/*
    
    chmod 2775 "$1/var/lib/nagios/rw"
    chroot "$1/" addgroup www nagios
    
    # Start Nagios daemon if we are  on running system
    [ "$1" ] || /etc/init.d/nagios start
    
    # post_install messges
    echo -e "\nTo start $PACKAGE server you can run :\n"
    echo "/etc/init.d/$PACKAGE start"
    echo -e "Or add $PACKAGE to RUN_DAEMONS in /etc/rcS.conf\n"
    echo -e "Default user and password for the Web GUI is nagiosadmin and nagios"
}

pre_remove()
{
    [ "$1" ] || /etc/init.d/nagios stop
}
6025 packages and 203154 files in current database (Thu Apr 25 06:17:47 2024)