2010-05-13 01:00:08 +02:00
|
|
|
#!/bin/sh
|
|
|
|
|
2015-02-05 00:07:15 +01:00
|
|
|
# Slackware build script for nagios
|
2010-05-13 01:00:08 +02:00
|
|
|
|
2013-04-24 13:14:17 +02:00
|
|
|
# Copyright 2009-2013 Niels Horn, Rio de Janeiro, RJ, Brazil
|
2015-02-25 13:30:17 +01:00
|
|
|
# Copyright 2014, 2015 Mario Preksavec, Zagreb, Croatia
|
2011-09-03 15:19:18 +02:00
|
|
|
# All rights reserved.
|
|
|
|
#
|
|
|
|
# Redistribution and use of this script, with or without modification, is
|
|
|
|
# permitted provided that the following conditions are met:
|
|
|
|
#
|
|
|
|
# 1. Redistributions of this script must retain the above copyright
|
|
|
|
# notice, this list of conditions and the following disclaimer.
|
|
|
|
#
|
2014-11-26 22:51:05 +01:00
|
|
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
|
2011-09-03 15:19:18 +02:00
|
|
|
# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
|
|
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
|
|
|
# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
|
|
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
|
|
|
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
|
|
|
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
|
|
|
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
|
|
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
2010-05-13 01:00:08 +02:00
|
|
|
PRGNAM=nagios
|
2014-11-26 22:51:05 +01:00
|
|
|
VERSION=${VERSION:-4.0.8}
|
2015-02-25 13:30:17 +01:00
|
|
|
BUILD=${BUILD:-2}
|
2010-05-13 01:00:08 +02:00
|
|
|
TAG=${TAG:-_SBo}
|
|
|
|
|
2010-07-11 16:06:29 +02:00
|
|
|
if [ -z "$ARCH" ]; then
|
|
|
|
case "$( uname -m )" in
|
|
|
|
i?86) ARCH=i486 ;;
|
|
|
|
arm*) ARCH=arm ;;
|
|
|
|
*) ARCH=$( uname -m ) ;;
|
|
|
|
esac
|
|
|
|
fi
|
|
|
|
|
2010-05-13 01:00:08 +02:00
|
|
|
DOCROOT=${DOCROOT:-/var/www/htdocs}
|
|
|
|
|
2010-07-11 16:06:29 +02:00
|
|
|
# To create valid symlinks, we need a relative path from DOCROOT
|
|
|
|
RELPATH=""
|
|
|
|
for i in $(echo $DOCROOT | tr "/" " "); do
|
|
|
|
RELPATH="${RELPATH}../"
|
|
|
|
done
|
|
|
|
|
2010-05-13 01:00:08 +02:00
|
|
|
CWD=$(pwd)
|
|
|
|
TMP=${TMP:-/tmp/SBo}
|
|
|
|
PKG=$TMP/package-$PRGNAM
|
|
|
|
OUTPUT=${OUTPUT:-/tmp}
|
|
|
|
|
|
|
|
if [ "$ARCH" = "i486" ]; then
|
|
|
|
SLKCFLAGS="-O2 -march=i486 -mtune=i686"
|
|
|
|
LIBDIRSUFFIX=""
|
|
|
|
elif [ "$ARCH" = "i686" ]; then
|
|
|
|
SLKCFLAGS="-O2 -march=i686 -mtune=i686"
|
|
|
|
LIBDIRSUFFIX=""
|
|
|
|
elif [ "$ARCH" = "x86_64" ]; then
|
|
|
|
SLKCFLAGS="-O2 -fPIC"
|
|
|
|
LIBDIRSUFFIX="64"
|
2010-07-11 16:06:29 +02:00
|
|
|
else
|
|
|
|
SLKCFLAGS="-O2"
|
|
|
|
LIBDIRSUFFIX=""
|
2010-05-13 01:00:08 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
# Check if the 'nagios' user & group exist:
|
|
|
|
if [ "$(grep ^nagios /etc/passwd)" = "" -o "$(grep ^nagios /etc/group)" = "" ] ; then
|
|
|
|
printf "\nYou must have a nagios user and group.\n\nExample:\n"
|
|
|
|
printf "\t# groupadd -g 213 nagios\n"
|
|
|
|
printf "\t# useradd -d /dev/null -s /bin/false -u 213 -g nagios nagios\n\n"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2011-09-03 15:19:18 +02:00
|
|
|
rm -rf $PKG
|
2010-05-13 01:00:08 +02:00
|
|
|
mkdir -p $TMP $PKG $OUTPUT
|
|
|
|
cd $TMP
|
2011-09-03 15:19:18 +02:00
|
|
|
rm -rf $PRGNAM
|
2010-05-13 01:00:08 +02:00
|
|
|
tar xvf $CWD/$PRGNAM-$VERSION.tar.gz
|
2014-11-26 22:51:05 +01:00
|
|
|
cd $PRGNAM-$VERSION
|
2010-05-13 01:00:08 +02:00
|
|
|
chown -R root:root .
|
2013-11-25 12:23:31 +01:00
|
|
|
find -L . \
|
|
|
|
\( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 \
|
|
|
|
-o -perm 511 \) -exec chmod 755 {} \; -o \
|
|
|
|
\( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \
|
|
|
|
-o -perm 440 -o -perm 400 \) -exec chmod 644 {} \;
|
2010-05-13 01:00:08 +02:00
|
|
|
|
|
|
|
CFLAGS="$SLKCFLAGS" \
|
|
|
|
./configure \
|
|
|
|
--prefix=/usr \
|
|
|
|
--sbindir=/usr/sbin/$PRGNAM \
|
|
|
|
--datadir=$DOCROOT/$PRGNAM \
|
|
|
|
--libdir=/usr/lib${LIBDIRSUFFIX} \
|
2010-09-09 00:18:04 +02:00
|
|
|
--libexecdir=/usr/libexec/$PRGNAM \
|
|
|
|
--sysconfdir=/etc/$PRGNAM \
|
2010-05-13 01:00:08 +02:00
|
|
|
--localstatedir=/var/$PRGNAM \
|
|
|
|
--mandir=/usr/man \
|
2012-12-27 20:16:46 +01:00
|
|
|
--build=$ARCH-slackware-linux \
|
2010-05-13 01:00:08 +02:00
|
|
|
--with-httpd-conf=/etc/httpd/extra \
|
|
|
|
--with-checkresult-dir=/var/spool/$PRGNAM \
|
|
|
|
--with-init-dir=/etc/rc.d \
|
|
|
|
--with-lockfile=/var/run/nagios/nagios.lock
|
|
|
|
|
|
|
|
make all
|
|
|
|
|
|
|
|
export DESTDIR=$PKG
|
2011-09-03 15:19:18 +02:00
|
|
|
echo "*** make install ***"
|
2010-05-13 01:00:08 +02:00
|
|
|
make install
|
2011-09-03 15:19:18 +02:00
|
|
|
echo "*** make install-init ***"
|
2010-05-13 01:00:08 +02:00
|
|
|
make install-init
|
2011-09-03 15:19:18 +02:00
|
|
|
echo "*** make install-commandmode ***"
|
2010-05-13 01:00:08 +02:00
|
|
|
make install-commandmode
|
2011-09-03 15:19:18 +02:00
|
|
|
echo "*** make install-config ***"
|
2010-05-13 01:00:08 +02:00
|
|
|
make install-config
|
|
|
|
# Need to create the $PKG/etc/httpd/extra directory (this is a bug in Makefile.in)
|
|
|
|
mkdir -p $PKG/etc/httpd/extra
|
2011-09-03 15:19:18 +02:00
|
|
|
echo "*** make install-webconf ***"
|
2010-05-13 01:00:08 +02:00
|
|
|
make install-webconf
|
2011-09-03 15:19:18 +02:00
|
|
|
# Following upstream, the "exfoliation" theme is now the default...
|
|
|
|
echo "*** make install-exfoliation ***"
|
|
|
|
make install-exfoliation
|
|
|
|
# ...but, if you prefer the "classic" theme, uncomment the next two lines, as they
|
|
|
|
# will overwrite the new theme:
|
|
|
|
#echo "*** make install-classicui ***"
|
|
|
|
#make install-classicui
|
2010-05-13 01:00:08 +02:00
|
|
|
|
2010-05-19 08:44:32 +02:00
|
|
|
find $PKG | xargs file | grep -e "executable" -e "shared object" | grep ELF \
|
|
|
|
| cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true
|
2010-05-13 01:00:08 +02:00
|
|
|
|
2015-02-25 13:30:17 +01:00
|
|
|
# Use monitoring-plugins instead of nagios-plugins
|
|
|
|
sed -i 's#\($USER1$=/usr/libexec/\)nagios#\1monitoring-plugins#' \
|
|
|
|
$PKG/etc/nagios/resource.cfg
|
|
|
|
|
2010-05-13 01:00:08 +02:00
|
|
|
# Change configuration files to .new
|
|
|
|
find $PKG/etc/$PRGNAM/ -name *.cfg | while read cfg ; do mv $cfg $cfg.new ; done
|
|
|
|
mv $PKG/etc/httpd/extra/nagios.conf $PKG/etc/httpd/extra/nagios.conf.new
|
2010-09-09 00:18:04 +02:00
|
|
|
# cfg files may contain passwords, so we don't want 'others' to read them
|
|
|
|
chmod -R g-w,o-rx $PKG/etc/$PRGNAM
|
2010-05-13 01:00:08 +02:00
|
|
|
|
|
|
|
# Create directory for lock-file
|
|
|
|
mkdir -p $PKG/var/run/nagios
|
|
|
|
|
|
|
|
# Change init script and leave it -x
|
|
|
|
mv $PKG/etc/rc.d/$PRGNAM $PKG/etc/rc.d/rc.$PRGNAM.new
|
|
|
|
chmod -x $PKG/etc/rc.d/rc.$PRGNAM.new
|
|
|
|
|
|
|
|
# Move documentation to right location
|
|
|
|
mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
|
|
|
|
cp -a \
|
|
|
|
Changelog INSTALLING LEGAL LICENSE README THANKS UPGRADING contrib \
|
|
|
|
$PKG/usr/doc/$PRGNAM-$VERSION
|
|
|
|
mv $PKG/$DOCROOT/$PRGNAM/docs $PKG/usr/doc/$PRGNAM-$VERSION/html
|
|
|
|
find $PKG/usr/doc/$PRGNAM-$VERSION -type f -exec chmod 644 {} \;
|
|
|
|
cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild
|
2010-03-16 01:49:39 +01:00
|
|
|
cat $CWD/README.SLACKWARE > $PKG/usr/doc/$PRGNAM-$VERSION/README.SLACKWARE
|
2010-05-13 01:00:08 +02:00
|
|
|
|
|
|
|
# Fixup some ownership and permission issues
|
|
|
|
chown root:root $PKG/usr/sbin
|
2010-03-16 01:49:39 +01:00
|
|
|
chown -R root:nagios $PKG/usr/sbin/$PRGNAM
|
|
|
|
chmod -R 0754 $PKG/usr/sbin/$PRGNAM
|
2010-05-13 01:00:08 +02:00
|
|
|
chown root:root $PKG/usr/bin
|
|
|
|
chmod 0755 $PKG/usr/bin
|
|
|
|
chown root:nagios $PKG/usr/bin/*
|
|
|
|
chmod 0754 $PKG/usr/bin/*
|
2010-03-16 01:49:39 +01:00
|
|
|
chown nagios:nagios $PKG/var/run/$PRGNAM
|
|
|
|
chmod 0775 $PKG/var/run/$PRGNAM
|
2010-05-13 01:00:08 +02:00
|
|
|
|
|
|
|
mkdir -p $PKG/install
|
|
|
|
cat $CWD/slack-desc > $PKG/install/slack-desc
|
|
|
|
cat $CWD/doinst.sh > $PKG/install/doinst.sh
|
|
|
|
|
|
|
|
cd $PKG
|
|
|
|
/sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.${PKGTYPE:-tgz}
|