2010-07-05 05:20:42 +02:00
#!/bin/sh
2009-08-11 18:26:09 +02:00
2013-02-07 17:53:01 +01:00
# Pandora FMS Server Installer (c) 2008-2013 Artica ST
2010-07-05 05:20:42 +02:00
# Linux/FreeBSD Version (generic), for SuSe, Debian/Ubuntu and FreeBSD only
2009-08-11 18:26:09 +02:00
# other Linux distros could not work properly without modifications
2009-04-20 17:14:04 +02:00
# Please see http://www.pandorafms.org
2013-02-07 17:53:01 +01:00
# v5.0 Build 130207
2008-04-07 00:11:16 +02:00
# This code is licensed under GPL 2.0 license.
# **********************************************************************
2022-09-30 12:00:00 +02:00
PI_VERSION="7.0NG.765"
2022-10-03 01:00:16 +02:00
PI_BUILD="221003"
2009-11-06 20:48:48 +01:00
2008-04-07 00:11:16 +02:00
MODE=$1
2014-09-18 12:55:45 +02:00
if [ $# -gt 1 ]; then
shift
fi
2014-08-12 08:06:26 +02:00
# Defaults
PREFIX=/usr
2009-12-07 15:57:03 +01:00
PANDORA_SPOOL=/var/spool/pandora
2014-08-12 08:06:26 +02:00
PANDORA_HOME=$PREFIX/share/pandora_server
2009-12-07 15:57:03 +01:00
PANDORA_CFG_DIR=/etc/pandora
PANDORA_LOG=/var/log/pandora
PANDORA_SERVER=/etc/init.d/pandora_server
TENTACLE_SERVER=/etc/init.d/tentacle_serverd
2014-08-12 08:06:26 +02:00
PANDORA_CFG_FILE=$PANDORA_CFG_DIR/pandora_server.conf
PANDORA_CFG_FILE_DIST=conf/pandora_server.conf.new
PANDORA_INIT_SCRIPT=util/pandora_server
2018-04-27 13:09:51 +02:00
TENTACLE_CFG_DIR=/etc/tentacle
TENTACLE_CFG_FILE=$TENTACLE_CFG_DIR/tentacle_server.conf
TENTACLE_CFG_FILE_DIST=conf/tentacle_server.conf.new
2014-08-12 08:06:26 +02:00
TENTACLE_INIT_SCRIPT=util/tentacle_serverd
PERL=perl
MANDIR=$PREFIX/share/man/man1
INITDIR=/etc/init.d
WITHOUT_TENTACLE=0
#
# set_global_vars
# Check platform and set DISTRO, OS_VERSION and LINUX.
# Also, define some platform sepcific variables (e.g. PANDORA_RC_VAR for (Free|Net)BSD)
# and override some of defaults defined above if needed.
#
set_global_vars () {
# Default
LINUX=NO
OS_VERSION=`uname -r`
DISTRO=`uname -s`
2016-01-13 16:04:36 +01:00
# set correct value for LINUX_DISTRO
2014-08-12 08:06:26 +02:00
case $DISTRO in
Linux)
# Default for Linux
LINUX=YES
DISTRO="GENERIC"
# Get Linux Distro type and version
# We assume we are on Linux unless told otherwise
if [ -f "/etc/SuSE-release" ]
then
OS_VERSION=`cat /etc/SuSE-release | grep VERSION | cut -f 3 -d " "`
DISTRO=SUSE
elif [ -f "/etc/lsb-release" ] && [ ! -f "/etc/redhat-release" ]
then
OS_VERSION=`cat /etc/lsb-release | grep DISTRIB_RELEASE | cut -f 2 -d "="`
DISTRO=UBUNTU
OS_VERSION="UBUNTU $OS_VERSION"
elif [ -f "/etc/debian_version" ]
then
OS_VERSION=`cat /etc/debian_version`
OS_VERSION="DEBIAN $OS_VERSION"
DISTRO=DEBIAN
elif [ -f "/etc/fedora-release" ]
then
OS_VERSION=`cat /etc/fedora-release | cut -f 4 -d " "`
OS_VERSION="FEDORA $OS_VERSION"
DISTRO=FEDORA
fi
;;
Darwin|AIX)
# For future reference, Darwin doesn't have /etc/init.d but uses LaunchDaemons.
# AIX doesn't have /etc/init.d
;;
SunOS)
2009-09-21 22:26:23 +02:00
# Some Solaris and other Unices don't have /etc/init.d, some have /usr/spool instead of /var/spool
2014-08-12 08:06:26 +02:00
DISTRO="Solaris"
;;
FreeBSD)
PREFIX=/usr/local
PANDORA_HOME=$PREFIX/share/pandora_server
PANDORA_CFG_DIR=$PREFIX/etc/pandora
PANDORA_SERVER=$PREFIX/etc/rc.d/pandora_server
TENTACLE_SERVER=$PREFIX/etc/rc.d/tentacle_server
PANDORA_CFG_FILE=$PANDORA_CFG_DIR/pandora_server.conf
PANDORA_CFG_FILE_DIST=$DISTRO/pandora_server.conf.new
PANDORA_INIT_SCRIPT=$DISTRO/pandora_server
2018-04-27 13:09:51 +02:00
TENTACLE_CFG_DIR=$PREFIX/etc/tentacle
TENTACLE_CFG_FILE=$TENTACLE_CFG_DIR/tentacle_server.conf
2014-08-12 08:06:26 +02:00
TENTACLE_INIT_SCRIPT=$DISTRO/tentacle_server
MANDIR=$PREFIX/man/man1
INITDIR=$PREFIX/etc/rc.d
PERL=/usr/local/bin/perl
PANDORA_RC_VAR="pandora_server_enable"
TENTACLE_RC_VAR="tentacle_server_enable"
;;
NetBSD)
PREFIX=/usr/local
PANDORA_HOME=$PREFIX/share/pandora_server
PANDORA_CFG_DIR=$PREFIX/etc/pandora
PANDORA_SERVER=/etc/rc.d/pandora_server
2018-04-27 13:09:51 +02:00
TENTACLE_CFG_DIR=$PREFIX/etc/tentacle
TENTACLE_CFG_FILE=$TENTACLE_CFG_DIR/tentacle_server.conf
2014-08-12 08:06:26 +02:00
TENTACLE_SERVER=/etc/rc.d/tentacle_server
PANDORA_CFG_FILE=$PANDORA_CFG_DIR/pandora_server.conf
PANDORA_CFG_FILE_DIST=$DISTRO/pandora_server.conf.new
PANDORA_INIT_SCRIPT=$DISTRO/pandora_server
TENTACLE_INIT_SCRIPT=$DISTRO/tentacle_server
PERL=/usr/pkg/bin/perl
INITDIR=/etc/rc.d
PANDORA_RC_VAR="pandora_server"
TENTACLE_RC_VAR="tentacle_server"
;;
esac
}
#
# install_startup_script [options...] SRC
# copy SRC into the $INITDIR and do additional required operation according to $DISTRO
# if $INITDIR is not set or empty, do nothing.
# If $DESTDIR is set, skip enabling service
# OPTIONS:
# -s SPRIO specify startup priority for service
#
install_startup_script () {
[ "$INITDIR" ] || return 1
if [ "$1" = "-s" ]
2013-04-03 06:59:01 +02:00
then
2014-08-12 08:06:26 +02:00
SPRIO=$2
shift;shift
2008-06-19 16:53:10 +02:00
fi
2014-08-12 08:06:26 +02:00
SRC=$1
SCRIPT_NAME=`basename $SRC`
echo "Copying the daemon script into $INITDIR"
2016-06-20 14:10:28 +02:00
[ -d $DESTDIR$INITDIR ] || mkdir -p $DESTDIR$INITDIR
2014-08-12 08:06:26 +02:00
cp $SRC $DESTDIR$INITDIR
[ "$DESTDIR" ] && return
case $DISTRO in
UBUNTU|DEBIAN)
echo "Linking startup script to /etc/rc2.d"
update-rc.d $SCRIPT_NAME defaults
;;
SUSE)
echo "Creating startup daemons"
insserv $SCRIPT_NAME
;;
FeeBSD|NetBSD)
2014-08-14 13:26:16 +02:00
chmod 555 $DESTDIR$INITDIR/$SCRIPT_NAME
2014-08-12 08:06:26 +02:00
;;
*)
if [ "$LINUX" = YES ]
then
# Pandora FMS Server install (Other Distros)
INITLV=`grep '[0-9]:initdefault' /etc/inittab | cut -f 2 -d ':'`
: ${INITLV:=2}
echo "Linking startup script to /etc/rc.d/rc$INITLV.d/S$SPRIO$SCRIPT_NAME"
ln -s $INITDIR/$SCRIPT_NAME /etc/rc.d/rc$INITLV.d/S$SPRIO$SCRIPT_NAME
fi
;;
esac
2009-08-11 18:26:09 +02:00
}
2008-06-19 16:53:10 +02:00
2009-08-11 18:26:09 +02:00
install () {
2014-08-12 08:06:26 +02:00
set_global_vars
2011-10-26 19:11:13 +02:00
FORCE=0
2016-01-13 16:04:36 +01:00
BINARIES=0
2011-10-26 19:11:13 +02:00
2014-08-12 08:06:26 +02:00
# parse options
while :
do
case $1 in
--force) FORCE=1;;
2016-01-13 16:04:36 +01:00
--from-binary) BINARIES=1;;
--no-tentacle) WITHOUT_TENTACLE=1;;
2014-08-12 08:06:26 +02:00
--destdir) DESTDIR=$2;shift;;
*) break;;
esac
shift
done
2016-01-13 16:04:36 +01:00
2014-08-12 08:06:26 +02:00
if [ "$LINUX" = YES ]
then
echo "$DISTRO distribution detected"
else
echo "$DISTRO detected"
fi
2016-01-13 16:04:36 +01:00
if [ ! $BINARIES -eq 1 ]
# Do not compile files if binary is distributed
2014-08-12 08:06:26 +02:00
then
2016-01-13 16:04:36 +01:00
$PERL Makefile.PL INSTALLMAN1DIR=none WITHOUT_TENTACLE=$WITHOUT_TENTACLE > output 2>&1
#&& sleep 2 && cat output | grep "found" | wc -l
DEPENDENCIAS=`cat output | grep "found" | wc -l`
if [ $DEPENDENCIAS -gt 0 ] && [ $FORCE -eq 0 ]
2009-12-18 19:22:33 +01:00
then
2016-01-13 16:04:36 +01:00
echo "You are missing the following dependencies"
echo " "
cat output | awk -F ": prerequisite" '{print $2}' | awk -F " " '{print $1}'
2021-11-04 16:28:15 +01:00
echo "The complete installation guide is at: https://pandorafms.com/docs/"
2016-01-13 16:04:36 +01:00
echo " "
echo "Debian-based distribution do:"
echo " # apt-get install snmp snmpd libjson-perllibio-socket-inet6-perl libsocket6-perl libxml-simple-perl libxml-twig-perl libnetaddr-ip-perl libdbi-perl libnetaddr-ip-perl libhtml-parser-perl wmi-client xprobe2 snmp-mibs-downloader"
echo " "
echo "For CentOS / RHEL do: "
echo " "
echo " # yum install perl-XML-Simple* perl-XML-Twig perl-JSON perl-IO-Socket* perl-Socket6 perl-Time-modules* perl-NetAddr-IP* perl-DateTime* perl-ExtUtils perl-DBI nmap "
echo " "
echo "For OpenSUSE / SLES do : "
echo " "
echo " # zypper install nmap perl-DBD-mysql perl-DBI perl-HTML-Parser perl-JSON
perl-HTML-Encoding perl-HTML-Tree perl-NetAddr-IP perl-IO-Socket-INET6 perl-Socket6
perl-TimeDate perl-XML-Simple perl-XML-Twig perl-libwww-perl mysql-client"
echo " "
echo " You also will need to install (optionally) xprobe2 and wmiclient from rpm (download from our website)"
echo " "
echo "For FreeBSD do : "
echo " "
2020-07-27 06:52:06 +02:00
echo " Install following tools from ports or packages."
2016-01-13 16:04:36 +01:00
echo " Recommended: p5-DBI p5-NetAddr-IP p5-XML-Simple p5-XML-Twig p5-HTML-Parser p5-DBD-mysql p5-Socket6 p5-IO-Socket-INET6 p5-JSON"
echo " Optional: nmap xprobe"
echo " "
2020-07-27 06:52:06 +02:00
echo " And install Geo::IP manually."
echo " "
echo "To get them from source through CPAN do"
2016-01-13 16:04:36 +01:00
echo " "
2020-07-27 06:52:06 +02:00
echo " $ cpan Time::Local DBI Socket6 XML::Simple XML::Twig IO::Socket Time::HiRes NetAddr::IP HTML::Entities IO::Socket::INET6 JSON Geo::IP"
2016-01-13 16:04:36 +01:00
echo " "
rm output
2014-08-12 08:06:26 +02:00
exit 1
2009-12-18 19:22:33 +01:00
fi
2016-01-13 16:04:36 +01:00
rm output
echo "Installing binaries and libraries"
make
make DESTDIR=$DESTDIR install
echo "Checking binaries at /usr/local/bin -> /usr/bin"
if [ ! -f "$DESTDIR/usr/bin/pandora_server" ]
2014-08-12 08:06:26 +02:00
then
2016-01-13 16:04:36 +01:00
if [ ! -f "$DESTDIR/usr/local/bin/pandora_server" ]
then
echo "ERROR compiling Pandora FMS Server from sources. Aborting"
exit 1
fi
if [ "$DISTRO" != "FreeBSD" ] && [ "$DISTRO" != "NetBSD" ]
then
2016-06-20 14:10:28 +02:00
[ -d $DESTDIR$PREFIX/bin ] || mkdir -p $DESTDIR$PREFIX/bin
2016-01-13 16:04:36 +01:00
ln -s /usr/local/bin/pandora_server $DESTDIR$PREFIX/bin
ln -s /usr/local/bin/pandora_exec $DESTDIR$PREFIX/bin
ln -s /usr/local/bin/tentacle_server $DESTDIR$PREFIX/bin
2020-11-10 19:31:14 +01:00
ln -s /usr/local/bin/tentacle_client $DESTDIR$PREFIX/bin
2016-01-13 16:04:36 +01:00
fi
2009-08-11 18:26:09 +02:00
fi
2014-08-12 08:06:26 +02:00
fi
2009-09-21 22:26:23 +02:00
2014-08-12 08:06:26 +02:00
echo "Creating common Pandora FMS directories"
id pandora 2> /dev/null
if [ $? -eq 0 ]; then
echo " "
echo "User pandora does exist, make sure the SSH directories are correct"
elif [ "$DESTDIR" ]
then
# chown can fail with fakeroot installation
echo "User 'pandora' does not exist. All chown operations may fail."
echo "You should manualy set proper ownership to $DESTDIR$PANDORA_SPOOL if needed."
echo
else
echo "Are you sure we can create a standard 'pandora' user locally? [y/N]"
read AREYOUSURE
if [ "$AREYOUSURE" = "y" ]; then
if [ "$DISTRO" = "FreeBSD" ]
2009-09-21 22:26:23 +02:00
then
2014-08-12 08:06:26 +02:00
echo "pandora:41121:::::Pandora FMS:/home/pandora:/usr/sbin/nologin:" | adduser -f - -w no 2> /dev/null
2009-09-21 22:26:23 +02:00
else
2014-08-12 08:06:26 +02:00
useradd pandora
mkdir /home/pandora 2> /dev/null
mkdir /home/pandora/.ssh 2> /dev/null
chown -R pandora /home/pandora
2009-09-21 22:26:23 +02:00
fi
2010-07-05 05:20:42 +02:00
else
2014-08-12 08:06:26 +02:00
echo "Please create the 'pandora' user manually according to your authentication scheme, then start again the installation"
echo "Aborting..."
exit 1
2010-07-05 05:20:42 +02:00
fi
2014-08-12 08:06:26 +02:00
fi
2010-05-11 19:02:26 +02:00
2014-08-12 08:06:26 +02:00
mkdir -p $DESTDIR$PANDORA_SPOOL/data_in 2> /dev/null
2017-02-27 13:06:19 +01:00
chmod 2770 $DESTDIR$PANDORA_SPOOL/data_in
2014-08-12 08:06:26 +02:00
mkdir $DESTDIR$PANDORA_SPOOL/data_in/conf 2> /dev/null
2017-02-27 13:06:19 +01:00
chmod 2770 $DESTDIR$PANDORA_SPOOL/data_in/conf
2014-08-12 08:06:26 +02:00
mkdir $DESTDIR$PANDORA_SPOOL/data_in/md5 2> /dev/null
2017-02-27 13:06:19 +01:00
chmod 2770 $DESTDIR$PANDORA_SPOOL/data_in/md5
2014-08-12 08:06:26 +02:00
mkdir $DESTDIR$PANDORA_SPOOL/data_in/collections 2> /dev/null
2017-02-27 13:06:19 +01:00
chmod 2770 $DESTDIR$PANDORA_SPOOL/data_in/collections
2014-08-12 08:06:26 +02:00
mkdir $DESTDIR$PANDORA_SPOOL/data_in/netflow 2> /dev/null
2017-02-27 13:06:19 +01:00
chmod 2770 $DESTDIR$PANDORA_SPOOL/data_in/netflow
2016-06-13 14:34:30 +02:00
mkdir $DESTDIR$PANDORA_SPOOL/data_in/trans 2> /dev/null
2017-02-27 13:06:19 +01:00
chmod 2770 $DESTDIR$PANDORA_SPOOL/data_in/trans
2019-11-21 18:21:46 +01:00
mkdir $DESTDIR$PANDORA_SPOOL/data_in/commands 2> /dev/null
chmod 2770 $DESTDIR$PANDORA_SPOOL/data_in/commands
2014-08-12 08:06:26 +02:00
mkdir -p $DESTDIR$PANDORA_LOG 2> /dev/null
2021-03-04 12:13:16 +01:00
chown -R pandora:apache $DESTDIR$PANDORA_LOG 2> /dev/null
2018-05-31 20:16:09 +02:00
chmod 2774 $DESTDIR$PANDORA_LOG 2> /dev/null
2014-08-12 08:06:26 +02:00
echo "Giving proper permission to /var/spool/pandora"
for group in "www-data" wwwrun www apache
do
IDGROUP=`id -g "$group" 2> /dev/null`
if [ $? -eq 0 ]
2010-07-05 05:20:42 +02:00
then
2014-08-12 08:06:26 +02:00
GROUPNAME=`grep ":$IDGROUP:" /etc/group | awk -F":" '{print $1}'`
break
2010-07-05 05:20:42 +02:00
fi
2014-08-12 08:06:26 +02:00
done
if [ -z "$GROUPNAME" ]
then
echo "No web server user found, some functionality might not perform correctly"
GROUPNAME=0
fi
# when fakeroot installation, this can fail
chown -R pandora:$GROUPNAME $DESTDIR$PANDORA_SPOOL 2>/dev/null
2022-05-24 11:58:40 +02:00
chown apache:$GROUPNAME $DESTDIR$PANDORA_SPOOL/data_in/customer_key 2>/dev/null
2014-08-12 08:06:26 +02:00
echo "Creating setup directory in $PANDORA_CFG_DIR"
mkdir -p $DESTDIR$PANDORA_CFG_DIR 2> /dev/null
if [ -f "$DESTDIR$PANDORA_CFG_FILE" ]
then
echo cp $PANDORA_CFG_FILE_DIST $DESTDIR$PANDORA_CFG_DIR
cp $PANDORA_CFG_FILE_DIST $DESTDIR$PANDORA_CFG_DIR
else
echo cp $PANDORA_CFG_FILE_DIST $DESTDIR$PANDORA_CFG_FILE
cp $PANDORA_CFG_FILE_DIST $DESTDIR$PANDORA_CFG_FILE
chmod 770 $DESTDIR$PANDORA_CFG_FILE
fi
2009-08-11 18:26:09 +02:00
2014-08-12 08:06:26 +02:00
echo "Installing Pandora Server manual"
2016-06-20 14:10:28 +02:00
[ -d $DESTDIR$MANDIR ] || mkdir -p $DESTDIR$MANDIR
2014-08-12 08:06:26 +02:00
cp man/man1/pandora_server.1.gz $DESTDIR$MANDIR
2010-02-23 18:49:05 +01:00
2014-08-12 08:06:26 +02:00
install_startup_script -s 90 $PANDORA_INIT_SCRIPT
if [ -d /etc/logrotate.d ]
then
2021-03-31 17:24:18 +02:00
if [ -f $DESTDIR/etc/logrotate.d/pandora_server ]
then
echo "A logrotate.d entry for Pandora FMS log management already exists, skipping creation"
else
echo "Creating logrotate.d entry for Pandora FMS log management"
[ -d $DESTDIR/etc/logrotate.d ] || mkdir -p $DESTDIR/etc/logrotate.d
cp util/pandora_server_logrotate $DESTDIR/etc/logrotate.d/pandora_server
fi
2014-08-12 08:06:26 +02:00
else
echo "Please add a log rotation schedule manually to your log rotation daemon (if any)"
fi
if [ $WITHOUT_TENTACLE -eq 0 ]
then
# tentacle_server is already installed by "make install"
install_startup_script -s 80 $TENTACLE_INIT_SCRIPT
2018-04-27 13:09:51 +02:00
# Create the directory to locate the Tentacle configuration file
echo "Creating setup Tentacle directory in $TENTACLE_CFG_DIR"
mkdir -p $DESTDIR$TENTACLE_CFG_DIR 2> /dev/null
if [ -f "$DESTDIR$TENTACLE_CFG_FILE" ]
then
echo cp $TENTACLE_CFG_FILE_DIST $DESTDIR$TENTACLE_CFG_DIR
cp $TENTACLE_CFG_FILE_DIST $DESTDIR$TENTACLE_CFG_DIR
else
echo cp $TENTACLE_CFG_FILE_DIST $DESTDIR$TENTACLE_CFG_FILE
cp $TENTACLE_CFG_FILE_DIST $DESTDIR$TENTACLE_CFG_FILE
2018-04-30 16:22:52 +02:00
chmod 774 $DESTDIR$TENTACLE_CFG_FILE
2018-04-27 13:09:51 +02:00
fi
2009-09-21 22:26:23 +02:00
2014-08-12 08:06:26 +02:00
echo "Installing Tentacle Server manual"
cp man/man1/tentacle_server.1.gz $DESTDIR$MANDIR
fi
echo "Creating Pandora FMS distribution directory in $PANDORA_HOME"
mkdir -p $DESTDIR$PANDORA_HOME 2> /dev/null
cp -R util $DESTDIR$PANDORA_HOME
find $DESTDIR$PANDORA_HOME -type l -delete
2020-07-27 06:52:06 +02:00
case $DISTRO in
FreeBSD)
# adjust shebang
for pl_script in `find $DESTDIR$PANDORA_HOME/util -name "*.pl"`
do
cat $pl_script | sed 's/^#!\/usr\/bin\/perl/#!\/usr\/local\/bin\/perl/g' > ${pl_script}.new
mv ${pl_script}.new $pl_script
chmod a+x $pl_script
done
for sh_script in `find $DESTDIR$PANDORA_HOME/util -name "*.sh"`
do
cat $sh_script | sed 's/^#!\/bin\/bash/#!\/usr\/local\/bin\/bash/g' > ${sh_script}.new
mv ${sh_script}.new $sh_script
chmod a+x $sh_script
done
2021-07-19 06:47:24 +02:00
# install pandora_ha
INSTALL_DIR="$DESTDIR$PREFIX/bin/"
echo ">Installing the pandora_ha binary to $INSTALL_DIR..."
cp -f $DESTDIR$PANDORA_HOME/util/pandora_ha.pl "$INSTALL_DIR/pandora_ha"
chmod +x "$INSTALL_DIR/pandora_ha"
2020-07-27 06:52:06 +02:00
;;
2021-06-14 13:56:42 +02:00
*)
SYSTEMD_DIR=$DESTDIR/etc/systemd/system
PID_DIR=$DESTDIR/var/run
INSTALL_DIR="$DESTDIR$PREFIX/bin/"
echo ">Installing the pandora_ha binary to $INSTALL_DIR..."
cp -f util/pandora_ha.pl "$INSTALL_DIR/pandora_ha"
chmod +x "$INSTALL_DIR/pandora_ha"
echo ">Installing pandora_ha service to $INSTALL_DIR..."
[ -d "$PID_DIR" ] || mkdir -p "$PID_DIR"
[ -d "$SYSTEMD_DIR" ] || mkdir -p "$SYSTEMD_DIR"
cat > $SYSTEMD_DIR/pandora_ha.service <<-EOF
[Unit]
2021-08-26 10:47:52 +02:00
Description=Pandora FMS Daemon Watchdog
2021-06-14 13:56:42 +02:00
[Service]
Type=forking
User=$USER
PIDFile=$PID_DIR/pandora_ha.pid
Restart=always
ExecStart=${INSTALL_DIR}pandora_ha -d -p $PID_DIR/pandora_ha.pid $PANDORA_CONF
[Install]
WantedBy=multi-user.target
EOF
;;
2020-07-27 06:52:06 +02:00
esac
2014-08-12 08:06:26 +02:00
# install cron job
if [ -d /etc/cron.hourly ]
then
[ ! -d $DESTDIR/etc/cron.hourly ] && mkdir -p $DESTDIR/etc/cron.hourly
echo "Creating the Cron script to run Pandora DB tool each hour"
echo "#!/bin/bash" > $DESTDIR/etc/cron.hourly/pandora_db
2016-06-20 14:10:28 +02:00
echo "perl $PANDORA_HOME/util/pandora_db.pl /etc/pandora/pandora_server.conf" >> $DESTDIR/etc/cron.hourly/pandora_db
chmod +x $DESTDIR/etc/cron.hourly/pandora_db
2014-08-12 08:06:26 +02:00
elif [ "$DISTRO" = "FreeBSD" ] || [ "$DISTRO" = "NetBSD" ]
then
if [ "$DESTDIR" ]
2009-08-11 18:26:09 +02:00
then
2014-08-12 08:06:26 +02:00
echo "Skip adding cron entry for pandora_db.pl when performing fakeroot installation."
2009-08-11 18:26:09 +02:00
else
2014-08-12 08:06:26 +02:00
grep pandora_db.pl /etc/crontab > /dev/null 2>&1
if [ $? -ne 0 ]
2010-07-05 05:20:42 +02:00
then
2014-08-12 08:06:26 +02:00
echo "# Pandora FMS" >> /etc/crontab
echo "2 * * * * root perl $PANDORA_HOME/util/pandora_db.pl $PANDORA_CFG_FILE" >> /etc/crontab
2010-07-05 05:20:42 +02:00
else
2014-08-12 08:06:26 +02:00
echo "The crontab for pandora_db.pl is already configured."
2010-07-05 05:20:42 +02:00
fi
2009-08-11 18:26:09 +02:00
fi
2014-08-12 08:06:26 +02:00
else
echo "You're probably not using cron for automatic scheduling. You should schedule the following command to run frequently (hourly) on your master server:"
echo " perl $PANDORA_HOME/util/pandora_db.pl $PANDORA_CFG_FILE"
2008-07-08 20:52:57 +02:00
fi
2014-08-12 08:06:26 +02:00
echo
echo "Now you have to edit your $PANDORA_CFG_FILE file to change the database password (default is pandora) with the one set in include/config.php of your Pandora FMS Console."
echo "After setting password you can start your Pandora FMS Server!!"
2008-04-07 00:11:16 +02:00
2014-08-12 08:06:26 +02:00
if [ "$DISTRO" = "FreeBSD" ] || [ "$DISTRO" = "NetBSD" ]
2013-04-03 06:59:01 +02:00
then
2014-08-12 08:06:26 +02:00
echo " "
echo "Define '$PANDORA_RC_VAR=\"YES\"' in /etc/rc.conf to enable pandora server daemon."
[ "$WITHOUT_TENTACLE" = 0 ] && \
echo "Define '$TENTACLE_RC_VAR=\"YES\"' in /etc/rc.conf to enable tentacle server daemon."
fi
2010-07-05 05:20:42 +02:00
}
2008-04-07 00:11:16 +02:00
uninstall () {
2014-08-12 08:06:26 +02:00
set_global_vars
2014-09-18 17:03:31 +02:00
if [ "$LINUX" != "YES" ] && [ "$DISTRO" != "FreeBSD" ] && [ "$DISTRO" != "NetBSD" ]
2014-08-12 08:06:26 +02:00
then
echo "This is not a Linux-based distro. Uninstaller is currently not working for your OS"
exit 1
fi
echo "Removing PERL libs and man files"
PERL_SITELIB=/usr/lib/perl5
if [ "$DISTRO" != "FreeBSD" ] || [ "$DISTRO" != "NetBSD" ]
then
PERL_SITELIB=$(eval $($PERL -V:sitelib);echo $sitelib);
2008-07-08 20:52:57 +02:00
fi
2014-08-12 08:06:26 +02:00
PERL_SITEMAN3DIR=`eval \`$PERL -V:siteman3dir\`;echo $siteman3dir`;
[ -d $DESTDIR/$PERL_SITELIB/PandoraFMS ] && rm -rf $DESTDIR/$PERL_SITELIB/PandoraFMS
rm -f $DESTDIR/$PERL_SITEMAN3DIR/PandoraFMS::* 2>/dev/null
2013-06-07 13:43:34 +02:00
2008-07-08 20:52:57 +02:00
echo "Removing Pandora Servers"
2014-08-12 08:06:26 +02:00
if [ -d $DESTDIR$PANDORA_SPOOL/data_out ]; then
rm -Rf $DESTDIR$PANDORA_SPOOL/data_in
2010-07-20 14:01:47 +02:00
else
2014-08-12 08:06:26 +02:00
rm -Rf $DESTDIR$PANDORA_SPOOL
2010-07-20 14:01:47 +02:00
fi
2008-07-08 20:52:57 +02:00
echo "If the user Pandora is not being used for any other operations, please delete using the following commands:"
2014-08-12 08:06:26 +02:00
if [ "$DISTRO" != "FreeBSD" ] || [ "$DISTRO" != "NetBSD" ]
then
echo " rmuser pandora"
else
echo " userdel pandora"
echo " rm -Rf /home/pandora/"
fi
2010-02-23 18:49:05 +01:00
2009-12-16 19:15:25 +01:00
## Just to clarify here. Some people (like me) are using the pandora user
## for other purposes and/or using an LDAP-based user management
2008-07-08 20:52:57 +02:00
## I would hate to have a script clear out this users' information without any notification
2014-08-12 08:06:26 +02:00
rm -Rf $DESTDIR$PANDORA_LOG 2> /dev/null
rm -f $DESTDIR$PANDORA_CFG_FILE 2> /dev/null
rm -f "$DESTDIR$PANDORA_CFG_FILE.new" 2> /dev/null
2018-04-27 13:09:51 +02:00
rm -f $DESTDIR$TENTACLE_CFG_FILE 2> /dev/null
rm -f "$DESTDIR$TENTACLE_CFG_FILE.new" 2> /dev/null
2014-08-12 08:06:26 +02:00
rm -f $DESTDIR$PANDORA_SERVER 2> /dev/null
rm -f $DESTDIR$PREFIX/bin/pandora_server 2> /dev/null
rm -f $DESTDIR$PREFIX/bin/pandora_exec 2> /dev/null
2020-11-10 19:31:14 +01:00
# Do not remove tentacle files if agent is still installed...
[ -e $DESTDIR$PREFIX/bin/pandora_agent ] || rm -f $DESTDIR$PREFIX/bin/tentacle_server 2> /dev/null
[ -e $DESTDIR$PREFIX/bin/pandora_agent ] || rm -f $DESTDIR$PREFIX/bin/tentacle_client 2> /dev/null
2014-08-12 08:06:26 +02:00
rm -Rf $DESTDIR$PANDORA_HOME
rm -f $DESTDIR/etc/cron.hourly/pandora_db
2015-11-02 16:52:30 +01:00
rm -f $DESTDIR/etc/logrotate.d/pandora_server
2014-08-12 08:06:26 +02:00
if [ "$DESTDIR" ]
then
# do nothing with "fakeroot" uninstallation
:
elif [ "$DISTRO" = "UBUNTU" ] || [ "$DISTRO" = "DEBIAN" ]
2009-12-07 15:57:03 +01:00
then
update-rc.d -f pandora_server remove
update-rc.d -f tentacle_serverd remove
2014-08-12 08:06:26 +02:00
elif [ "$DISTRO" != "FreeBSD" ] || [ "$DISTRO" != "NetBSD" ]
then
TMP_CRONTAB=/tmp/crontab.tmp
egrep -v "Pandora FMS|pandora_db.pl" /etc/crontab > $TMP_CRONTAB
cp $TMP_CRONTAB /etc/crontab
rm $TMP_CRONTAB
2009-12-07 15:57:03 +01:00
fi
2014-08-12 08:06:26 +02:00
rm -f $DESTDIR/etc/rc2.d/S90pandora_server 2> /dev/null
rm -f $DESTDIR/etc/rc.d/rc3.d/S90pandora_server 2> /dev/null
rm -f $DESTDIR/etc/rc2.d/S80tentacle_serverd 2> /dev/null
rm -f $DESTDIR/etc/rc.d/rc3.d/S80tentacle_serverd 2> /dev/null
rm -f $DESTDIR$MANDIR/pandora_server.1.gz 2>/dev/null
rm -f $DESTDIR$MANDIR/tentacle_server.1.gz 2>/dev/null
2008-04-07 00:11:16 +02:00
echo "Done"
}
help () {
2009-12-16 19:15:25 +01:00
echo " --install To install Pandora FMS Servers on this system (You have to be root)"
echo " --uninstall To uninstall and remove Pandora FMS Servers on this System"
2009-04-20 17:14:04 +02:00
echo " "
2011-10-26 19:11:13 +02:00
echo " Additional second parameter (after --install) "
2009-12-16 19:15:25 +01:00
echo " "
2011-10-26 19:11:13 +02:00
echo " --force Ignore dependency problems and do the install"
2009-12-16 19:15:25 +01:00
echo " --no-tentacle Skip tentacle server installation (by default tentacle server installed)"
2014-08-12 08:06:26 +02:00
echo " --destdir DIR Specify root directory for \"fakeroot\" installation"
2016-01-13 16:04:36 +01:00
echo " --from-binary No compile Pandora Server and not execute Makefiles"
2009-04-20 17:14:04 +02:00
echo " "
2008-04-07 00:11:16 +02:00
}
# Script banner at start
echo " "
2016-01-13 16:04:36 +01:00
echo "Pandora FMS Server Installer $PI_VERSION $PI_BUILD (c) 2008-2016 Artica ST"
2013-02-07 17:53:01 +01:00
echo "This program is licensed under GPL2 Terms. http://pandorafms.com"
2008-04-07 00:11:16 +02:00
echo " "
case "$MODE" in
'--install')
2014-08-12 08:06:26 +02:00
install "$@"
2016-01-13 16:04:36 +01:00
exit 0
2009-12-16 19:15:25 +01:00
;;
2008-04-07 00:11:16 +02:00
'--uninstall')
2014-08-12 08:06:26 +02:00
uninstall "$@"
2016-01-13 16:04:36 +01:00
exit 0
2009-12-16 19:15:25 +01:00
;;
2008-04-07 00:11:16 +02:00
*)
2009-12-16 19:15:25 +01:00
help
2008-04-07 00:11:16 +02:00
esac