Announcement

Collapse
No announcement yet.

Paquet deb et rpm

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Paquet deb et rpm

    Dans le cadre de mon travail j'ai empaqueter oreon dans un paquet debian ( avec l'aide de Watt que je remercie ) et rpm. Se ne sont que les "premiers" jets on va dire mais cela fonctionne très bien.

    Bon le versionning de la release c'est un peu "freestyle" à chaque modif j'incrémente même pour une modif minuscule ^^". Je débute donc soyez indulgents

    Le paquet rpm crée automatiquement les deux bases sous le nom oreon et oreon_data ainsi qu'un utilisateur pour ces bases nommé oreon ( manque d'originalité je sais). Les droit pour les dossiers sont réglés et pour l'instant il installe les modules php automatiquement sauf si c'est une update et non une installation qu'on réalise. A la suppression d'oreon on supprime les bases de données et les fichiers.
    Voici le fichiers spec concernant le .rpm :

    Code:
    Summary: Web interface which add functionnality to Nagios
    Name: oreon
    Version: 1.4
    Release: 1.43
    License: GPL 
    Group: Applications/Archiving
    URL: http://www.oreon-project.org/download.html
    Source0: %{name}-%{version}.tar.gz
    Patch0: oreon-rpm.patch
    BuildRoot: /usr/src/redhat/BUILD/%{name}-%{version}
    BuildArchitectures: noarch
    Packager: Claneys Skyne
    Distribution: RHEL 4
    Requires: mysql-server, nagios, httpd, php, php-gd, php-snmp, php-ldap, gd, gd-devel, libpng, libpng-devel
    %description
    Oreon provide entreprise monitoring based on core.
    It offers a complete tool from administration to 
    reporting/ visualisation with the most powerful 
    monitoring and alerting engine.
    
    %prep
    %setup -q
    %patch0 -p1
    
    
    %build
    
    %install
    
    
    %clean
    rm -rf $RPM_BUILD_ROOT
    
    
    %files
    /usr/local/oreon/
    /etc/init.d/ods
    /etc/httpd/conf.d/oreon.conf
    /usr/lib/nagios/plugins/
    /usr/X11R6/lib/X11/fonts/truetype/arial.ttf
    /usr/X11R6/lib/X11/fonts/truetype/fontmap.txt
    /usr/X11R6/lib/X11/fonts/truetype/verdanab.ttf
    %doc /debugfiles.list
    %doc /debugsources.list
    
    %pre
    oreon_exist=`rpm -q oreon | grep oreon-1.4`
    if [ "$oreon_exist" != "" ]
    then
    exit 0
    else
    PEAR_PATH=/usr/share/pear
    OREON_BASE=oreon
    OREON_USER=oreon
    OREON_PASSWORD=****
    mkdir -p /usr/local/oreon/ODS/etc
    mkdir -p /usr/local/oreon/ODS/var
    mkdir -p /usr/local/oreon/GPL_LIB/SmartyCache/compile
    #Configuring and update pear
    pear upgrade -a PEAR-1.3.6
    pear upgrade Archive_Tar Structures_Graph PEAR
    #Proxy for SYDEL
    pear config-set http_proxy proxyhttp.sydel.fr:8080
    pear config-set preferred_state beta
    pear channel-update pear.php.net
    pear install -o --alldeps Image_Color DB DB_DataObject DB_DataObject_FormBuilder 
    pear install -o --alldeps Numbers_Roman Numbers_Words HTML_Common HTML_QuickForm 
    pear install -o --alldeps MDB2 Date HTTP Image_Canvas Auth_SASL XML_RPC
    pear install -o --alldeps HTML_QuickForm_advmultiselect HTML_Table
    pear install -o --alldeps Image_Graph Image_GraphViz Mail Mail_Mine Net_SMTP 
    pear install -o --alldeps Net_Socket Net_Traceroute Net_Ping Validate 
    echo "Install of php modules                 [OK]"
    if [ -f /var/run/mysqld/mysqld.pid ]
    then
    mysql --user=root -e "CREATE DATABASE "$OREON_BASE""
    mysql --user=root -e "CREATE DATABASE "$OREON_BASE"_data"
    mysql --user=root -e "GRANT ALL PRIVILEGES ON "$OREON_BASE".* TO "$OREON_USER"@'%' IDENTIFIED BY '"$OREON_PASSWORD"'"
    mysql --user=root -e "GRANT ALL PRIVILEGES ON "$OREON_BASE"_data.* TO "$OREON_USER"@'%' IDENTIFIED BY '"$OREON_PASSWORD"'"
    echo "Create databases and user              [OK]"
    else
    service mysqld start
    mysql --user=root -e "CREATE DATABASE "$OREON_BASE""
    mysql --user=root -e "CREATE DATABASE "$OREON_BASE"_data"
    mysql --user=root -e "GRANT ALL PRIVILEGES ON "$OREON_BASE".* TO "$OREON_USER"@'%' IDENTIFIED BY '"$OREON_PASSWORD"'"
    mysql --user=root -e "GRANT ALL PRIVILEGES ON "$OREON_BASE"_data.* TO "$OREON_USER"@'%' IDENTIFIED BY '"$OREON_PASSWORD"'"
    echo "Create databases and user              [OK]"
    fi
    fi
    exit 0
    
    %post
    SHAREDIR=/usr/local/oreon
    RRDDIR=/usr/local/oreon/rrd
    PLUGDIR=/usr/lib/nagios/plugins
    service httpd restart
    echo "Configuring Apache                     [OK]"
    chown -R apache:apache ${SHAREDIR}
    chmod -R 775 ${SHAREDIR}
    chown -R nagios:nagios ${RRDDIR}
    chown -R apache:nagios ${PLUGDIR}
    chmod -R 775 ${PLUGDIR}
    chown -R apache:nagios /etc/nagios
    chmod -R 775 /etc/nagios
    echo "Configuring acces right                [OK]"
    if [ -f /etc/init.d/ods /etc/rc5.d/S99ods ]
    then
    exit 0
    else
    ln -s /etc/init.d/ods /etc/rc5.d/S99ods
    fi
    exit 0
    
    %preun
    OREON_BASE=oreon
    mysql --user=root -e "DROP DATABASE IF EXISTS "$OREON_BASE 
    mysql --user=root -e "DROP DATABASE IF EXISTS "$OREON_BASE"_data"
    rm -rf /usr/local/oreon
    rm -f /etc/init.d/ods /etc/rc5.d/S99ods
    exit 0
    
    %changelog
    * Tue Jul 10 2007 root <[email protected]> - 1.4-1
    - Initial build.
    Pour le deb y'a un peu plus de boulot déjà et la plupart sont inspirés des anciens scripts de Watt ( je vous épargne les fichiers sans intérêts ). On commmence par le fichier control :

    Code:
    Source: oreon
    Section: utils
    Priority: optional
    Maintainer: Claneys Skyne <vvvv>
    Build-Depends: debhelper (>= 4.0.0)
    Standards-Version: 3.7.2
    
    Package: oreon
    Architecture: any
    Depends: ${shlibs:Depends}, ${misc:Depends},php5-mysql, php-pear, php5-snmp, php5-gd, libgd2-xpm, libgd2-xpm-dev, libpng12-0, libpng12-dev, libconfig-inifiles-perl, libcrypt-des-perl, libdigest-hmac-perl, libdigest-sha1-perl, libgd-perl, libio-socket-inet6-perl, libnet-snmp-perl, librrdp-perl, librrd2, librrds-perl, libsocket6-perl, rrdtool, nagios2, mysql-server-5.0, phpmyadmin, debconf-utils, apache2, libapache2-mod-php5
    Description: Oreon : Web interface for Nagios.
     Oreon is a network supervision and monitoring tool, 
     it is based upon the most effective 
     Open Source monitoring engine : Nagios.
     Oreon provides a new frontend and 
     new functionnalities to Nagios. 
     It ables you to be more efficient 
     in your network monitoring, 
     but also allows you to make your supervision informations
     readable by a largest range of users. 
     Indeed, a non technical user can now use the Oreon/Nagios couple
     to easily understand your network infrastructure thanks to charts
     and graphical representations of the gathered informations.
     Although, skilled users still have access to the technicals
     informations collected by Nagios. 
     Oreon was released for three years, and has already conviced 
     most of its everyday users. Oreon has became a reference as a Nagios
     Frontend.
     The Oreon/Nagios couple is used by a wide range of users, 
     from novices to skilled users, even if they didn't knew Nagios before.
     Here is a non-exhaustive list of the functionalities provided by Oreon :
     A highly customizable and intuitive multi-user interface
     An enhanced configuration tool to setup the supervised perimeter
     Configuration wizards
     A frontend to all Nagios configuration files. These configurations are 
     linked to save your working time. 
     A Nagios configuration loader module
     A Nagios 1.X and 2.x compatibility 
     A Nagios configuration file-checker thanks to Nagios Debugger 
     Network devices and servers ID Cards which has all the basic informations about these resources 
     A customizable network cartography 
     An access manager, including resources as well as interfaces restrictions 
     And a lot more to discover
    Le scripts de postinst :

    Code:
    #! /bin/sh -e
    # postinst script for oreon
    #
    # see: dh_installdeb(1)
    
    #
    SHAREDIR=/usr/local/oreon
    RRDDIR=/usr/local/oreon/rrd
    PLUGDIR=/usr/lib/nagios/plugins
    
    #
    # Skip, if we are not in "configure" state
    #
    if [ "$1"   != "configure" ]; then
            exit 0
    fi
    	
    ## Source debconf library
    . /usr/share/debconf/confmodule
    
    cp -f /usr/share/doc/oreon/oreon.apache.conf /etc/apache2/conf.d/oreon.conf
    echo "Configuring Apache                     [OK]"
    #invoke-rc.d apache2 restart
    
    chown -R www-data:www-data ${SHAREDIR}
    chmod -R 775 ${SHAREDIR}
    
    chown -R nagios:nagios ${RRDDIR}
    
    chown  -R www-data:nagios ${PLUGDIR}
    chmod  -R 775 ${PLUGDIR}
    
    chown  -R www-data:nagios /etc/nagios2
    chmod -R 775 /etc/nagios2
    echo "Configuring acces right                [OK]"
    
    # Process of debconf answer.
    
    db_get oreon/php_modules
    PEAR="$RET"
    
    if [ "$RET" = "true" ]; then
    pear install -o -f --alldeps DB DB_DataObject DB_DataObject_FormBuilder MDB2 Date
    pear install -o -f --alldeps Numbers_Roman Numbers_Words HTML_Common HTML_QuickForm 
    pear install -o -f --alldeps HTML_QuickForm_advmultiselect HTML_Table Auth_SASL HTTP Image_Canvas Image_Color
    pear install -o -f --alldeps Image_Graph Image_GraphViz Mail Mail_Mine Net_SMTP Net_Socket Net_Traceroute Net_Ping Validate XML_RPC
    fi
    
    db_get oreon/mysql_oreon_base
    OREON_BASE="$RET"
    
    db_get oreon/mysql_oreon_base_data
    OREON_BASE_DATA="$RET"
    
    db_get oreon/mysql_oreon_user_for_database
    OREON_USER="$RET"
    
    db_get oreon/mysql_oreon_password_for_database
    OREON_PASSWORD="$RET"
    
    
    mysql --user=root -e "CREATE DATABASE "$OREON_BASE""
    mysql --user=root -e "CREATE DATABASE "$OREON_BASE_DATA""
    mysql --user=root -e "GRANT ALL PRIVILEGES ON "$OREON_BASE".* TO "$OREON_USER"@'%' IDENTIFIED BY '"$OREON_PASSWORD"'"
    mysql --user=root -e "GRANT ALL PRIVILEGES ON "$OREON_BASE_DATA".* TO "$OREON_USER"@'%' IDENTIFIED BY '"$OREON_PASSWORD"'"
    echo "Create databases and user              [OK]"
    # dh_installdeb will replace this with shell code automatically
    # generated by other debhelper scripts.
    
    #DEBHELPER#
    exit 0
    Last edited by claneys; 18 July 2007, 13:16.

  • #2
    script postrm :

    Code:
    #! /bin/bash -e
    # postinst script for oreon
    #
    # see: dh_installdeb(1)
    # dh_installdeb will replace this with shell code automatically
    # generated by other debhelper scripts.
    
    #DEBHELPER#
    
    
    
    SHAREDIR=/usr/local/oreon
    RRDDIR=/usr/local/oreon/rrd
    PLUGDIR=/usr/lib/nagios/plugins
    
    if [ "$1" != "remove" ]; then
            exit 0
    fi
    
    ## Source debconf library
    . /usr/share/debconf/confmodule
    
    rm -rf ${SHAREDIR}
    rm -f /etc/apache2/conf.d/oreon.conf
    #invoke-rc.d apache2 restart
    rm -f /etc/init.d/ods
    
    db_get oreon/mysql_oreon_base
    OREON_BASE="$RET"
    
    db_get oreon/mysql_oreon_base_data
    OREON_BASE_DATA="$RET"
    
    db_get oreon/mysql_oreon_user_for_database
    OREON_USER="$RET"
    
    db_get oreon/mysql_oreon_password_for_database
    OREON_PASSWORD="$RET"
    
    #Clean mysql server.
    mysql --user=root -e "REVOKE ALL PRIVILEGES, GRANT OPTION FROM "$OREON_USER
    mysql --user=root -e "DROP USER "$OREON_USER
    mysql --user=root -e "DROP DATABASE IF EXISTS "$OREON_BASE 
    mysql --user=root -e "DROP DATABASE IF EXISTS "$OREON_BASE_DATA
    
    exit 0
    templates des questions pour debconf :

    Code:
    Template: oreon/php_modules
    Type: boolean
    Description: Do you want to install php modules ?
     If you want to install php module for Oreon manually or installing automatically using pear.
    
    Template: oreon/mysql_oreon_base
    Type: string
    Default: oreon
    Description: Which name for the oreon database do you want?
     This database is for stock configuration of nagios and oreon.
    
    Template: oreon/mysql_oreon_base_data
    Type: string
    Default: oreon_data
    Description: Which name for the oreon datastorage database do you want?
     This database is for stock data of graph and log generated by rrd.
    
    Template: oreon/mysql_oreon_user_for_database
    Type: string
    Default: oreon
    Description: Choose a pseudo for oreon's database access.
     This name is used for the two databases defined earlier.
    
    Template: oreon/mysql_oreon_password_for_database
    Type: string
    Default: oreon_admin
    Description: Choose a pass for oreon's database access.
     This pass is used for the two databases defined earlier.
    config pour debconf :

    Code:
    w#!/bin/sh -e
    
    action=$1
    version=$2
    
    #Source debconf library.
    . /usr/share/debconf/confmodule
    
    #Install or not the php modules.
    db_input critical oreon/php_modules || true
    db_input critical oreon/mysql_oreon_base || true
    db_input critical oreon/mysql_oreon_base_data || true
    db_input critical oreon/mysql_oreon_user_for_database || true
    db_input critical oreon/mysql_oreon_password_for_database || true
    db_go || true
    
    exit 0
    Bon tous ça est sujet à bien des modifications et vous parait problablement brouillons mais toute remarque constructive est la bienvenue pour améliorer ceci. Je ne sais pas si je vais pouvoir maintenir ces paquets ( ou au moins un ) mais pour l'instant ça semble bien parti.

    Comment


    • #3
      n'hésite pas à me contacter si tu veux de l'aide... ca m'interresse ton histoire de package...

      y a longtemps qu'on doit le faire...
      Julien Mathis
      Centreon Project Leader
      www.merethis.com |

      Comment


      • #4
        Et moi ça m'interresse votre histoire d'oreon ^^.

        Comment

        Working...
        X