2010-06-29 03:19:44 +02:00
|
|
|
#!/bin/sh
|
2009-08-11 19:14:21 +02:00
|
|
|
|
2011-03-02 22:56:48 +01:00
|
|
|
# Pandora FMS Console Installer (c) 2008-2011 Artica ST
|
2011-01-14 13:33:31 +01:00
|
|
|
# Linux/FreeBSD Version (generic), for SuSe, Debian/Ubuntu, RHEL/CentOS,
|
|
|
|
# Fedora and FreeBSD only
|
2009-08-11 19:14:21 +02:00
|
|
|
# other Linux distros could not work properly without modifications
|
|
|
|
# Please see http://www.pandorafms.org
|
2011-03-02 22:56:48 +01:00
|
|
|
# v4.0dev Build 110203
|
2009-08-11 19:14:21 +02:00
|
|
|
# This code is licensed under GPL 2.0 license.
|
|
|
|
# **********************************************************************
|
|
|
|
|
2011-03-02 22:56:48 +01:00
|
|
|
PI_VERSION=4.0dev
|
2009-08-11 19:14:21 +02:00
|
|
|
FORCE=0
|
|
|
|
LOG_TIMESTAMP=`date +"%Y/%m/%d %H:%M:%S"`
|
|
|
|
MODE=$1
|
|
|
|
|
|
|
|
|
|
|
|
get_distro () {
|
|
|
|
|
2010-06-29 03:19:44 +02:00
|
|
|
OS_NAME=`uname -s`
|
|
|
|
|
2009-08-11 19:14:21 +02:00
|
|
|
# Get Linux Distro type and version
|
|
|
|
if [ -f "/etc/SuSE-release" ]
|
|
|
|
then
|
|
|
|
OS_VERSION=`cat /etc/SuSE-release | grep VERSION | cut -f 3 -d " "`
|
|
|
|
LINUX_DISTRO=SUSE
|
|
|
|
else
|
|
|
|
if [ -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"
|
|
|
|
else
|
|
|
|
if [ -f "/etc/debian_version" ]
|
|
|
|
then
|
|
|
|
OS_VERSION=`cat /etc/debian_version`
|
|
|
|
OS_VERSION="DEBIAN $OS_VERSION"
|
|
|
|
LINUX_DISTRO=DEBIAN
|
|
|
|
else
|
|
|
|
if [ -f "/etc/fedora-release" ]
|
|
|
|
then
|
|
|
|
OS_VERSION=`cat /etc/fedora-release | cut -f 4 -d " "`
|
|
|
|
OS_VERSION="FEDORA $OS_VERSION"
|
|
|
|
LINUX_DISTRO=FEDORA
|
|
|
|
else
|
2010-06-29 03:19:44 +02:00
|
|
|
if [ -f "/etc/redhat-release" ]
|
|
|
|
then
|
|
|
|
LINUX_DISTRO=RHEL_CENTOS
|
|
|
|
else
|
|
|
|
if [ "$OS_NAME" = "FreeBSD" ]
|
|
|
|
then
|
|
|
|
LINUX_DISTRO=FreeBSD
|
|
|
|
else
|
|
|
|
LINUX_DISTRO=GENERIC
|
|
|
|
fi
|
|
|
|
OS_VERSION=`uname -r`
|
|
|
|
fi
|
2009-08-11 19:14:21 +02:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
echo $LINUX_DISTRO
|
|
|
|
}
|
|
|
|
|
|
|
|
uninstall () {
|
2010-06-29 03:19:44 +02:00
|
|
|
DISTRO=`get_distro`
|
|
|
|
|
|
|
|
if [ "$DISTRO" = "UBUNTU" ]
|
2010-11-25 20:26:54 +01:00
|
|
|
then
|
2010-06-29 03:19:44 +02:00
|
|
|
PANDORA_HOME=/var/www/pandora
|
2010-11-25 20:26:54 +01:00
|
|
|
else
|
2010-06-29 03:19:44 +02:00
|
|
|
if [ "$DISTRO" = "RHEL_CENTOS" ]
|
|
|
|
then
|
|
|
|
PANDORA_HOME=/var/www/html/pandora_console
|
|
|
|
else
|
2011-01-14 13:33:31 +01:00
|
|
|
if [ "$DISTRO" = "FEDORA" ]
|
2010-06-29 03:19:44 +02:00
|
|
|
then
|
2011-01-14 13:33:31 +01:00
|
|
|
PANDORA_HOME=/var/www/html/pandora_console
|
2010-06-29 03:19:44 +02:00
|
|
|
else
|
2011-01-14 13:33:31 +01:00
|
|
|
if [ "$DISTRO" = "FreeBSD" ]
|
|
|
|
then
|
|
|
|
PANDORA_HOME="/usr/local/www/data/pandora_console /usr/local/www/apache22/data/pandora_console"
|
|
|
|
else
|
|
|
|
PANDORA_HOME=/srv/www/htdocs/pandora
|
|
|
|
fi
|
2010-06-29 03:19:44 +02:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2010-06-06 23:56:42 +02:00
|
|
|
echo "Removing Pandora FMS Console"
|
|
|
|
rm -Rf $PANDORA_HOME
|
2011-03-29 10:45:21 +02:00
|
|
|
echo "You need to drop manually pandora database from your Database server"
|
2010-06-06 23:56:42 +02:00
|
|
|
echo "Done"
|
2009-08-11 19:14:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
install () {
|
|
|
|
|
|
|
|
DISTRO=`get_distro`
|
|
|
|
OLDFILENAMETMP=`date +"%Y-%m-%d"`
|
|
|
|
|
2010-06-29 03:19:44 +02:00
|
|
|
if [ "$DISTRO" = "UBUNTU" ]
|
2009-08-11 19:14:21 +02:00
|
|
|
then
|
|
|
|
PANDORA_HOME=/var/www/pandora
|
|
|
|
PANDORA_CONF=$PANDORA_HOME/include/config.php
|
|
|
|
else
|
2010-06-29 03:19:44 +02:00
|
|
|
if [ "$DISTRO" = "RHEL_CENTOS" ]
|
|
|
|
then
|
|
|
|
PANDORA_HOME=/var/www/html/pandora_console
|
|
|
|
PANDORA_CONF=$PANDORA_HOME/include/config.php
|
|
|
|
else
|
2011-01-14 13:33:31 +01:00
|
|
|
if [ "$DISTRO" = "FEDORA" ]
|
2010-06-29 03:19:44 +02:00
|
|
|
then
|
2011-01-14 13:33:31 +01:00
|
|
|
PANDORA_HOME=/var/www/html/pandora_console
|
|
|
|
PANDORA_CONF=$PANDORA_HOME/include/config.php
|
|
|
|
else
|
|
|
|
if [ "$DISTRO" = "FreeBSD" ]
|
2010-06-29 03:19:44 +02:00
|
|
|
then
|
2011-01-14 13:33:31 +01:00
|
|
|
if [ -d /usr/local/www/apache22 ]
|
|
|
|
then
|
|
|
|
PANDORA_HOME=/usr/local/www/apache22/data/pandora_console
|
|
|
|
else
|
|
|
|
PANDORA_HOME=/usr/local/www/data/pandora_console
|
|
|
|
fi
|
|
|
|
PANDORA_CONF=$PANDORA_HOME/include/config.php
|
2010-06-29 03:19:44 +02:00
|
|
|
else
|
2011-01-14 13:33:31 +01:00
|
|
|
PANDORA_HOME=/srv/www/htdocs/pandora
|
|
|
|
PANDORA_CONF=$PANDORA_HOME/include/config.php
|
2010-06-29 03:19:44 +02:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
2009-08-11 19:14:21 +02:00
|
|
|
fi
|
|
|
|
|
2010-06-29 03:19:44 +02:00
|
|
|
echo "Detecting operating system: $DISTRO"
|
2009-08-11 19:14:21 +02:00
|
|
|
|
2010-06-06 23:56:42 +02:00
|
|
|
if [ -f $PANDORA_HOME ] && [ "$FORCE" = "0" ]
|
|
|
|
then
|
|
|
|
echo "Seems that default dir already exists. Please use --force to"
|
|
|
|
echo "force installer to install on $PANDORA_HOME"
|
|
|
|
exit
|
|
|
|
else
|
|
|
|
echo "Checking default dir $PANDORA_HOME..."
|
|
|
|
fi
|
2009-08-11 19:14:21 +02:00
|
|
|
|
2010-06-06 23:56:42 +02:00
|
|
|
# Create directories
|
|
|
|
echo "Creating Pandora FMS Console home directory at $PANDORA_HOME ..."
|
2010-06-29 03:19:44 +02:00
|
|
|
mkdir -p $PANDORA_HOME 2> /dev/null
|
2009-08-11 19:14:21 +02:00
|
|
|
|
2010-06-06 23:56:42 +02:00
|
|
|
# Copying Pandora FMS console
|
|
|
|
echo "Copying Pandora FMS Console to $PANDORA_HOME.."
|
|
|
|
cp -R * $PANDORA_HOME
|
|
|
|
chmod -R u+rwX,g+rX,g-w,o-rwx $PANDORA_HOME
|
2009-12-24 11:55:36 +01:00
|
|
|
|
2009-08-11 19:14:21 +02:00
|
|
|
|
|
|
|
# Creating 'pandora' user
|
2010-06-29 03:19:44 +02:00
|
|
|
id pandora 2> /dev/null
|
2009-08-11 19:14:21 +02:00
|
|
|
if [ $? -eq 0 ]; then
|
|
|
|
echo " "
|
|
|
|
echo "User pandora does exist, skipping this step"
|
|
|
|
else
|
|
|
|
echo "Creating 'pandora' user"
|
2010-06-29 03:19:44 +02:00
|
|
|
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
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ! -d /var/spool/pandora ]
|
|
|
|
then
|
|
|
|
mkdir -p /var/spool/pandora
|
2009-08-11 19:14:21 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
#Ownership
|
2010-06-29 03:19:44 +02:00
|
|
|
if [ "$DISTRO" = "UBUNTU" ]
|
2009-08-11 19:14:21 +02:00
|
|
|
then
|
|
|
|
chown -R www-data:root $PANDORA_HOME
|
|
|
|
chown -R pandora:www-data /var/spool/pandora/
|
2009-12-24 11:55:36 +01:00
|
|
|
else
|
2010-06-29 03:19:44 +02:00
|
|
|
if [ "$DISTRO" = "RHEL_CENTOS" ]
|
|
|
|
then
|
|
|
|
chown -R apache:apache $PANDORA_HOME
|
|
|
|
chown -R pandora:apache /var/spool/pandora/
|
2011-01-14 13:33:31 +01:00
|
|
|
else
|
|
|
|
if [ "$DISTRO" = "FEDORA" ]
|
2010-06-29 03:19:44 +02:00
|
|
|
then
|
2011-01-14 13:33:31 +01:00
|
|
|
chown -R apache:apache $PANDORA_HOME
|
|
|
|
chown -R pandora:apache /var/spool/pandora/
|
2010-06-29 03:19:44 +02:00
|
|
|
else
|
2011-01-14 13:33:31 +01:00
|
|
|
if [ "$DISTRO" = "FreeBSD" ]
|
|
|
|
then
|
|
|
|
chown -R www:www $PANDORA_HOME
|
|
|
|
chown -R pandora:www /var/spool/pandora/
|
|
|
|
else
|
|
|
|
# Assuming SUSE
|
|
|
|
chown -R wwwrun:root $PANDORA_HOME
|
|
|
|
chown -R pandora:www /var/spool/pandora/
|
|
|
|
fi
|
2010-06-29 03:19:44 +02:00
|
|
|
fi
|
|
|
|
fi
|
2009-08-11 19:14:21 +02:00
|
|
|
fi
|
2010-06-06 23:56:42 +02:00
|
|
|
|
|
|
|
echo "Setting secure permissions for Pandora FMS spool dir..."
|
|
|
|
chmod -R u+rwX,g+rwX,o-rwx /var/spool/pandora/
|
|
|
|
|
|
|
|
echo "Done."
|
|
|
|
echo " "
|
|
|
|
echo "You have your Pandora FMS console installed on $PANDORA_HOME."
|
2009-08-11 19:14:21 +02:00
|
|
|
echo " "
|
|
|
|
echo "Now you can setup your Pandora FMS console and install"
|
2011-03-29 10:45:21 +02:00
|
|
|
echo "database using a browser and point to: "
|
2009-08-11 19:14:21 +02:00
|
|
|
echo " "
|
2010-06-06 23:56:42 +02:00
|
|
|
echo " http://ip_address_of_this_server/pandora/install.php"
|
|
|
|
echo " "
|
2009-08-11 19:14:21 +02:00
|
|
|
echo " "
|
|
|
|
}
|
|
|
|
|
|
|
|
help () {
|
2010-06-06 23:56:42 +02:00
|
|
|
echo " --force-install To force installation if already installed on this system"
|
|
|
|
echo " --install To install Pandora FMS Console on this system"
|
|
|
|
echo " "
|
2009-08-11 19:14:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
# Script banner at start
|
|
|
|
echo " "
|
2011-03-29 10:45:21 +02:00
|
|
|
echo "Pandora FMS Console Installer $PI_VERSION (c) 2008-2011 ArticaST"
|
2009-08-11 19:14:21 +02:00
|
|
|
echo "This program is licensed under GPL2 Terms. http://pandorafms.com"
|
|
|
|
echo " "
|
|
|
|
|
|
|
|
case "$MODE" in
|
|
|
|
|
|
|
|
'--force-install')
|
2010-06-06 23:56:42 +02:00
|
|
|
FORCE=1
|
|
|
|
install
|
|
|
|
exit
|
|
|
|
;;
|
2009-08-11 19:14:21 +02:00
|
|
|
|
|
|
|
'--install')
|
2010-06-06 23:56:42 +02:00
|
|
|
install
|
|
|
|
exit
|
|
|
|
;;
|
2009-08-11 19:14:21 +02:00
|
|
|
|
|
|
|
'--uninstall')
|
2010-06-06 23:56:42 +02:00
|
|
|
uninstall
|
|
|
|
exit
|
|
|
|
;;
|
2009-08-11 19:14:21 +02:00
|
|
|
|
|
|
|
*)
|
2010-06-06 23:56:42 +02:00
|
|
|
help
|
2009-08-11 19:14:21 +02:00
|
|
|
esac
|
|
|
|
|