Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
My Pandora Server installation script
#1
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 wget
[/code]
The 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!
 Reply
#2
God, well done :-)
I will test it too in a couple of days

Those 2 scripts will help a lot. Its will be propably upload to the contrib directory of pandora, when the tests and the corrections (if necessary) were done.

By the way, are you running your mysql without a root password?
I have noticed this:
mysql -D pandora -u root

Have you tried the script on a mysql with -p ? If not, don´t mind, I will :-)
If there´s a password on the mysql (normal scenario) would be a good idea to ask first for the root password (mysql), read it, and by using "expect" pass it as a data to the script, so the mysql tables and pandora user (on the mysql) will be set up automatically.

After seeing all your scripts, I´m thinking, seriusly, in making and script to copy all the keys and set perms correctly (this last thing sometimes drives people mad).

We are so glad you´re working hard on improving Pandora so much :-)
Once more, thanks
 Reply
#3
Quote:As promised, here is my "Pandora Server" installation script.
bye for now!

Quite interesting, probably put in contrib directory.... could be useful to future packaging scripts. Thanks a lot.
 Reply
#4
Thanks to you as well,
This script is taking installation of the Pandora Server from the beginning: that means that on the machine, there is a 'minimal installation" of a distribution (no apache, no mysql, no ...etc, just a running linux with a bash command line and network configured) and when you install mysql server for the first time it has no root password, it's more conveniant for an automated installation as mysql doesn't ask for a password every now and then...
The root password is set later in the script when all the tables and data are set. The password change functionnality has been commented because I wanted to let the choice to the user of half/entirely automatic installation and didn't implement it Wink sorry).

As I said it's just a start, but as I don't have much time actually to work on this one, I post it here for some to continue/give some ideas.

I will post some /etc/init.d/ start/stop scripts compatibles with chkconfig (this is not a big improvement as I added only half a dozen lines).

So the next step will be to integrate those strat/stop scripts in the installation scripts.

And maybe we could write an uninstall script?
thanks again
bye
 Reply
#5
Quote:And maybe we could write an uninstall script?
thanks again
bye

Why someone would be interested in unistall it? :-)
 Reply
#6
Hey dagget! how are you doing?

I´ve been testing a little bit the installation script and it doesn´t work properly, at least, for me. I´ve made some changes and now it´s ok.
I will post it soon, I´m finishing somethings at the moment.

Just a reminder, could you please send me a tar.gz package with all the scripts you have made? I´d like to test its and then once the review is done, upload its to the contrib directory on the SVN :-)

I wish you to have nice weekend!
 Reply
#7
Yep, I sent them 5 minutes ago!
Wow include my scripts in the SVN... it's makin' me quiet proud! :wink:
thanks, really, I'm really happy about that! It's a kind of a christmas persent! :lol:

I didn't send my script before 'cause I wanted to terminate some modifications on the packages (the char set issue) but it didn't work as expected, and I won't be working again on this until January 3rd 2007 (one week of vacations!!) 8) .

So happy new year and merry christmas to all of you, thanks for all the great job you did on Pandora, your precious help and see you in 1 week! Big Grin

bye for now.
Denis
 Reply


Users browsing this thread: 1 Guest(s)


(c) 2006-2018 Artica Soluciones Tecnológicas. Contents of this wiki are under Create Common Attribution v3 licence. | pandorafms.com | pandorafms.org

Theme © MyBB Themes