-
My Pandora Server installation script
As promised, here is my “Pandora Server” installation script.
It’s not tested, so it may contaon bugs (it certainly contains bug!)
To be run as root:
[code:1]#!/bin/bash# this script was released under GNU/GPL license 2006.
# by Denis Chupau, Tranquil IT Systems.
# It was _NEVER_ tested, so use it with care! and at your own risks.#### var declarations
PANDORA_HOME=”/opt/pandora”
FILES_SERVER_URL=”http:// ftp://” # server to download .tgz files from
SERVER_PACK=”pandora_server.tar.gz”
SERVER_SUBDIR=”pandora_server”
SERVER_IP=”your.pandora.server.ip.or.fqdn”
SERVER_PORT=”22″
CONSOLE_PACK=”pandora_agent.tar.gz”
CONSOLE_SUBDIR=”pandora_console”
CONSOLE_PATH=”/var/www/html”
AGENT_PACK=”pandora_console.tar.gz”
AGENT_SUBDIR=”pandora_agent”# **** your Linux distribution detection code here:
# Get Linux Distro type and version# SUSE
if [ -f “/etc/SuSE-release” ]
then
OS_VERSION=`cat /etc/SuSE-release | grep VERSION | cut -f 3 -d ” “`
LINUX_DISTRO=SUSE
# *** put your code and vars for SUSE here
# CONSOLE_PATH=”/var/www/html”
# *** between those comments
else
if [ -f “/etc/lsb-release” ]
then
OS_VERSION=`cat /etc/lsb-release | grep DISTRIB_RELEASE | cut -f 2 -d “=”`
LINUX_DISTRO=UBUNTU
# *** put your code and vars for UBUNTU here
# CONSOLE_PATH=”/var/www/html”
# *** between those comments
else
if [ -f “/etc/debian_version” ]
then
OS_VERSION=`cat /etc/debian_version`
OS_VERSION=”DEBIAN $OS_VERSION”
LINUX_DISTRO=DEBIAN
# *** put your code and vars for DEBIAN here
# CONSOLE_PATH=”/var/www/html”
# *** between those comments
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
# *** put your code and vars for FEDORA here
CONSOLE_PATH=”/var/www/html”
# *** between those comments
else
if [ -f “/etc/mandriva-release” ]
then
OS_VERSION=`cat /etc/mandriva-release`
LINUX_DISTRO=MANDRIVA
# *** put your code and vars for MANDRIVA here
CONSOLE_PATH=”/var/www/html”
# *** between those comments
else
# Add your distribution detection code here
LINUX_DISTRO=GENERIC
OS_VERSION=`uname -r`
# *** put your code and vars for GENERIC here
# *** between those comments
fi
fi
fi
fi
fi
# **** end of detection.urpmi sshd
urpmi wget
mkdir $PANDORA_HOME
cd $PANDORA_HOME
wget $FILES_SERVER_URL/$SERVER_PACK # retrieving packets to install them
wget $FILES_SERVER_URL/$CONSOLE_PACK
wget $FILES_SERVER_URL/$AGENT_PACK
tar -xzf $SERVER_PACK # de-tar prepared packages
tar -xzf $CONSOLE_PACK
tar -xzf $AGENT_PACK
mv $PANDORA_HOME/linux $PANDORA_HOME/$AGENT_SUBDIR # we only need linux agent
rm -rf $(ls /opt/pandora/ -I “pan*”) # cleaning
chown -R root:root $PANDORA_HOME # root is the owner at this precise time# ****************************************************************************
# ****************** Pandora Server configuration *********************
# ****************************************************************************
useradd -m -s /bin/bash pandora
echo “Password for user pandora:”
passwd pandora # => user intervention needed
chown pandora $PANDORA_HOME/$SERVER_SUBDIR/data_in
chown pandora $PANDORA_HOME/$SERVER_SUBDIR/log
chown pandora $PANDORA_HOME/$SERVER_SUBDIR/var
su pandora -c “mkdir /home/pandora/.ssh”
su pandora -c “touch /home/pandora/.ssh/authorized_keys”
su pandora -c “chmod 600 /home/pandora/.ssh/authorized_keys”
echo “SSH keys pair generation (keep default if you don’t know what to do, hit Enter):”
su pandora -c “ssh-keygen” # => user intervention
su pandora -c ‘echo command=”$PANDORA_HOME/$SERVER_SUBDIR/valid.sh” $(cat /home/pandora/.ssh/id_rsa.pub) >> /home/pandora/.ssh/authorized_keys’
echo AllowUsers pandora tisadmin >> /etc/ssh/sshd_config
# echo PasswordAuthentication no >> /etc/ssh/sshd_config # => to make the server unaccessible without RSA keys (no password).
# echo Put here the key(s) you want to add to pandora authorized_keys
# cat >> /home/pandora/.ssh/authorized_keys
/etc/init.d/sshd restart
## RPM specifiques (will probably need user intervention)
urpmi mysql
urpmi perl-xml-simple
urpmi perl-XML-Parser
urpmi perl-datemanip
urpmi perl-forks
urpmi perl-reaper
urpmi perl-md5
## Database configuration
/etc/init.d/mysqld start
mysql -e “create database pandora”
cat $PANDORA_HOME/$CONSOLE_SUBDIR/pandoradb.sql | mysql -D pandora -u root
cat $PANDORA_HOME/$CONSOLE_SUBDIR/pandoradb_data.sql | mysql -D pandora -u root
mysql -e “grant all on pandora.* to ‘pandora’@’localhost’ identified by ‘pandora'”echo Enter Mysql root password:
mysql -e “SET PASSWORD FOR ‘pandora’@’localhost’ = PASSWORD(‘pandora’)”
# mysql -e “SET PASSWORD FOR ‘root’@’localhost’ = PASSWORD(”)” # setting root password
# UPDATE mysql.user SET Password = PASSWORD(‘new_password’) WHERE User = ” # another command to set user password: which one is best?
/etc/init.d/mysqld restart # using this instead of flush privileges# **************************************************************
# *************** console installation ***********************
# **************************************************************
## RPM specifiques
urpmi apache-mod_php # apache + php5
urpmi php-mysql
urpmi php5-jpgraph
cp -r $PANDORA_HOME/$CONSOLE_SUBDIR $CONSOLE_PATH
cp -r /usr/share/php5-jpgraph/* $CONSOLE_PATH/$CONSOLE_SUBDIR/reporting/jpgraph/
/etc/init.d/httpd start# **************************************************************
# *********** installation de l’agent **************************
# **************************************************************
echo Generating modules …
urpmi sshd
urpmi wgetThe end of the script is the same than the agent installation script.
This is jsut an essay, so don’t blame me if it’s not perfect, I know it’s not!
And I even say, be careful, this is just an idea of a script, and it robably needs to be completely rewriten.bye for now!