Changeset 5734

Show
Ignore:
Timestamp:
07/16/08 23:36:50 (5 months ago)
Author:
watt
Message:

Install script: add new test for ticket #76. Print warning on stdout. Add more stuff to prepare upgrade.

Location:
trunk/centreon/libinstall
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • trunk/centreon/libinstall/Upgrade_1_4_to_2.sh

    r5297 r5734  
    11#!/bin/bash 
     2#---- 
     3## @Synopsis    Upgrade script version 1.4 to 2.0 for centreon 
     4## @Copyright  Copyright 2008, Guillaume Watteeux 
     5## @licence     GPL : http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt 
     6## TODO 
     7## * Backup CENTREON INSTALL DIR (www, cron, ...) 
     8## * Find cron (file or user) & backup 
     9## * Quid RRD base 
     10## * SQL changes 
     11## * Clean unused files ...  
     12## * Remove ODS 
     13## * ... 
     14 
     15#---- 
    216# Centreon Upgrade script 
    317################################# 
     
    822echo "$line" 
    923 
    10 ## TODO 
    11 # * Backup CENTREON INSTALL DIR (www, cron, ...) 
    12 # * Find cron (file or user) & backup 
    13 # * Quid RRD base 
    14 # * SQL changes 
    15 # * Clean unused files ...  
    16 # * Remove ODS 
    17 # * ... 
    18  
    1924 
    2025# I'm writing all upgrade functon on this script. And when all people will stop use centreon1.4. We just delete or unuse this script. 
    2126 
    22 ## Function locate_centreon_backupdir 
    23 # define directory where I move old centreon install. 
     27#--- 
     28## Define directory where I move old centreon install. 
     29## @Globals     CENTREON_BACKUPDIR, DEFAULT_CENTREON_BACKUPDIR 
     30#--- 
    2431function locate_centreon_backupdir() { 
    2532        if [ -z "$CENTREON_BACKUPDIR" ] ; then  
     
    3542} 
    3643 
    37 ## Function find_cron 
    38 # search in system who cron was define.  
    39 # need to valid there are not a user crontab (nagios) 
    40 # if /etc/cron.d/oreon or centreon exist, move and add by new install. 
     44#---- 
     45## search in system who cron was define.  
     46## @Globals     CRON_FILE 
     47## need to valid there are not a user crontab (nagios) 
     48## if /etc/cron.d/oreon or centreon exist, move and add by new install. 
     49#---- 
    4150function find_cron() { 
     51        local cron_type="" 
     52        local cron_type_choice="file user" 
     53        echo -e "$(gettext "Please select a type of cron method")" 
     54        select_in_array "cron_type" "${cron_type_choice[@]}" 
     55        if [ "$cron_type" = "user" ] ; then  
     56                is_cron_user 
     57        elif [ "$cron_type" = "file" ] ; then 
     58                is_cron_file 
     59        else 
     60                return 1 
     61        fi 
    4262 
     63        return 0 
    4364} 
    4465 
    4566## find in nagios user if crontab centreon exist and WARNING 
    4667 
     68#---- 
     69## Find in cron file if centreon's cron exist 
     70#---- 
     71function is_cron_file() { 
     72         
     73} 
     74 
     75#---- 
     76## Find in cron user if centreon's cron exist 
     77#---- 
     78function is_cron_user() { 
     79 
     80} 
  • trunk/centreon/libinstall/cinstall

    r5687 r5734  
    121121function usage() { 
    122122        local program=cinstall 
    123         cat << __EOT__ 
     123        ${CAT} << __EOT__ 
    124124 
    125125Usage: $program [OPTION]... SOURCE DEST 
  • trunk/centreon/libinstall/functions

    r5724 r5734  
    11931193 
    11941194#---- 
     1195## Find config problem on sudo 
     1196## If I found a problem, print a warning and need to press enter. 
     1197## @Globals    LOG_FILE 
     1198## @return 0   no problem in sudo file 
     1199## @return 1    possible problem in sudo file 
     1200#---- 
     1201function is_suspect_conf_sudo() { 
     1202        local sudo_file="$1" 
     1203        ${GREP} -e "^Defaults.*requiretty$" $sudo_file >> $LOG_FILE 2>&1 
     1204        if [ "$?" -eq 0 ] ; then 
     1205                echo_warning "$(gettext "I think you'll have a problem with\n'Default requiretty' in sudo file")" 
     1206                echo -e "$(gettext "Press enter to continue.")" 
     1207                read 
     1208                return 1 
     1209        fi 
     1210        return 0 
     1211} 
     1212 
     1213#---- 
    11951214## Configure Sudo on system  
    11961215## Need a directory to store a config  
     
    12261245        fi 
    12271246        log "INFO" "$(gettext "Please configure your sudo with this example"): $dir_conf/centreon.sudo" 
     1247        # Add a simple test for Defaults Requiretty problem on CentOS, Fedora... 
     1248        is_suspect_conf_sudo $SUDO_FILE 
    12281249        return 0 
    12291250} 
     
    20282049## file. After that, rewrite sudo file with clean file. 
    20292050## @param       0/1 to active a question to clean sudo (not by default) 
    2030 ## @Globals     SUDO_FILE, TMPDIR, LOG_FILE 
     2051## @param       sudo file 
     2052## @Globals     TMPDIR, LOG_FILE 
    20312053#---- 
    20322054function clean_sudo() { 
    20332055        local validate=${1:-0} 
    20342056        local RC=1 
    2035         local sudo_old="$SUDO_FILE" 
    2036         local sudo_clean="$TMPDIR/$SUDO_FILE.clean" 
     2057        local sudo_old="$2" 
     2058        local sudo_clean="$TMPDIR/$sudo_old.clean" 
    20372059 
    20382060        ${CAT} $sudo_old | \