Welcome to Pandora FMS Community!

Find answers, ask questions, and connect with our community around the world.

Welcome to Pandora FMS Community Forums Community support My Pandora Server installation script

  • My Pandora Server installation script

    Posted by daggett on December 18, 2006 at 14:09

    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

    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!

    daggett replied 17 years, 10 months ago 3 Members · 6 Replies
  • 6 Replies
  • manu

    Member
    December 18, 2006 at 14:24
    0 Karma points
    Community rank: tentacle-noob-1 Tentacle noob
    Like it
    Up
    0
    Down
    Drop it
    ::

    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

  • Sancho

    Administrator
    December 18, 2006 at 15:18
    2214 Karma points
    Community awards: bulb Bright ideas
    Community rank: tentacle_master_icon Tentacle Master
    Like it
    Up
    0
    Down
    Drop it
    ::

    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.

  • daggett

    Member
    December 18, 2006 at 16:50
    0 Karma points
    Community rank: tentacle-noob-1 Tentacle noob
    Like it
    Up
    0
    Down
    Drop it
    ::

    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 😉 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

  • manu

    Member
    December 19, 2006 at 15:56
    0 Karma points
    Community rank: tentacle-noob-1 Tentacle noob
    Like it
    Up
    0
    Down
    Drop it
    ::

    And maybe we could write an uninstall script?
    thanks again
    bye

    Why someone would be interested in unistall it? 🙂

  • manu

    Member
    December 22, 2006 at 15:34
    0 Karma points
    Community rank: tentacle-noob-1 Tentacle noob
    Like it
    Up
    0
    Down
    Drop it
    ::

    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!

  • daggett

    Member
    December 22, 2006 at 20:43
    0 Karma points
    Community rank: tentacle-noob-1 Tentacle noob
    Like it
    Up
    0
    Down
    Drop it
    ::

    Yep, I sent them 5 minutes ago!
    Wow include my scripts in the SVN… it’s makin’ me quiet proud! 😉
    thanks, really, I’m really happy about that! It’s a kind of a christmas persent! 😆

    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! 😀

    bye for now.
    Denis