pandorafms/pandora_agents/linux/pandora_agent_installer

164 lines
5.1 KiB
Plaintext
Raw Normal View History

#!/bin/bash
# **********************************************************************
# Pandora FMS Agent - Generic Host Agent Installer
# GNU/Linux version
# (c) 2007 Sancho Lerena <slerena@gmail.com>
# Please see http://pandora.sourceforge.net
# This code is licensed under GPL 2.0 license.
# **********************************************************************
PI_VERSION=1.0
PANDORA_BIN=/usr/bin/pandora_agent
2007-06-12 Manuel Arostegui <marostegui@artica.es> * linux/contrib/pandora_agent_installer: Changed a PATH to adapt the script to the 1.3 version. * linux/contrib/pandora_agent_daemon: Added nohup. * linux/pandora_agent: Added features like: Maximum and Minimum hours where the agent can run between. Delayed startup for the agent. Added NICE option to protect CPU. Added "local" as a new transfer mode. * linux/pandora_agent.conf: Changed in order to adapt it to the new features of the agent. * aix/pandora_agent_installer: Added to repository: Pandora Agent Installer for AIX Systems. * aix/pandora_agent_daemon: Added nohup and fixed a small bug related with an "exit" in the beggining of the script. * aix/pandora_agent.conf: Changed in order to adapt it to the new features of the agent. * aix/pandora_agent.sh: Added features like: Maximum and Minimum hours where the agent can run between. Delayed startup for the agent. Added NICE option to protect CPU. Added "ftp" and "local" as a new transfer mode. Added the chance of choosing the remote ssh port to use. * win32/bin/pandora_agent.conf: Changed version number. * solaris/pandora_agent_installer: Added to repository: Pandora Agent Installer for Solaris Systems. * solaris/pandora_agent_daemon: Added nohup. * solaris/pandora_agent.conf: Changed in order to adapt it to the new features of the agent. * solaris/pandora_agent.sh: Added the banner in the start up. Added features like: Maximum and Minimum hours where the agent can run between. Delayed startup for the agent. Added NICE option to protect CPU. Added "ftp" and "local" as a new transfer mode. Added the chance of choosing the remote ssh port to use. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@503 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2007-06-12 11:32:54 +02:00
PANDORA_HOME=/usr/share/pandora_agent
PANDORA_TEMP=/var/spool/pandora
PANDORA_CFG=/etc/pandora
PANDORA_LOG=/var/log/pandora/pandora_agent.log
PANDORA_STARTUP=/etc/init.d/pandora_agent_daemon
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
uninstall () {
echo "Removing Pandora FMS Agent..."
rm -Rf $PANDORA_BIN
rm -Rf $PANDORA_TEMP
rm -Rf $PANDORA_CFG
rm -Rf $PANDORA_STARTUP
rm -Rf $PANDORA_HOME
rm -Rf $PANDORA_LOG
echo "Done"
}
install () {
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
if [ -f $PANDORA_BIN ] && [ "$FORCE" = "0" ]
then
echo "Seems that $PANDORA_BIN already exists. Please use --force to"
echo "force installer to reinstall overwriting it"
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
mkdir $PANDORA_TEMP
mkdir $PANDORA_TEMP/data_out
mkdir $PANDORA_CFG
mkdir /var/log/pandora
# 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..."
cp pandora_agent.conf $PANDORA_HOME
chmod 600 $PANDORA_HOME/pandora_agent.conf
echo "Copying Pandora FMS Agent plugins to $PANDORA_HOME/plugins..."
cp -r plugins $PANDORA_HOME
chmod -R 700 $PANDORA_HOME/plugins
echo "Linking Pandora FMS Agent plugins directory to $PANDORA_CFG/plugins..."
ln -s $PANDORA_HOME/plugins $PANDORA_CFG
echo "Linking Pandora FMS Agent configuration to $PANDORA_CFG/pandora_agent.conf..."
ln -s $PANDORA_HOME/pandora_agent.conf $PANDORA_CFG
echo "Linking Pandora FMS Agent user configuration to $PANDORA_CFG/pandora_user.conf..."
ln -s $PANDORA_HOME/pandora_user.conf $PANDORA_CFG
echo "Setting secure permissions and ownership for all Pandora FMS Agent files..."
chown -R root $PANDORA_HOME
chmod -R 600 $PANDORA_TEMP/data_out
chmod 640 $PANDORA_LOG
chgrp 3 $PANDORA_LOG
echo "Linking start-up daemon script at $PANDORA_STARTUP";
cp pandora_agent_daemon $PANDORA_STARTUP
echo "Linking start-up daemon script to /etc/rc2.d";
ln -s /etc/init.d/pandora_agent_daemon /etc/rc2.d/S90pandora_agent
echo "Copying tentacle_client to /usr/bin";
cp tentacle_client /usr/bin/
chown -R root $PANDORA_BIN
echo "Done."
echo " "
echo "You have your startup script ready at $PANDORA_STARTUP"
echo "Tentacle is the default transfer mode"
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 " "
}
help () {
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 " "
}
# Script banner at start
echo " "
echo "Pandora FMS Agent Installer $PI_VERSION (c) 2007 Sancho Lerena"
echo "This program is licensed under GPL2 Terms. http://pandora.sourceforge.net"
echo " "
case "$MODE" in
'--force-install')
FORCE=1
install
exit
;;
'--install')
install
exit
;;
'--uninstall')
uninstall
exit
;;
*)
help
esac