2010-06-29 03:19:44 +02:00
|
|
|
#!/bin/sh
|
2009-08-11 19:14:21 +02:00
|
|
|
|
2015-11-13 04:02:03 +01:00
|
|
|
# Pandora FMS Console Installer (c) 2008-2015 Artica ST
|
|
|
|
# Linux/FreeBSD/NetBSD Version (generic), for SuSe, Debian/Ubuntu,
|
|
|
|
# RHEL/CentOS, Fedora, FreeBSD and NetBSD 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.
|
|
|
|
# **********************************************************************
|
|
|
|
|
2023-02-16 10:36:23 +01:00
|
|
|
PI_VERSION="7.0NG.769"
|
2009-08-11 19:14:21 +02:00
|
|
|
FORCE=0
|
2014-08-14 02:22:48 +02:00
|
|
|
DESTDIR=""
|
2009-08-11 19:14:21 +02:00
|
|
|
LOG_TIMESTAMP=`date +"%Y/%m/%d %H:%M:%S"`
|
|
|
|
MODE=$1
|
|
|
|
|
2014-08-14 02:22:48 +02:00
|
|
|
#
|
|
|
|
# set_global_vars
|
|
|
|
# Check platform and set DISTRO, OS_VERSION, WWWUSER, WWWGROUP, WWWROOT,
|
|
|
|
# PANDORA_HOME and PANDORA_HOME_GROUP.
|
|
|
|
#
|
|
|
|
set_global_vars () {
|
|
|
|
DISTRO="GENERIC"
|
2009-08-11 19:14:21 +02:00
|
|
|
|
2014-08-14 02:22:48 +02:00
|
|
|
case `uname -s` in
|
|
|
|
Linux)
|
|
|
|
# Get Linux Distro type and version
|
|
|
|
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" ]
|
2009-08-11 19:14:21 +02:00
|
|
|
then
|
|
|
|
OS_VERSION=`cat /etc/lsb-release | grep DISTRIB_RELEASE | cut -f 2 -d "="`
|
2014-08-14 02:22:48 +02:00
|
|
|
DISTRO=UBUNTU
|
2009-08-11 19:14:21 +02:00
|
|
|
OS_VERSION="UBUNTU $OS_VERSION"
|
2014-08-14 02:22:48 +02:00
|
|
|
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
|
|
|
|
elif [ -f "/etc/redhat-release" ]
|
|
|
|
then
|
|
|
|
DISTRO=RHEL_CENTOS
|
2009-08-11 19:14:21 +02:00
|
|
|
fi
|
2014-08-14 02:22:48 +02:00
|
|
|
case $DISTRO in
|
|
|
|
SUSE)
|
|
|
|
WWWUSER=wwwrun
|
|
|
|
WWWGROUP=www
|
|
|
|
PANDORA_HOME_GROUP=root
|
|
|
|
WWWROOT=/srv/www/htdocs
|
|
|
|
;;
|
|
|
|
UBUNTU|DEBIAN)
|
|
|
|
WWWUSER=www-data
|
|
|
|
WWWGROUP=www-data
|
|
|
|
WWWROOT=/var/www
|
|
|
|
;;
|
|
|
|
FEDORA|RHEL_CENTOS)
|
|
|
|
WWWUSER=apache
|
|
|
|
WWWGROUP=apache
|
|
|
|
WWWROOT=/var/www/html
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
;;
|
|
|
|
FreeBSD)
|
|
|
|
DISTRO=FreeBSD
|
|
|
|
WWWUSER=www
|
|
|
|
WWWGROUP=www
|
|
|
|
WWWROOT=/usr/local/www
|
2009-08-11 19:14:21 +02:00
|
|
|
|
2014-08-14 02:22:48 +02:00
|
|
|
local apache
|
|
|
|
for apache in apache24 apache22
|
|
|
|
do
|
|
|
|
[ ! -d $WWWROOT/$apache ] && continue
|
|
|
|
WWWROOT=$WWWROOT/$apache/data
|
|
|
|
break
|
|
|
|
done
|
|
|
|
;;
|
|
|
|
NetBSD)
|
|
|
|
DISTRO=NetBSD
|
|
|
|
WWWUSER=www
|
|
|
|
WWWGROUP=www
|
|
|
|
WWWROOT=/usr/pkg/share/httpd/htdocs
|
|
|
|
;;
|
|
|
|
esac
|
2010-06-29 03:19:44 +02:00
|
|
|
|
2014-08-14 02:22:48 +02:00
|
|
|
# backward compatible defaults (Assuming SUSE)
|
|
|
|
if [ "$DISTRO" = GENERIC ]
|
2010-11-25 20:26:54 +01:00
|
|
|
then
|
2014-08-14 02:22:48 +02:00
|
|
|
WWWUSER=wwwrun
|
|
|
|
WWWGROUP=www
|
|
|
|
WWWROOT=/srv/www/htdocs
|
|
|
|
PANDORA_HOME_GROUP=root
|
2010-06-29 03:19:44 +02:00
|
|
|
fi
|
2014-08-14 02:22:48 +02:00
|
|
|
# Use WWWGROUP as default for PANDORA_HOME_GROUP
|
|
|
|
: ${PANDORA_HOME_GROUP:=$WWWGROUP}
|
|
|
|
|
|
|
|
OS_VERSION=`uname -r`
|
|
|
|
PANDORA_HOME="$WWWROOT/pandora_console"
|
|
|
|
}
|
|
|
|
|
|
|
|
uninstall () {
|
|
|
|
set_global_vars
|
2010-06-29 03:19:44 +02:00
|
|
|
|
2010-06-06 23:56:42 +02:00
|
|
|
echo "Removing Pandora FMS Console"
|
|
|
|
rm -Rf $PANDORA_HOME
|
2015-11-02 16:52:30 +01:00
|
|
|
rm -f $DESTDIR/etc/logrotate.d/pandora_console
|
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 () {
|
2014-08-14 02:22:48 +02:00
|
|
|
set_global_vars
|
2009-08-11 19:14:21 +02:00
|
|
|
|
|
|
|
OLDFILENAMETMP=`date +"%Y-%m-%d"`
|
2014-08-14 02:22:48 +02:00
|
|
|
PANDORA_CONF=$PANDORA_HOME/include/config.php
|
2009-08-11 19:14:21 +02:00
|
|
|
|
2010-06-29 03:19:44 +02:00
|
|
|
echo "Detecting operating system: $DISTRO"
|
2009-08-11 19:14:21 +02:00
|
|
|
|
2014-08-14 02:22:48 +02:00
|
|
|
if [ -f $DESTDIR$PANDORA_HOME ] && [ "$FORCE" = "0" ]
|
2010-06-06 23:56:42 +02:00
|
|
|
then
|
|
|
|
echo "Seems that default dir already exists. Please use --force to"
|
2014-08-14 02:22:48 +02:00
|
|
|
echo "force installer to install on $DESTDIR$PANDORA_HOME"
|
2010-06-06 23:56:42 +02:00
|
|
|
exit
|
|
|
|
else
|
2014-08-14 02:22:48 +02:00
|
|
|
echo "Checking default dir $DESTDIR$PANDORA_HOME..."
|
2010-06-06 23:56:42 +02:00
|
|
|
fi
|
2009-08-11 19:14:21 +02:00
|
|
|
|
2014-08-14 02:22:48 +02:00
|
|
|
# Check and create 'pandora' user if needed
|
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"
|
2014-08-14 02:22:48 +02:00
|
|
|
elif [ "$DESTDIR" ]
|
|
|
|
then
|
|
|
|
# don't create user with "fakeroot" installation
|
|
|
|
echo "User 'pandora' does not exist. All chown operations may fail."
|
|
|
|
echo "You should manualy set proper ownership to $DESTDIR$PANDORA_HOME and $DESTDIR$PANDORA_SPOOL if it's required."
|
|
|
|
echo
|
2009-08-11 19:14:21 +02:00
|
|
|
else
|
2014-08-14 02:22:48 +02:00
|
|
|
echo "Are you sure we can create a standard 'pandora' user locally? [y/N]"
|
|
|
|
read AREYOUSURE
|
|
|
|
if [ "$AREYOUSURE" != "y" ]
|
|
|
|
then
|
|
|
|
echo "Please create the 'pandora' user manually according to your authentication scheme, then start again the installation"
|
|
|
|
echo "Aborting..."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
# creating 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
|
|
|
|
|
2014-08-14 02:22:48 +02:00
|
|
|
# Create directories
|
|
|
|
echo "Creating Pandora FMS Console home directory at $DESTDIR$PANDORA_HOME ..."
|
|
|
|
mkdir -p $DESTDIR$PANDORA_HOME 2> /dev/null
|
|
|
|
|
|
|
|
# Copying Pandora FMS console
|
|
|
|
echo "Copying Pandora FMS Console to $DESTDIR$PANDORA_HOME.."
|
|
|
|
cp -R * $DESTDIR$PANDORA_HOME
|
|
|
|
chmod -R u+rwX,g+rX,g-w,o-rwx $DESTDIR$PANDORA_HOME
|
|
|
|
|
|
|
|
# prepare /var/spool/pandora/data_in and sub directories
|
|
|
|
for subdir in collections conf md5 netflow
|
|
|
|
do
|
|
|
|
[ ! -d $DESTDIR/var/spool/pandora/data_in/$subdir ] && mkdir -p $DESTDIR/var/spool/pandora/data_in/$subdir
|
|
|
|
done
|
2009-08-11 19:14:21 +02:00
|
|
|
|
2015-11-02 16:52:30 +01:00
|
|
|
if [ -d /etc/logrotate.d ]
|
|
|
|
then
|
|
|
|
[ -d $DESTDIR/etc/logrotate.d ] && mkdir -p $DESTDIR/etc/logrotate.d
|
|
|
|
echo "Creating logrotate.d entry for Pandora FMS log management"
|
2015-11-16 17:29:58 +01:00
|
|
|
case $DISTRO in
|
|
|
|
SUSE)
|
|
|
|
cp pandora_console_logrotate_suse $DESTDIR/etc/logrotate.d/pandora_console
|
|
|
|
;;
|
|
|
|
UBUNTU|DEBIAN)
|
|
|
|
cp pandora_console_logrotate_ubuntu $DESTDIR/etc/logrotate.d/pandora_console
|
|
|
|
;;
|
|
|
|
FEDORA|RHEL_CENTOS|GENERIC)
|
|
|
|
cp pandora_console_logrotate_centos $DESTDIR/etc/logrotate.d/pandora_console
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "Please add a log rotation schedule manually to your log rotation daemon (if any)"
|
|
|
|
;;
|
|
|
|
esac
|
2015-11-02 16:52:30 +01:00
|
|
|
else
|
|
|
|
echo "Please add a log rotation schedule manually to your log rotation daemon (if any)"
|
|
|
|
fi
|
|
|
|
|
2009-08-11 19:14:21 +02:00
|
|
|
#Ownership
|
2014-08-14 02:22:48 +02:00
|
|
|
chown -R $WWWUSER:$PANDORA_HOME_GROUP $DESTDIR$PANDORA_HOME 2> /dev/null
|
|
|
|
chown -R pandora:$WWWGROUP $DESTDIR/var/spool/pandora/ 2> /dev/null
|
2010-06-06 23:56:42 +02:00
|
|
|
|
|
|
|
echo "Setting secure permissions for Pandora FMS spool dir..."
|
2014-08-14 02:22:48 +02:00
|
|
|
chmod -R u+rwX,g+rwX,o-rwx $DESTDIR/var/spool/pandora/
|
2010-06-06 23:56:42 +02:00
|
|
|
|
|
|
|
echo "Done."
|
|
|
|
echo " "
|
2014-08-14 02:22:48 +02:00
|
|
|
echo "You have your Pandora FMS console installed on $DESTDIR$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 " "
|
2013-01-15 18:33:03 +01:00
|
|
|
echo " http://ip_address_of_this_server/pandora_console/install.php"
|
2010-06-06 23:56:42 +02:00
|
|
|
echo " "
|
2009-08-11 19:14:21 +02:00
|
|
|
echo " "
|
|
|
|
}
|
|
|
|
|
|
|
|
help () {
|
2014-08-14 02:22:48 +02:00
|
|
|
echo "Syntax":
|
|
|
|
echo
|
|
|
|
echo " ./pandora_console_install < --mode > [ --option ]"
|
|
|
|
echo " "
|
|
|
|
echo "Modes:"
|
|
|
|
echo
|
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"
|
2014-08-14 02:22:48 +02:00
|
|
|
echo " --uninstall To uninstall/remove Pandora FMS Console on this System"
|
|
|
|
echo
|
|
|
|
echo "Option:"
|
|
|
|
echo
|
|
|
|
echo " --destdir DIR Specify root directory for \"fakeroot\" installation"
|
|
|
|
echo
|
2009-08-11 19:14:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
# Script banner at start
|
|
|
|
echo " "
|
2015-11-13 04:02:03 +01:00
|
|
|
echo "Pandora FMS Console Installer $PI_VERSION $PI_BUILD (c) 2008-2015 ArticaST"
|
2009-08-11 19:14:21 +02:00
|
|
|
echo "This program is licensed under GPL2 Terms. http://pandorafms.com"
|
|
|
|
echo " "
|
|
|
|
|
2014-08-14 02:22:48 +02:00
|
|
|
# parse option
|
|
|
|
if [ "$2" = "--destdir" ]
|
|
|
|
then
|
|
|
|
if [ -z "$3" ]
|
|
|
|
then
|
|
|
|
echo '"--datadir" option requires an argument'
|
|
|
|
help
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
DESTDIR="$3"
|
|
|
|
fi
|
|
|
|
|
2009-08-11 19:14:21 +02:00
|
|
|
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
|
|
|
|
|