2007-04-19 20:37:57 +02:00
|
|
|
#!/bin/bash
|
2009-08-11 18:58:01 +02:00
|
|
|
|
|
|
|
# Pandora FMS Agent Installer (c) 2008-2009 Artica ST
|
|
|
|
# Linux Version (generic), for SuSe and Debian/Ubuntu only
|
|
|
|
# other Linux distros could not work properly without modifications
|
|
|
|
# Please see http://www.pandorafms.org
|
2009-11-29 14:35:16 +01:00
|
|
|
# v3.0.1 Build 091129
|
2007-04-21 22:05:35 +02:00
|
|
|
# This code is licensed under GPL 2.0 license.
|
2007-04-19 20:37:57 +02:00
|
|
|
# **********************************************************************
|
|
|
|
|
2009-08-11 18:58:01 +02:00
|
|
|
PI_VERSION=3.0
|
2007-04-19 20:37:57 +02:00
|
|
|
PANDORA_BIN=/usr/bin/pandora_agent
|
2007-06-12 11:32:54 +02:00
|
|
|
PANDORA_HOME=/usr/share/pandora_agent
|
2009-12-07 15:57:34 +01:00
|
|
|
PANDORA_TEMP=/var/spool/pandora/data_out
|
2007-04-19 20:37:57 +02:00
|
|
|
PANDORA_CFG=/etc/pandora
|
2007-08-23 18:05:21 +02:00
|
|
|
PANDORA_LOG=/var/log/pandora/pandora_agent.log
|
2007-04-19 20:37:57 +02:00
|
|
|
PANDORA_STARTUP=/etc/init.d/pandora_agent_daemon
|
2009-04-02 21:22:05 +02:00
|
|
|
TENTACLE=/usr/bin/tentacle_client
|
2009-06-12 09:09:33 +02:00
|
|
|
PANDORA_CFG_FILE=/etc/pandora/pandora_agent.conf
|
2009-04-02 21:22:05 +02:00
|
|
|
|
2007-04-19 20:37:57 +02:00
|
|
|
FORCE=0
|
|
|
|
LOG_TIMESTAMP=`date +"%Y/%m/%d %H:%M:%S"`
|
|
|
|
|
|
|
|
MODE=$1
|
|
|
|
|
|
|
|
if [ ! -f "pandora_agent" ]
|
|
|
|
then
|
|
|
|
echo " "
|
|
|
|
echo "You need to place pandora_agent file on main distribution directory before install"
|
|
|
|
echo " "
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2009-08-11 18:58:01 +02:00
|
|
|
get_distro () {
|
|
|
|
|
|
|
|
# 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
|
|
|
|
LINUX_DISTRO=GENERIC
|
|
|
|
OS_VERSION=`uname -r`
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
echo $LINUX_DISTRO
|
|
|
|
}
|
|
|
|
|
2007-04-19 20:37:57 +02:00
|
|
|
uninstall () {
|
2009-11-29 14:35:16 +01:00
|
|
|
DISTRO=`get_distro`
|
2007-04-19 20:37:57 +02:00
|
|
|
echo "Removing Pandora FMS Agent..."
|
|
|
|
rm -Rf $PANDORA_BIN
|
|
|
|
rm -Rf $PANDORA_TEMP
|
2009-06-12 09:09:33 +02:00
|
|
|
rm -Rf $PANDORA_CFG_FILE
|
2007-04-19 20:37:57 +02:00
|
|
|
rm -Rf $PANDORA_STARTUP
|
|
|
|
rm -Rf $PANDORA_HOME
|
|
|
|
rm -Rf $PANDORA_LOG
|
2009-09-30 18:32:21 +02:00
|
|
|
rm -Rf $TENTACLE
|
2009-11-29 14:35:16 +01:00
|
|
|
if [ "$DISTRO" == "UBUNTU" ]
|
|
|
|
then
|
|
|
|
# Removing linking daemon scripts
|
|
|
|
update-rc.d -f pandora_agent_daemon remove
|
|
|
|
fi
|
2007-04-19 20:37:57 +02:00
|
|
|
echo "Done"
|
|
|
|
}
|
|
|
|
|
|
|
|
install () {
|
2009-11-29 14:35:16 +01:00
|
|
|
DISTRO=`get_distro`
|
|
|
|
OLDFILENAMETMP=`date +"%Y-%m-%d"`
|
2009-08-11 18:58:01 +02:00
|
|
|
|
2009-11-29 14:35:16 +01:00
|
|
|
echo "Detecting Linux distribution: $DISTRO"
|
2009-08-11 18:58:01 +02:00
|
|
|
|
2009-11-29 14:35:16 +01:00
|
|
|
if [ -f $PANDORA_HOME ] && [ "$FORCE" = "0" ]
|
|
|
|
then
|
|
|
|
echo "Seems that default dir already exists. Please use --force-install to"
|
|
|
|
echo "force installer to install on $PANDORA_HOME"
|
|
|
|
exit
|
|
|
|
else
|
|
|
|
echo "Checking default dir $PANDORA_HOME..."
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -f $PANDORA_BIN ] && [ "$FORCE" = "0" ]
|
|
|
|
then
|
|
|
|
echo "Seems that $PANDORA_BIN already exists. Please use --force-install to"
|
|
|
|
echo "force installer to reinstall overwriting it"
|
|
|
|
echo " "
|
|
|
|
exit
|
|
|
|
else
|
|
|
|
echo "Checking Pandora FMS Agent on $PANDORA_BIN...."
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Create directories
|
|
|
|
echo "Creating Pandora FMS Agent home directory at $PANDORA_HOME ..."
|
|
|
|
mkdir $PANDORA_HOME 2> /dev/null
|
|
|
|
mkdir -p $PANDORA_TEMP 2> /dev/null
|
|
|
|
mkdir $PANDORA_CFG 2> /dev/null
|
|
|
|
mkdir /var/log/pandora 2> /dev/null
|
|
|
|
|
|
|
|
# Create logfile
|
|
|
|
if [ ! -z "`touch $PANDORA_LOG`" ]
|
|
|
|
then
|
|
|
|
echo "Seems to be a problem generating logfile ($PANDORA_LOG) please check it";
|
|
|
|
else
|
|
|
|
echo "Creating logfile at $PANDORA_LOG..."
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "$LOG_TIMESTAMP Pandora FMS installer has created this file at startup" > $PANDORA_LOG
|
|
|
|
|
|
|
|
# Copying agent and securing it
|
|
|
|
echo "Copying Pandora FMS Agent to $PANDORA_BIN..."
|
|
|
|
cp pandora_agent $PANDORA_BIN
|
|
|
|
chmod 700 $PANDORA_BIN
|
|
|
|
|
|
|
|
echo "Copying Pandora FMS Agent contrib dir to $PANDORA_HOME/..."
|
|
|
|
cp pandora_agent_daemon $PANDORA_HOME
|
|
|
|
|
|
|
|
echo "Copying Pandora FMS Agent configuration file to $PANDORA_HOME/pandora_agent.conf..."
|
|
|
|
if [ -e /etc/pandora/pandora_agent.conf ]
|
|
|
|
then
|
|
|
|
cat /etc/pandora/pandora_agent.conf > /etc/pandora/pandora_agent.conf.$OLDFILENAMETMP
|
|
|
|
echo "Backing up old configuration file to /etc/pandora_agent.conf.$OLDFILENAMETMP"
|
|
|
|
fi
|
2009-08-11 18:58:01 +02:00
|
|
|
|
2009-11-29 14:35:16 +01:00
|
|
|
echo "Copying default agent configuration to $PANDORA_HOME/pandora_agent.conf"
|
|
|
|
cp pandora_agent.conf $PANDORA_HOME/pandora_agent.conf
|
|
|
|
chmod 600 $PANDORA_HOME/pandora_agent.conf
|
2007-04-21 22:05:35 +02:00
|
|
|
|
2009-11-29 14:35:16 +01:00
|
|
|
echo "Copying Pandora FMS Agent plugins to $PANDORA_HOME/plugins..."
|
|
|
|
cp -r plugins $PANDORA_HOME
|
|
|
|
chmod -R 700 $PANDORA_HOME/plugins
|
2009-04-02 21:22:05 +02:00
|
|
|
|
2009-11-29 14:35:16 +01:00
|
|
|
echo "Copying tentacle client to $TENTACLE"
|
|
|
|
cp tentacle_client $TENTACLE
|
2009-04-02 21:22:05 +02:00
|
|
|
|
2009-11-29 14:35:16 +01:00
|
|
|
echo "Linking Pandora FMS Agent plugins directory to $PANDORA_CFG/plugins..."
|
|
|
|
rm $PANDORA_CFG/plugins 2> /dev/null
|
|
|
|
ln -s $PANDORA_HOME/plugins $PANDORA_CFG 2> /dev/null
|
2007-04-19 20:37:57 +02:00
|
|
|
|
2009-11-29 14:35:16 +01:00
|
|
|
echo "Linking Pandora FMS Agent configuration to $PANDORA_CFG/pandora_agent.conf..."
|
|
|
|
rm $PANDORA_CFG/pandora_agent.conf 2> /dev/null
|
|
|
|
ln -s $PANDORA_HOME/pandora_agent.conf $PANDORA_CFG/pandora_agent.conf
|
2007-04-19 20:37:57 +02:00
|
|
|
|
2009-11-29 14:35:16 +01:00
|
|
|
echo "Setting secure permissions and ownership for all Pandora FMS Agent files..."
|
|
|
|
chown -R root $PANDORA_HOME
|
|
|
|
chmod -R 600 $PANDORA_TEMP
|
|
|
|
chmod 640 $PANDORA_LOG
|
|
|
|
chgrp root $PANDORA_LOG
|
2008-09-03 18:50:56 +02:00
|
|
|
|
2009-11-29 14:35:16 +01:00
|
|
|
echo "Linking start-up daemon script at $PANDORA_STARTUP";
|
|
|
|
cp pandora_agent_daemon $PANDORA_STARTUP
|
2008-09-03 18:50:56 +02:00
|
|
|
|
2009-11-29 14:35:16 +01:00
|
|
|
if [ "$DISTRO" == "UBUNTU" ]
|
2009-08-11 18:58:01 +02:00
|
|
|
then
|
|
|
|
echo "Linking start-up daemon script to /etc/rc2.d";
|
2009-12-07 15:57:34 +01:00
|
|
|
ln -s /etc/init.d/pandora_agent_daemon /etc/rc2.d/S90pandora_agent_daemon
|
|
|
|
echo "Linking stop daemon scripts";
|
|
|
|
ln -s /etc/init.d/pandora_agent_daemon /etc/rc0.d/K90pandora_agent_daemon
|
|
|
|
ln -s /etc/init.d/pandora_agent_daemon /etc/rc1.d/K90pandora_agent_daemon
|
|
|
|
ln -s /etc/init.d/pandora_agent_daemon /etc/rc6.d/K90pandora_agent_daemon
|
2009-11-29 14:35:16 +01:00
|
|
|
else
|
|
|
|
INITLV=`cat /etc/inittab | grep "[0-9]\:initdefault" | cut -f 2 -d ":"`
|
|
|
|
echo "Linking start-up daemon script to /etc/rc.d/rc$INITLV.d";
|
|
|
|
ln -s /etc/init.d/pandora_agent_daemon /etc/rc.d/rc$INITLV.d/S90pandora_agent_daemon
|
|
|
|
fi
|
|
|
|
|
|
|
|
chown -R root:root $PANDORA_BIN
|
|
|
|
|
|
|
|
echo "Done."
|
|
|
|
echo " "
|
|
|
|
echo "You have your startup script ready at $PANDORA_STARTUP"
|
|
|
|
echo " "
|
|
|
|
echo "Tentacle is the default transfer mode since 2.0 version."
|
|
|
|
echo "If you want to use SSH, firstly you need to copy your public SSH keys ($HOME/.ssh/id_dsa)"
|
|
|
|
echo "under /home/pandora/.ssh/authorized_keys on your Pandora FMS Server host"
|
|
|
|
echo "You also need to setup your $PANDORA_CFG/pandora_agent.conf config file"
|
|
|
|
echo " "
|
2007-04-19 20:37:57 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
help () {
|
2009-11-29 14:35:16 +01:00
|
|
|
echo " --force-install To force installation if already installed on system "
|
|
|
|
echo " --install To install Pandora FMS Agent on this system"
|
|
|
|
echo " --uninstall To uninstall and remove Pandora FMS Agent on this System"
|
|
|
|
echo " "
|
2007-04-19 20:37:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
# Script banner at start
|
|
|
|
echo " "
|
2009-08-11 18:58:01 +02:00
|
|
|
echo "Pandora FMS Agent Installer $PI_VERSION (c) 2008-2009 ArticaST"
|
2009-04-02 21:22:05 +02:00
|
|
|
echo "This program is licensed under GPL2 Terms. http://pandorafms.com"
|
2007-04-19 20:37:57 +02:00
|
|
|
echo " "
|
|
|
|
|
|
|
|
case "$MODE" in
|
|
|
|
|
|
|
|
'--force-install')
|
2009-11-29 14:35:16 +01:00
|
|
|
FORCE=1
|
|
|
|
install
|
|
|
|
exit
|
|
|
|
;;
|
2007-04-19 20:37:57 +02:00
|
|
|
|
|
|
|
'--install')
|
2009-11-29 14:35:16 +01:00
|
|
|
install
|
|
|
|
exit
|
|
|
|
;;
|
2007-04-19 20:37:57 +02:00
|
|
|
|
|
|
|
'--uninstall')
|
2009-11-29 14:35:16 +01:00
|
|
|
uninstall
|
|
|
|
exit
|
|
|
|
;;
|
2007-04-19 20:37:57 +02:00
|
|
|
|
|
|
|
*)
|
2009-11-29 14:35:16 +01:00
|
|
|
help
|
2007-04-19 20:37:57 +02:00
|
|
|
esac
|
|
|
|
|