157 lines
4.6 KiB
Plaintext
157 lines
4.6 KiB
Plaintext
|
#!/usr/bin/ksh
|
||
|
# **********************************************************************
|
||
|
# Pandora Enterprise Generic Host Agent Installer
|
||
|
# AIX version
|
||
|
# (c) 2007 Sancho Lerena <slerena@gmail.com>
|
||
|
# Please see http://pandora.sourceforge.net
|
||
|
# this code is licensed under GPL 2.0 license.
|
||
|
# Este codigo esta licenciado bajo la licencia GPL 2.0.
|
||
|
# **********************************************************************
|
||
|
|
||
|
PI_VERSION=1.0
|
||
|
PANDORA_BIN=/usr/bin/pandora_agent.sh
|
||
|
PANDORA_HOME=/usr/share/pandora_agent
|
||
|
PANDORA_TEMP=/var/spool/pandora
|
||
|
PANDORA_CFG=/etc/pandora
|
||
|
PANDORA_LOG=/var/adm/pandora_agent.log
|
||
|
PANDORA_STARTUP=/etc/rc.pandora_agent_daemon
|
||
|
PANDORA_STARTUP_RC=/etc/rc2.d/S90pandora_agent
|
||
|
|
||
|
FORCE=0
|
||
|
LOG_TIMESTAMP=`date +"%Y/%m/%d %H:%M:%S"`
|
||
|
|
||
|
MODE=$1
|
||
|
|
||
|
set `id`
|
||
|
if [ $1 != "uid=0(root)" ]
|
||
|
then
|
||
|
echo " "
|
||
|
echo "I need to run as root"
|
||
|
echo " "
|
||
|
exit 1
|
||
|
fi
|
||
|
|
||
|
if [ ! -f "pandora_agent.sh" ]
|
||
|
then
|
||
|
echo " "
|
||
|
echo "You need to place on main distribution directory before install"
|
||
|
echo " "
|
||
|
exit 1
|
||
|
fi
|
||
|
|
||
|
uninstall () {
|
||
|
echo "Removing Pandora 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 Agent on $PANDORA_BIN...."
|
||
|
fi
|
||
|
|
||
|
# Create directories
|
||
|
echo "Creating Pandora Agent home directory at $PANDORA_HOME ..."
|
||
|
mkdir $PANDORA_HOME
|
||
|
mkdir $PANDORA_TEMP
|
||
|
mkdir $PANDORA_TEMP/data_out
|
||
|
mkdir $PANDORA_CFG
|
||
|
|
||
|
# Create logfile
|
||
|
if [ ! -z "`touch $PANDORA_LOG`" ]
|
||
|
then
|
||
|
echo "Seems to be a problem generating logfile ($PANDORA_LOG) please checkit";
|
||
|
else
|
||
|
echo "Creating logfile at $PANDORA_LOG..."
|
||
|
fi
|
||
|
|
||
|
echo "$LOG_TIMESTAMP Pandora installer has created this file at startup" > $PANDORA_LOG
|
||
|
|
||
|
# Copying agent and securing it
|
||
|
echo "Copying Pandora Agent to $PANDORA_BIN..."
|
||
|
cp pandora_agent.sh $PANDORA_BIN
|
||
|
chmod 700 $PANDORA_BIN
|
||
|
|
||
|
# Copying moduleS
|
||
|
echo "Copying Pandora Agent configuration file to $PANDORA_HOME/pandora_agent.conf..."
|
||
|
cp pandora_agent.conf $PANDORA_HOME
|
||
|
cp pandora_agent.sh $PANDORA_HOME
|
||
|
cp pandora_agent_daemon $PANDORA_HOME
|
||
|
chmod 600 $PANDORA_HOME/pandora_agent.conf
|
||
|
echo "Linking Pandora Agent configuration to $PANDORA_CFG/pandora_agent.conf..."
|
||
|
ln -s $PANDORA_HOME/pandora_agent.conf $PANDORA_CFG
|
||
|
echo "Setting secure permissions and ownership for all Pandora 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"
|
||
|
ln -s $PANDORA_HOME/pandora_agent_daemon $PANDORA_STARTUP
|
||
|
echo "Linking start-up daemon script at $PANDORA_STARTUP_RC"
|
||
|
ln -s $PANDORA_HOME/pandora_agent_daemon $PANDORA_STARTUP_RC
|
||
|
chown -R root $PANDORA_BIN
|
||
|
echo "Done."
|
||
|
echo " "
|
||
|
echo "You have your startup script ready at $PANDORA_STARTUP"
|
||
|
echo "First you need to copy your public SSH keys ($HOME/.ssh/id_dsa.pub)"
|
||
|
echo "under /home/pandora/.ssh/authorized_keys on your Pandora 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 Agent on this system"
|
||
|
echo " --uninstall To uninstall and remove Pandora Agent on this System"
|
||
|
echo " "
|
||
|
}
|
||
|
|
||
|
# Script banner at start
|
||
|
echo " "
|
||
|
echo "Pandora Enterprise Agent Installer $BI_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
|
||
|
|