2010-07-05 05:20:42 +02:00
#!/bin/sh
2009-08-11 18:26:09 +02:00
2011-04-28 17:33:25 +02:00
# Pandora FMS Server Installer (c) 2008-2011 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
2012-12-10 20:09:58 +01:00
# v5.0 Build 121210
2008-04-07 00:11:16 +02:00
# This code is licensed under GPL 2.0 license.
# **********************************************************************
2009-11-06 20:48:48 +01:00
2008-04-07 00:11:16 +02:00
MODE=$1
2009-04-20 17:14:04 +02:00
SECOPT=$2
2009-12-07 15:57:03 +01:00
PANDORA_SPOOL=/var/spool/pandora
PANDORA_HOME=/usr/share/pandora_server
PANDORA_CFG_DIR=/etc/pandora
PANDORA_LOG=/var/log/pandora
PANDORA_SERVER=/etc/init.d/pandora_server
TENTACLE_SERVER=/etc/init.d/tentacle_serverd
PANDORA_CFG_FILE=/etc/pandora/pandora_server.conf
2008-04-07 00:11:16 +02:00
2009-08-11 18:26:09 +02:00
get_distro () {
# Get Linux Distro type and version
2009-09-21 22:26:23 +02:00
# We assume we are on Linux unless told otherwise
2009-09-22 12:38:53 +02:00
LINUX=YES
2009-08-11 18:26:09 +02:00
if [ -f "/etc/SuSE-release" ]
2008-06-19 16:53:10 +02:00
then
2009-08-11 18:26:09 +02:00
OS_VERSION=`cat /etc/SuSE-release | grep VERSION | cut -f 3 -d " "`
LINUX_DISTRO=SUSE
2009-09-21 22:26:23 +02:00
elif [ -f "/etc/lsb-release" ]
then
OS_VERSION=`cat /etc/lsb-release | grep DISTRIB_RELEASE | cut -f 2 -d "="`
LINUX_DISTRO=UBUNTU
OS_VERSION="UBUNTU $OS_VERSION"
elif [ -f "/etc/debian_version" ]
then
OS_VERSION=`cat /etc/debian_version`
OS_VERSION="DEBIAN $OS_VERSION"
LINUX_DISTRO=DEBIAN
elif [ -f "/etc/fedora-release" ]
then
OS_VERSION=`cat /etc/fedora-release | cut -f 4 -d " "`
OS_VERSION="FEDORA $OS_VERSION"
LINUX_DISTRO=FEDORA
2010-07-05 05:20:42 +02:00
elif [ `uname -s` = "Darwin" ]
2009-09-21 22:26:23 +02:00
then
# For future reference, Darwin doesn't have /etc/init.d but uses LaunchDaemons
LINUX_DISTRO="Darwin"
OS_VERSION=`uname -r`
2009-09-22 12:38:53 +02:00
LINUX=NO
2010-07-05 05:20:42 +02:00
elif [ `uname -s` = "AIX" ]
2009-12-16 19:15:25 +01:00
then
# For future reference, AIX doesn't have /etc/init.d
LINUX_DISTRO="AIX"
OS_VERSION=`uname -r`
LINUX=NO
2010-07-05 05:20:42 +02:00
elif [ `uname -s` = "SunOS" ]
2009-09-21 22:26:23 +02:00
then
# Some Solaris and other Unices don't have /etc/init.d, some have /usr/spool instead of /var/spool
LINUX_DISTRO="Solaris"
OS_VERSION=`uname -r`
2009-09-22 12:38:53 +02:00
LINUX=NO
2010-07-05 05:20:42 +02:00
elif [ `uname -s` = "Linux" ]
2009-09-21 22:26:23 +02:00
then
# Test for Linux to make sure we're on Linux
LINUX_DISTRO="GENERIC"
OS_VERSION=`uname -r`
2010-07-05 05:20:42 +02:00
elif [ `uname -s` = "FreeBSD" ]
then
LINUX_DISTRO="FreeBSD"
OS_VERSION=`uname -r`
LINUX=NO
2009-08-11 18:26:09 +02:00
else
2009-09-21 22:26:23 +02:00
# Default to Linux is false, test for real Linux above - that way we don't assume we can just plunk down files everywhere
LINUX_DISTRO=`uname -s`
OS_VERSION=`uname -r`
2009-09-22 12:38:53 +02:00
LINUX=NO
2008-06-19 16:53:10 +02:00
fi
2009-09-22 12:38:53 +02:00
echo "$LINUX_DISTRO:$OS_VERSION:$LINUX"
2009-08-11 18:26:09 +02:00
}
2008-06-19 16:53:10 +02:00
2009-04-18 14:37:18 +02:00
2009-08-11 18:26:09 +02:00
install () {
2009-04-18 14:37:18 +02:00
2009-12-16 19:15:25 +01:00
perl Makefile.PL > output 2>&1 #&& sleep 2 && cat output | grep "found" | wc -l
2009-08-11 18:26:09 +02:00
DEPENDENCIAS=`cat output | grep "found" | wc -l`
2011-10-26 19:11:13 +02:00
FORCE=0
if [ ! -z "$SECOPT" ]
then
if [ "$SECOPT" == "--force" ]
then
FORCE=1
fi
fi
if [ $DEPENDENCIAS -gt 0 ] && [ $FORCE == 0 ]
2008-07-08 20:52:57 +02:00
then
2009-08-11 18:26:09 +02:00
echo "You are missing the following dependencies"
echo " "
cat output | awk -F ": prerequisite" '{print $2}' | awk -F " " '{print $1}'
2010-10-07 17:09:04 +02:00
echo "The complete installation guide is at: http://openideas.info/wiki/index.php?title=Pandora"
2009-08-11 18:26:09 +02:00
echo " "
echo "Debian-based distribution do:"
2011-09-12 12:07:22 +02:00
echo " # apt-get install snmp snmpd libio-socket-inet6-perl libsocket6-perl libxml-simple-perl libxml-twig-perl libnetaddr-ip-perl libdbi-perl libsnmp-perl libnetaddr-ip-perl libhtml-parser-perl wmi-client xprobe2 snmp-mibs-downloader"
2009-08-11 18:26:09 +02:00
echo " "
2009-12-18 19:22:33 +01:00
echo "For CentOS / RHEL do: "
2009-08-11 18:26:09 +02:00
echo " "
2011-08-30 17:32:39 +02:00
echo " # yum install perl-XML-Simple* perl-XML-Twig perl-IO-Socket* perl-Socket6 perl-Time-modules* perl-NetAddr-IP* perl-DateTime* perl-ExtUtils perl-DBI perl-SNMP nmap "
2009-12-18 19:22:33 +01:00
echo " "
echo "For OpenSUSE / SLES do : "
echo " "
2011-08-30 17:32:39 +02:00
echo " # zypper install nmap perl-DBD-mysql perl-DBI perl-HTML-Parser
perl-HTML-Encoding perl-HTML-Tree perl-NetAddr-IP perl-IO-Socket-INET6 perl-Socket6
2011-08-25 20:24:08 +02:00
perl-TimeDate perl-XML-Simple perl-XML-Twig perl-libwww-perl mysql-client perl-SNMP"
2009-08-11 18:26:09 +02:00
echo " "
2010-10-07 17:09:04 +02:00
echo " You also will need to install (optionally) xprobe2 and wmiclient from rpm (download from our website)"
2009-11-08 02:38:04 +01:00
echo " "
2010-07-05 05:20:42 +02:00
echo "For FreeBSD do : "
echo " "
2011-08-10 06:36:03 +02:00
echo " Install perl5.8 or later from ports with thread enabled."
2010-07-05 05:20:42 +02:00
echo " (perl-5.8.x.pkg can not be used.)"
echo " # cd /usr/ports/lang/perl5.8"
echo " # make config"
echo " -> Enable THREADS."
echo " # make"
echo " # make install"
echo " "
echo " Install following tools from ports. Don't use packages."
2011-08-30 17:32:39 +02:00
echo " Recommended: p5-DBI p5-NetAddr-IP p5-XML-Simple p5-XML-Twig p5-HTML-Parser p5-Net-SNMP p5-SNMP p5-DBD-mysql p5-Socket6 p5-IO-Socket-INET6"
2010-07-05 05:20:42 +02:00
echo " Optional: nmap xprobe"
echo " "
2009-08-11 18:26:09 +02:00
echo "To get it from source through CPAN do"
echo " "
2011-08-30 17:32:39 +02:00
echo " $ cpan Time::Local DBI SNMP Socket6 XML::Simple XML::Twig IO::Socket Time::HiRes NetAddr::IP HTML::Entities IO::Socket::INET6"
2009-08-11 18:26:09 +02:00
echo " "
rm output
2008-07-08 20:52:57 +02:00
else
2009-09-22 12:38:53 +02:00
# This returns a multiple value string, separated with ":" -> $LINUX_DISTRO:$OS_VERSION:$LINUX
GET_DISTRO="`get_distro`"
DISTRO=`echo $GET_DISTRO | cut -f 1 -d ":"`
OS_VERSION=`echo $GET_DISTRO | cut -f 2 -d ":"`
LINUX=`echo $GET_DISTRO | cut -f 3 -d ":"`
2009-08-11 18:26:09 +02:00
2010-07-05 05:20:42 +02:00
if [ "$DISTRO" = "UBUNTU" ]
2009-08-11 18:26:09 +02:00
then
echo "UBUNTU distribution detected"
2010-07-05 05:20:42 +02:00
elif [ "$DISTRO" = "SUSE" ]
2009-08-11 18:26:09 +02:00
then
echo "SUSE distribution detected"
2010-07-05 05:20:42 +02:00
elif [ "$DISTRO" = "FreeBSD" ]
then
echo "FreeBSD detected"
PANDORA_SPOOL=/var/spool/pandora
PANDORA_HOME=/usr/local/share/pandora_server
PANDORA_CFG_DIR=/usr/local/etc/pandora
PANDORA_LOG=/var/log/pandora
PANDORA_SERVER=/usr/local/etc/rc.d/pandora_server
TENTACLE_SERVER=/usr/local/etc/rc.d/tentacle_server
PANDORA_CFG_FILE=/usr/local/etc/pandora/pandora_server.conf
2009-08-11 18:26:09 +02:00
fi
echo "Installing binaries and libraries"
make
make install
2009-12-18 19:22:33 +01:00
echo "Checking binaries at /usr/local/bin -> /usr/bin"
if [ ! -e "/usr/bin/pandora_server" ]
then
if [ ! -e "/usr/local/bin/pandora_server" ]
then
echo "ERROR compiling Pandora FMS Server from sources. Aborting"
exit 1
fi
2010-07-05 05:20:42 +02:00
if [ "$DISTRO" != "FreeBSD" ]
then
ln -s /usr/local/bin/pandora_server /usr/bin
ln -s /usr/local/bin/pandora_exec /usr/bin
fi
2009-12-18 19:22:33 +01:00
fi
2009-08-11 18:26:09 +02:00
echo "Creating common Pandora FMS directories"
2010-07-05 05:20:42 +02:00
id pandora 2> /dev/null
2009-08-11 18:26:09 +02:00
if [ $? -eq 0 ]; then
echo " "
echo "User pandora does exist, make sure the SSH directories are correct"
else
2009-09-21 22:26:23 +02:00
echo "Are you sure we can create a standard 'pandora' user locally? [y/N]"
read AREYOUSURE
2010-07-05 05:20:42 +02:00
if [ "$AREYOUSURE" = "y" ]; then
if [ "$DISTRO" = "FreeBSD" ]
then
echo "pandora:41121:::::Pandora FMS:/home/pandora:/usr/sbin/nologin:" | adduser -f - -w no 2> /dev/null
else
useradd pandora
mkdir /home/pandora 2> /dev/null
mkdir /home/pandora/.ssh 2> /dev/null
chown -R pandora /home/pandora
fi
2009-09-21 22:26:23 +02:00
else
2010-11-22 19:44:31 +01:00
echo "Please create the 'pandora' user manually according to your authentication scheme, then start again the installation"
2009-09-21 22:26:23 +02:00
echo "Aborting..."
exit 1
fi
2009-08-11 18:26:09 +02:00
fi
2009-09-21 22:26:23 +02:00
2009-12-07 15:57:03 +01:00
mkdir $PANDORA_SPOOL 2> /dev/null
mkdir $PANDORA_SPOOL/data_in 2> /dev/null
2010-09-23 14:06:15 +02:00
chmod 770 $PANDORA_SPOOL/data_in
2009-12-07 15:57:03 +01:00
mkdir $PANDORA_SPOOL/data_in/conf 2> /dev/null
2011-08-10 12:45:24 +02:00
chmod 770 $PANDORA_SPOOL/data_in/conf
2009-12-07 15:57:03 +01:00
mkdir $PANDORA_SPOOL/data_in/md5 2> /dev/null
2010-07-19 12:49:40 +02:00
chmod 770 $PANDORA_SPOOL/data_in/md5
2010-07-19 12:17:17 +02:00
mkdir $PANDORA_SPOOL/data_in/collections 2> /dev/null
2010-07-19 12:49:40 +02:00
chmod 770 $PANDORA_SPOOL/data_in/collections
2012-01-24 19:46:00 +01:00
mkdir $PANDORA_SPOOL/data_in/netflow 2> /dev/null
chmod 770 $PANDORA_SPOOL/data_in/netflow
2009-12-18 19:22:33 +01:00
mkdir $PANDORA_LOG 2> /dev/null
2009-08-11 18:26:09 +02:00
echo "Giving proper permission to /var/spool/pandora"
2012-04-18 11:21:28 +02:00
IDGROUP=`id -g www-data 2> /dev/null`
2009-09-21 22:26:23 +02:00
if [ $? -eq 0 ]
2009-08-11 18:26:09 +02:00
then
2012-04-18 11:21:28 +02:00
GROUPNAME=`cat /etc/group | grep ":$IDGROUP:" | awk -F":" '{print $1}'`
chown -R pandora:$GROUPNAME $PANDORA_SPOOL
2009-08-11 18:26:09 +02:00
else
2012-04-18 11:21:28 +02:00
IDGROUP=`id -g wwwrun 2> /dev/null`
2009-09-21 22:26:23 +02:00
if [ $? -eq 0 ]
then
2012-04-18 11:21:28 +02:00
GROUPNAME=`cat /etc/group | grep ":$IDGROUP:" | awk -F":" '{print $1}'`
chown -R pandora:$GROUPNAME $PANDORA_SPOOL
2009-09-21 22:26:23 +02:00
else
2012-04-18 11:21:28 +02:00
IDGROUP=`id -g www 2> /dev/null`
2009-09-21 22:26:23 +02:00
if [ $? -eq 0 ]
then
2012-04-18 11:21:28 +02:00
GROUPNAME=`cat /etc/group | grep ":$IDGROUP:" | awk -F":" '{print $1}'`
chown -R pandora:$GROUPNAME $PANDORA_SPOOL
2009-09-21 22:26:23 +02:00
else
2012-04-18 11:21:28 +02:00
IDGROUP=`id -g apache 2> /dev/null`
2011-09-22 08:08:19 +02:00
if [ $? -eq 0 ]
then
2012-04-18 11:21:28 +02:00
GROUPNAME=`cat /etc/group | grep ":$IDGROUP:" | awk -F":" '{print $1}'`
chown -R pandora:$GROUPNAME $PANDORA_SPOOL
2011-09-22 08:08:19 +02:00
else
echo "No web server user found, some functionality might not perform correctly"
chown -R pandora:root $PANDORA_SPOOL
fi
2009-09-21 22:26:23 +02:00
fi
fi
2009-08-11 18:26:09 +02:00
fi
2009-09-21 22:26:23 +02:00
2010-07-05 05:20:42 +02:00
echo "Creating setup directory in $PANDORA_CFG_DIR"
2009-12-07 15:57:03 +01:00
mkdir $PANDORA_CFG_DIR 2> /dev/null
if [ -e $PANDORA_CFG_FILE ]
2009-08-11 18:26:09 +02:00
then
OLDFILENAMETMP=`date +"%Y-%m-%d"`
echo "Old installation detected, backing up pandora_server.conf.$ODFILENAMETMP"
2009-12-07 15:57:03 +01:00
mv $PANDORA_CFG_FILE $PANDORA_CFG_FILE.$OLDFILENAMETMP
2009-08-11 18:26:09 +02:00
fi
2010-07-05 05:20:42 +02:00
if [ "$DISTRO" = "FreeBSD" ]
then
echo cp FreeBSD/pandora_server.conf $PANDORA_CFG_DIR
cp FreeBSD/pandora_server.conf $PANDORA_CFG_DIR
else
echo cp conf/pandora_server.conf $PANDORA_CFG_DIR
cp conf/pandora_server.conf $PANDORA_CFG_DIR
fi
2009-12-07 15:57:03 +01:00
chmod 770 $PANDORA_CFG_FILE
2010-05-11 19:02:26 +02:00
echo "Installing Pandora Server manual"
2010-07-05 05:20:42 +02:00
if [ "$DISTRO" = "FreeBSD" ]
then
cp man/man1/pandora_server.1.gz /usr/local/man/man1
else
cp man/man1/pandora_server.1.gz /usr/share/man/man1
fi
2009-08-11 18:26:09 +02:00
2010-07-05 05:20:42 +02:00
if [ "$LINUX" = "YES" ]
2009-08-11 18:26:09 +02:00
then
2009-09-21 22:26:23 +02:00
echo "Copying the daemon script into /etc/init.d/pandora_server"
cp util/pandora_server /etc/init.d/
2010-07-05 05:20:42 +02:00
if [ "$DISTRO" = "UBUNTU" ] || [ "$DISTRO" = "DEBIAN" ]
2009-09-21 22:26:23 +02:00
then
2009-12-18 19:22:33 +01:00
2009-09-21 22:26:23 +02:00
echo "Linking startup script to /etc/rc2.d"
2009-12-18 19:22:33 +01:00
update-rc.d pandora_server defaults
2009-09-21 22:26:23 +02:00
else
2010-07-05 05:20:42 +02:00
if [ "$DISTRO" = "SUSE" ]
2009-11-08 02:38:04 +01:00
then
echo "Creating startup daemons"
insserv pandora_server
else
# Pandora FMS Server install (Other Distros)
INITLV=`cat /etc/inittab | grep "[0-9]\:initdefault" | cut -f 2 -d ":"`
if [ -z "$INITLV" ]
then
INITLV=2
fi
echo "Linking startup script to /etc/rc.d/rc$INITLV.d"
2009-12-07 15:57:03 +01:00
ln -s $PANDORA_SERVER /etc/rc.d/rc$INITLV.d/S90pandora_server
2009-11-08 02:38:04 +01:00
fi
2009-09-21 22:26:23 +02:00
fi
2010-07-05 05:20:42 +02:00
else
if [ "$DISTRO" = "FreeBSD" ]
then
echo "Copying the daemon script into $PANDORA_SERVER"
cp FreeBSD/pandora_server $PANDORA_SERVER
chmod 555 $PANDORA_SERVER
fi
2009-08-11 18:26:09 +02:00
fi
2009-09-21 22:26:23 +02:00
if [ -d /etc/logrotate.d ]; then
echo "Creating logrotate.d entry for Pandora FMS log management"
cp util/pandora_logrotate /etc/logrotate.d/pandora
else
echo "Please add a log rotation schedule manually to your log rotation daemon (if any)"
fi
2009-09-22 12:38:53 +02:00
2010-07-05 05:20:42 +02:00
if [ "$LINUX" = "YES" ]
2009-08-11 18:26:09 +02:00
then
2009-09-21 22:26:23 +02:00
if [ "$SECOPT" != "--no-tentacle" ]
2009-08-11 18:26:09 +02:00
then
2010-07-05 05:20:42 +02:00
if [ "$DISTRO" = "UBUNTU" ] || [ "$DISTRO" = "DEBIAN" ]
2009-09-21 22:26:23 +02:00
then
# Tentacle server install (Ubuntu)
2009-12-18 19:22:33 +01:00
echo "Installing tentacle server"
cp bin/tentacle_server /usr/bin
2011-02-22 18:04:21 +01:00
chown pandora /usr/bin/tentacle_server
2009-12-07 15:57:03 +01:00
cp util/tentacle_serverd $TENTACLE_SERVER
2010-11-22 19:44:31 +01:00
update-rc.d tentacle_serverd defaults
2009-09-21 22:26:23 +02:00
else
2010-07-05 05:20:42 +02:00
if [ "$DISTRO" = "SUSE" ]
2009-11-08 02:38:04 +01:00
then
echo "Creating Tentacle startup daemon"
2009-12-18 19:22:33 +01:00
cp bin/tentacle_server /usr/bin
2011-02-22 18:04:21 +01:00
chown pandora /usr/bin/tentacle_server
2009-11-08 02:38:04 +01:00
cp util/tentacle_serverd /etc/init.d/tentacle_serverd
insserv tentacle_serverd
else
# Tentacle server install (Other Distros)
echo "Installing tentacle server in /etc/rc.d/rc$INITLV.d/S80tentacle_serverd"
2009-12-18 19:22:33 +01:00
cp bin/tentacle_server /usr/bin
2011-02-22 18:04:21 +01:00
chown pandora /usr/bin/tentacle_server
2009-11-08 02:38:04 +01:00
cp util/tentacle_serverd /etc/init.d/tentacle_serverd
2009-12-07 15:57:03 +01:00
ln -s $TENTACLE_SERVER /etc/rc.d/rc$INITLV.d/S80tentacle_serverd
2009-11-08 02:38:04 +01:00
fi
2009-09-21 22:26:23 +02:00
fi
2010-05-12 16:52:58 +02:00
echo "Installing Tentacle Server manual"
cp man/man1/tentacle_server.1.gz /usr/share/man/man1
2009-08-11 18:26:09 +02:00
fi
2010-07-05 05:20:42 +02:00
else
if [ "$SECOPT" != "--no-tentacle" ]
then
if [ "$DISTRO" = "FreeBSD" ]
then
echo "Installing tentacle server"
cp bin/tentacle_server /usr/local/bin
2011-02-22 18:04:21 +01:00
chown pandora /usr/local/bin/tentacle_server
2010-07-05 05:20:42 +02:00
cp FreeBSD/tentacle_server $TENTACLE_SERVER
chmod 555 $TENTACLE_SERVER
echo "Installing Tentacle Server manual"
cp man/man1/tentacle_server.1.gz /usr/local/man/man1
fi
fi
2009-08-11 18:26:09 +02:00
fi
2010-02-23 18:49:05 +01:00
2010-07-05 05:20:42 +02:00
echo "Creating Pandora FMS distribution directory in $PANDORA_HOME"
2009-12-07 15:57:03 +01:00
mkdir $PANDORA_HOME 2> /dev/null
cp -R util $PANDORA_HOME
2009-09-21 22:26:23 +02:00
2009-08-11 18:26:09 +02:00
if [ -d /etc/cron.daily ]
then
2009-11-06 20:48:48 +01:00
echo "Creating the Cron script to run daily Pandora DB tool"
2009-10-13 21:06:17 +02:00
echo "#!/bin/bash" > /etc/cron.daily/pandora_db
echo "perl /usr/share/pandora_server/util/pandora_db.pl /etc/pandora/pandora_server.conf" >> /etc/cron.daily/pandora_db
chmod +x /etc/cron.daily/pandora_db
2009-08-11 18:26:09 +02:00
else
2010-07-05 05:20:42 +02:00
if [ "$DISTRO" = "FreeBSD" ]
then
grep pandora_db.pl /etc/crontab > /dev/null 2>&1
if [ $? -ne 0 ]
then
echo "# Pandora FMS" >> /etc/crontab
echo "2 0 * * * root perl /usr/local/share/pandora_server/util/pandora_db.pl /usr/local/etc/pandora/pandora_server.conf" >> /etc/crontab
else
echo "The crontab for pandora_db.pl is already configured."
fi
else
echo "You're probably not using cron for automatic scheduling. You should schedule the following command to run frequently (daily) on your master server:"
echo " perl /usr/share/pandora_server/util/pandora_db.pl /etc/pandora/pandora_server.conf"
fi
2009-08-11 18:26:09 +02:00
fi
2009-11-06 20:48:48 +01:00
echo
2010-07-05 05:20:42 +02:00
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."
2009-11-06 20:48:48 +01:00
echo "After setting password you can start your Pandora FMS Server!!"
2009-08-11 18:26:09 +02:00
rm output
2009-11-08 02:38:04 +01:00
if [ -d "/etc/logrotate.d" ]
then
echo "Managing Pandora FMS logs with logrotate (Distro independent)"
cp -aRf util/pandora_logrotate /etc/logrotate.d/pandora
fi
2010-07-05 05:20:42 +02:00
if [ "$DISTRO" = "FreeBSD" ]
then
echo " "
echo "Define 'pandora_server_enable=\"YES\"' in /etc/rc.conf to enable pandora server daemon."
echo "Define 'tentacle_server_enable=\"YES\"' in /etc/rc.conf to enable tentacle server daemon."
fi
2008-07-08 20:52:57 +02:00
fi
2008-04-07 00:11:16 +02:00
}
2010-07-05 05:20:42 +02:00
uninstall_freebsd () {
PANDORA_SPOOL=/var/spool/pandora
PANDORA_HOME=/usr/local/share/pandora_server
PANDORA_CFG_DIR=/usr/local/etc/pandora
PANDORA_LOG=/var/log/pandora
PANDORA_SERVER=/usr/local/etc/rc.d/pandora_server
TENTACLE_SERVER=/usr/local/etc/rc.d/tentacle_server
PANDORA_CFG_FILE=/usr/local/etc/pandora/pandora_server.conf
TMP_CRONTAB=/tmp/crontab.tmp
echo "Removing Pandora Servers"
rm -Rf $PANDORA_SPOOL/data_in/
echo "If the user Pandora is not being used for any other operations, please delete using the following commands:"
echo " rmuser pandora"
rm -Rf $PANDORA_LOG 2> /dev/null
rm -Rf $PANDORA_CFG_FILE 2> /dev/null
rm -Rf $PANDORA_SERVER 2> /dev/null
rm -Rf $PANDORA_HOME
rm -Rf $PANDORA_SERVER
rm -Rf $TENTACLE_SERVER
cat /etc/crontab | grep -v "Pandora FMS" | grep -v "pandora_db.pl" > $TMP_CRONTAB
cp $TMP_CRONTAB /etc/crontab
rm $TMP_CRONTAB
echo "Done"
exit
}
2008-04-07 00:11:16 +02:00
uninstall () {
2009-12-07 15:57:03 +01:00
GET_DISTRO="`get_distro`"
DISTRO=`echo $GET_DISTRO | cut -f 1 -d ":"`
2008-09-08 18:12:57 +02:00
if [ "`uname -s`" != "Linux" ]; then
2010-07-05 05:20:42 +02:00
if [ "$DISTRO" = "FreeBSD" ]
then
uninstall_freebsd
else
2008-09-08 18:12:57 +02:00
echo "This is not a Linux-based distro. Uninstaller is currently not working for your OS"
2010-07-05 05:20:42 +02:00
fi
2008-07-08 20:52:57 +02:00
fi
echo "Removing Pandora Servers"
2010-07-20 14:01:47 +02:00
if [ -d $PANDORA_SPOOL/data_out ]; then
rm -Rf $PANDORA_SPOOL/data_in
else
rm -Rf $PANDORA_SPOOL
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:"
2009-12-16 19:15:25 +01:00
echo " userdel pandora"
echo " rm -Rf /home/pandora/"
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
2009-12-16 19:15:25 +01:00
rm -Rf $PANDORA_LOG 2> /dev/null
rm -Rf $PANDORA_CFG_FILE 2> /dev/null
rm -Rf $PANDORA_SERVER 2> /dev/null
2008-08-22 20:02:23 +02:00
rm -Rf /usr/bin/pandora_server 2> /dev/null
2009-12-18 19:22:33 +01:00
rm -Rf /usr/bin/pandora_exec 2> /dev/null
2009-12-07 15:57:03 +01:00
rm -Rf $PANDORA_HOME
2009-10-13 21:06:17 +02:00
rm -Rf /etc/cron.daily/pandora_db
2009-11-08 02:38:04 +01:00
rm -Rf /etc/logrotate.d/pandora
2010-07-05 05:20:42 +02:00
if [ "$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
fi
2009-12-16 19:15:25 +01:00
rm -Rf /etc/rc2.d/S90pandora_server 2> /dev/null
rm -Rf /etc/rc.d/rc3.d/S90pandora_server 2> /dev/null
2010-06-09 13:34:49 +02:00
rm -Rf /usr/share/man/man1/pandora_server.1.gz 2>/dev/null
rm -Rf /usr/share/man/man1/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)"
2009-04-20 17:14:04 +02:00
echo " "
2008-04-07 00:11:16 +02:00
}
# Script banner at start
echo " "
2012-04-18 19:04:53 +02:00
echo "Pandora FMS 5.0dev Server Installer (c) 2008-2012 Artica ST"
2009-04-20 17:14:04 +02:00
echo "This program is licensed under GPL2 Terms. http://pandorafms.org"
2008-04-07 00:11:16 +02:00
echo " "
case "$MODE" in
'--install')
2009-12-16 19:15:25 +01:00
install
exit
;;
2008-04-07 00:11:16 +02:00
'--uninstall')
2009-12-16 19:15:25 +01:00
uninstall
exit
;;
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