SliTaz Packages

Community Doc Forum Pro Shop Bugs Hg
.

Receipt for package "ndoutils"

# SliTaz package receipt.

PACKAGE="ndoutils"
VERSION="2.1.3"
CATEGORY="network"
SHORT_DESC="Provide mysql access to nagios."
MAINTAINER="pascal.bellard@slitaz.org"
LICENSE="GPL2"
WEB_SITE="https://www.nagios.org/"

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

DEPENDS="mysql nagios"
BUILD_DEPENDS="mysql-dev procps"

CONFIG_FILES="/etc/nagios"

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

# Rules to configure and make the package.
compile_rules()
{
    patch --input=$stuff/patches/Makefile.in-$VERSION \
        Makefile.in || exit 1
    patch --input=$stuff/patches/src_Makefile.in-$VERSION \
        src/Makefile.in || exit 1

    addgroup nagios
    adduser -D -G nagios nagios

    ./configure                \
        --prefix=/usr            \
        --with-ndo2db-user=nagios    \
        --with-ndo2db-group=nagios    \
        --localstatedir=/var/run/nagios    \
        --sysconfdir=/etc/nagios    \
        --libexecdir=/usr/lib/$PACKAGE    \
        --mandir=/usr/share/man        \
        $CONFIGURE_ARGS &&
    make all &&
    make DESTDIR=$DESTDIR install &&
    make DESTDIR=$DESTDIR install-config
}    

# Rules to gen a SliTaz package suitable for Tazpkg.
genpkg_rules()
{
    mkdir -p $fs/usr/lib
    mkdir -p $fs/usr/share/nagios/ndoutils
    mkdir -p $fs/etc/nagios
    mkdir -p $fs/etc/mysql.d

    cp -a $install/usr/bin    $fs/usr
    cp -a $install/ndomod.o    $fs/usr/lib
    cp -a $install/etc    $fs
    
    # configuration file ndo2db.cfg
    sed -i  -e 's/ndo2db_user=nagios/ndo2db_user=nagios/' \
        -e 's/ndo2db_group=nagios/ndo2db_group=nagios/' \
        -e 's|/usr/local/nagios/var/|/var/run/nagios/|' \
        -e 's/db_user=ndouser/db_user=root/' \
        -e 's/db_pass=ndopassword/db_pass=/' \
        $fs/etc/nagios/ndo2db.cfg

    # configuration file ndomod.cfg
    sed -i  -e 's|output=/usr/local/nagios/var/|output=/var/run/nagios/|' \
        -e 's|buffer_file=/usr/local/nagios/var/|buffer_file=/var/tmp/|' \
        $fs/etc/nagios/ndomod.cfg

    cp -a  $src/db/mysql.sql \
                $fs/usr/share/nagios/ndoutils/nagios.sql
    cp -a stuff/etc        $fs
    
    chmod 755        $fs/usr/bin/*
    chmod 755        $fs/etc/mysql.d/*
}

post_install()
{
    if ! grep -q nagios "$1/etc/passwd"
      then
        echo
        echo -n "Adding user nagios..."
        chroot "$1/" adduser -S -D -H nagios
        status
    fi
        
    if ! grep -q ndomod.cfg "$1/etc/nagios/nagios.cfg"
      then
        sed -i '/LOG ROTATION METHOD/i\broker_module=/usr/lib/ndoutils/ndomod.o config_file=/etc/nagios/ndomod.cfg' "$1/etc/nagios/nagios.cfg"
        chroot "$1/" chown nagios.nagios /etc/nagios/nagios.cfg
    fi
    
    chroot "$1/" chown nagios.nagios /usr/lib/ndoutils/ndomod.o \
     /etc/nagios/ndo2db.cfg /etc/nagios/ndomod.cfg \
     /etc/nagios

    sed -i "s/nagios/ndo2db nagios/" "$1/etc/rcS.conf"
    
    if [ -z "$1" ]
      then    
        [ -f /var/run/mysqld/mysql.pid ] || /etc/init.d/mysql start
        /etc/mysql.d/$PACKAGE    
        #/usr/bin/ndo2db -c /etc/nagios/ndo2db.cfg
        /etc/init.d/ndo2db start
        /etc/init.d/nagios stop
        /etc/init.d/nagios start

    fi    
}

pre_remove()
{
    /etc/init.d/ndo2db stop
}

post_remove()
{
        sed -i "s/ndo2db//" "$1/etc/rcS.conf"
        /etc/init.d/nagios restart
        sed -i 's|broker_module=/usr/lib/ndoutils/ndomod.o config_file=/etc/nagios/ndomod.cfg||' "$1/etc/nagios/nagios.cfg"
}
6025 packages and 203154 files in current database (Thu Apr 25 06:17:47 2024)