2009-11-03 18:18:52 +01:00
#!/bin/bash
2010-01-14 10:02:49 +01:00
get_distro () {
# Get Linux Distro type and version
# We assume we are on Linux unless told otherwise
LINUX=YES
if [ -f "/etc/SuSE-release" ]
then
OS_VERSION=`cat /etc/SuSE-release | grep VERSION | cut -f 3 -d " "`
LINUX_DISTRO=SUSE
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
elif [ `uname -s` == "Darwin" ]
then
# For future reference, Darwin doesn't have /etc/init.d but uses LaunchDaemons
LINUX_DISTRO="Darwin"
OS_VERSION=`uname -r`
LINUX=NO
elif [ `uname -s` == "AIX" ]
then
# For future reference, AIX doesn't have /etc/init.d
LINUX_DISTRO="AIX"
OS_VERSION=`uname -r`
LINUX=NO
elif [ `uname -s` == "SunOS" ]
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`
LINUX=NO
elif [ `uname -s` == "Linux" ]
then
# Test for Linux to make sure we're on Linux
LINUX_DISTRO="GENERIC"
OS_VERSION=`uname -r`
else
# 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`
LINUX=NO
fi
echo "$LINUX_DISTRO:$OS_VERSION:$LINUX"
}
2010-11-10 13:59:07 +01:00
echo "Linking pandora_exec..."
ln -s /usr/bin/pandora_exec.server /usr/bin/pandora_exec 2> /dev/null
2010-01-14 10:02:49 +01:00
echo "Creating common Pandora FMS directories"
useradd pandora 2> /dev/null
mkdir -p /home/pandora/.ssh 2> /dev/null
chown -R pandora:root /home/pandora
chmod 755 /usr/bin/tentacle_server
echo "Giving proper permission to /var/spool/pandora"
2011-02-21 13:09:27 +01:00
chown -R pandora:www-data /var/spool/pandora/
2010-01-14 10:02:49 +01:00
echo "Creating setup directory in /etc/pandora"
mkdir /etc/pandora 2> /dev/null
2010-06-08 16:41:18 +02:00
#Check if exist old conf file
2013-05-22 18:58:14 +02:00
if [ ! -e /etc/pandora/pandora_server.conf ]
2010-06-08 16:41:18 +02:00
then
2013-05-22 18:58:14 +02:00
cp /usr/share/pandora_server/conf/pandora_server.conf.new /etc/pandora/pandora_server.conf
chmod 600 /etc/pandora/pandora_server.conf
else
cp /usr/share/pandora_server/conf/pandora_server.conf.new /etc/pandora/pandora_server.conf.new
echo "Skipping creation of pandora_server.conf: there is already one."
2010-06-08 16:41:18 +02:00
fi
2010-01-14 10:02:49 +01:00
echo "Linking startup script to /etc/rc2.d"
update-rc.d pandora_server defaults
# Tentacle server install
echo "Installing tentacle server in /etc/rc2.d/S80tentacle_serverd"
update-rc.d tentacle_serverd defaults
2013-04-01 03:28:14 +02:00
if [ -d /etc/cron.hourly ]
2010-01-14 10:02:49 +01:00
then
2013-04-01 03:28:14 +02:00
echo "Create the Cron script to run hourly Pandora DB tool"
echo "#!/bin/bash" > /etc/cron.hourly/pandora_db
echo "perl /usr/share/pandora_server/util/pandora_db.pl /etc/pandora/pandora_server.conf" >> /etc/cron.hourly/pandora_db
chmod 750 /etc/cron.hourly/pandora_db
2010-01-14 10:02:49 +01:00
else
2013-04-01 03:28:14 +02:00
echo "You're probably not using cron for automatic scheduling. You should schedule the following command to run frequently (each hour) on your master server:"
2010-01-14 10:02:49 +01:00
echo " perl /usr/share/pandora_server/util/pandora_db.pl /etc/pandora/pandora_server.conf"
fi
echo "Please, now, edit the /etc/pandora/pandora_server.conf and launch the Pandora Server with /etc/init.d/Pandora ."