"Fossies" - the Fresh Open Source Software Archive

Member "OCSNG_UNIX_SERVER_2.6/setup.sh" (17 Apr 2019, 72918 Bytes) of package /linux/privat/OCSNG_UNIX_SERVER_2.6.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Bash source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. See also the latest Fossies "Diffs" side-by-side code changes report for "setup.sh": 2.5_vs_2.6.

    1 #!/bin/sh
    2 ################################################################################
    3 #
    4 # OCS Inventory NG Management Server Setup
    5 #
    6 # Copyleft 2006 Didier LIROULET
    7 # Web: http://www.ocsinventory-ng.org
    8 #
    9 # This code is open source and may be copied and modified as long as the source
   10 # code is always made freely available.
   11 # Please refer to the General Public Licence http://www.gnu.org/ or Licence.txt
   12 ################################################################################
   13 #
   14 
   15 # Which host run database server
   16 DB_SERVER_HOST="localhost"
   17 # On which port run database server
   18 DB_SERVER_PORT="3306"
   19 # Database server credentials
   20 DB_SERVER_USER="ocs"
   21 DB_SERVER_PWD="ocs"
   22 # Where is Apache daemon binary (if empty, will try to find it)
   23 APACHE_BIN=""
   24 # Where is Apache configuration file (if empty, will try to find it)
   25 APACHE_CONFIG_FILE=""
   26 # Where is Apache includes configuration directory (if emty, will try to find it)
   27 APACHE_CONFIG_DIRECTORY=""
   28 # Which user is running Apache web server (if empty, will try to find it)
   29 APACHE_USER=""
   30 # Which group is running Apache web server (if empty, will try to find it)
   31 APACHE_GROUP=""
   32 # Where is Apache document root directory (if empty, will try to find it)
   33 APACHE_ROOT_DOCUMENT=""
   34 # Which version of mod_perl is apache using,  1 for <= 1.999_21 and 2 for >= 1.999_22 (if empty, user will be asked for)
   35 APACHE_MOD_PERL_VERSION=""
   36 # Where are located OCS Communication server log files
   37 OCS_COM_SRV_LOG="/var/log/ocsinventory-server"
   38 # Where are located OCS Communication server plugins configuration files
   39 OCS_COM_SRV_PLUGINS_CONFIG_DIR="/etc/ocsinventory-server/plugins"
   40 # Where are located OCS Communication server plugins perl files
   41 OCS_COM_SRV_PLUGINS_PERL_DIR="/etc/ocsinventory-server/perl"
   42 # Where is located perl interpreter
   43 PERL_BIN=`which perl 2>/dev/null`
   44 # Where is located make utility
   45 MAKE=`which make 2>/dev/null`
   46 # Where is located logrotate configuration directory
   47 LOGROTATE_CONF_DIR="/etc/logrotate.d"
   48 # Where is located newsyslog.conf
   49 NEWSYSLOG_CONF_FILE="/etc/newsyslog.conf"
   50 # Where to store setup logs
   51 SETUP_LOG=`pwd`/ocs_server_setup.log
   52 # Communication Server Apache configuration file
   53 COM_SERVER_APACHE_CONF_FILE="ocsinventory-server.conf"
   54 # Rest API configuration file
   55 API_REST_APACHE_CONF_FILE="ocsinventory-restapi.conf"
   56 # Communication Server logrotate configuration file
   57 COM_SERVER_LOGROTATE_CONF_FILE="ocsinventory-server"
   58 # Administration Console Apache configuration file
   59 ADM_SERVER_APACHE_CONF_FILE="ocsinventory-reports.conf"
   60 # Administration console read only files directory
   61 ADM_SERVER_STATIC_DIR="/usr/share/ocsinventory-reports"
   62 ADM_SERVER_STATIC_REPORTS_DIR="ocsreports"
   63 ADM_SERVER_REPORTS_ALIAS="/ocsreports"
   64 # Administration console read/write files dir
   65 ADM_SERVER_VAR_DIR="/var/lib/ocsinventory-reports"
   66 # Administration default packages directory and Apache alias
   67 ADM_SERVER_VAR_PACKAGES_DIR="download"
   68 ADM_SERVER_PACKAGES_ALIAS="/download"
   69 # Administration default snmp directory and Apache alias
   70 ADM_SERVER_VAR_SNMP_DIR="snmp"
   71 ADM_SERVER_SNMP_ALIAS="/snmp"
   72 # Administration console log files dir
   73 ADM_SERVER_VAR_LOGS_DIR="logs"
   74 # Administration console scripts log files dir
   75 ADM_SERVER_VAR_SCRIPTS_LOGS_DIR="scripts"
   76 # Administration console default ipdsicover-util.pl cache dir
   77 ADM_SERVER_VAR_IPD_DIR="ipd"
   78 # OS or linux distribution from automatic detection
   79 UNIX_DISTRIBUTION=""
   80 # Default install directory for rest api
   81 REST_API_DIRECTORY=""
   82 
   83 ###################### DO NOT MODIFY BELOW #######################
   84 
   85 # Check for Apache web server binaries
   86 echo
   87 echo "+----------------------------------------------------------+"
   88 echo "|                                                          |"
   89 echo "|  Welcome to OCS Inventory NG Management server setup !   |"
   90 echo "|                                                          |"
   91 echo "+----------------------------------------------------------+"
   92 echo
   93 
   94 # Check for OS or linux distribution
   95 echo "Trying to determine which OS or Linux distribution you use"
   96 
   97 if [ -f /etc/redhat-release ]
   98     then
   99         UNIX_DISTRIBUTION="redhat"
  100 elif [ -f /etc/debian_version ]
  101     then
  102         UNIX_DISTRIBUTION="debian"
  103 elif [ -f /etc/SuSE-release ]
  104     then
  105         UNIX_DISTRIBUTION="suse"
  106 fi
  107 
  108 # Check for Apache web server binaries
  109 echo "+----------------------------------------------------------+"
  110 echo "| Checking for Apache web server binaries !               |"
  111 echo "+----------------------------------------------------------+"
  112 echo
  113 
  114 echo "CAUTION: If upgrading Communication server from OCS Inventory NG 1.0 RC2 and"
  115 echo "previous, please remove any Apache configuration for Communication Server!"
  116 echo
  117 echo -n "Do you wish to continue ([y]/n)?"
  118 read ligne
  119 if [ -z "$ligne" ] || [ "$ligne" = "y" ] || [ "$ligne" = "Y" ]
  120     then
  121         echo "Assuming Communication server 1.0 RC2 or previous is not installed"
  122         echo "on this computer."
  123         echo
  124     else
  125         echo "Installation aborted !"
  126         echo
  127         exit 1
  128 fi
  129 
  130 echo > $SETUP_LOG
  131 OCS_LOCAL_DATE=`date +%Y-%m-%d-%H-%M-%S`
  132 echo "Starting OCS Inventory NG Management server setup on $OCS_LOCAL_DATE" >> $SETUP_LOG
  133 echo -n "from folder " >> $SETUP_LOG
  134 pwd >> $SETUP_LOG
  135 echo -n "Starting OCS Inventory NG Management server setup from folder "
  136 pwd
  137 echo "Storing log in file $SETUP_LOG" >> $SETUP_LOG
  138 echo "Storing log in file $SETUP_LOG"
  139 echo >> $SETUP_LOG
  140 
  141 echo "============================================================" >> $SETUP_LOG
  142 echo "Checking OCS Inventory NG Management Server requirements..." >> $SETUP_LOG
  143 echo "============================================================" >> $SETUP_LOG
  144 echo
  145 echo "+----------------------------------------------------------+"
  146 echo "| Checking for database server properties...            |"
  147 echo "+----------------------------------------------------------+"
  148 echo
  149 
  150 # Check mysql client distribution version
  151 echo "Checking for database server properties" >> $SETUP_LOG
  152 DB_CLIENT_MAJOR_VERSION=`eval mysql -V | cut -d' ' -f6 | cut -d'.' -f1` >> $SETUP_LOG 2>&1
  153 DB_CLIENT_MINOR_VERSION=`eval mysql -V | cut -d' ' -f6 | cut -d'.' -f2` >> $SETUP_LOG 2>&1
  154 echo "Your MySQL client seems to be part of MySQL version $DB_CLIENT_MAJOR_VERSION.$DB_CLIENT_MINOR_VERSION."
  155 echo "MySQL client distribution version $DB_CLIENT_MAJOR_VERSION.$DB_CLIENT_MINOR_VERSION." >> $SETUP_LOG
  156 
  157 # Ensure mysql distribution is 4.1 or higher
  158 if [ $DB_CLIENT_MAJOR_VERSION -gt 4 ]
  159     then
  160         res=1
  161     else
  162         if [ $DB_CLIENT_MAJOR_VERSION -eq 4 ]
  163             then
  164                 if [ $DB_CLIENT_MINOR_VERSION -eq 1 ]
  165                     then
  166                         res=1
  167                     else
  168                         res=0
  169                 fi
  170             else
  171                 res=0
  172         fi
  173 fi
  174 if [ $res -eq 0 ]
  175     then
  176         # Not 4.1 or higher, ask user to contnue ?
  177         echo "Your computer does not seem to be compliant with MySQL 4.1 or higher."
  178         echo -n "Do you wish to continue (y/[n])?"
  179         read ligne
  180         if [ "$ligne" = "y" ]
  181             then
  182                 echo "Ensure your database server is running MySQL 4.1 or higher !"
  183                 echo "Ensure also this computer is able to connect to your MySQL server !"
  184             else
  185                 echo "Installation aborted !"
  186                 exit 1
  187         fi
  188     else
  189         echo "Your computer seems to be running MySQL 4.1 or higher, good ;-)"
  190         echo "Computer seems to be running MySQL 4.1 or higher" >> $SETUP_LOG
  191 fi
  192 echo
  193 
  194 # Ask user for database server host
  195 res=0
  196 while [ $res -eq 0 ]
  197     do
  198         echo -n "Which host is running database server [$DB_SERVER_HOST] ?"
  199         read ligne
  200         if [ -z "$ligne" ]
  201             then
  202                 res=1
  203             else
  204                 DB_SERVER_HOST="$ligne"
  205                 res=1
  206         fi
  207 done
  208 
  209 echo "OK, database server is running on host $DB_SERVER_HOST ;-)"
  210 echo "Database server is running on host $DB_SERVER_HOST" >> $SETUP_LOG
  211 echo
  212 
  213 # Ask user for database server port
  214 res=0
  215 while [ $res -eq 0 ]
  216 do
  217     echo -n "On which port is running database server [$DB_SERVER_PORT] ?"
  218     read ligne
  219     if [ -z "$ligne" ]
  220         then
  221             res=1
  222         else
  223             DB_SERVER_PORT="$ligne"
  224             res=1
  225     fi
  226 done
  227 
  228 echo "OK, database server is running on port $DB_SERVER_PORT ;-)"
  229 echo "Database server is running on port $DB_SERVER_PORT" >> $SETUP_LOG
  230 echo
  231 
  232 echo
  233 echo "+----------------------------------------------------------+"
  234 echo "| Checking for Apache web server daemon...                |"
  235 echo "+----------------------------------------------------------+"
  236 echo
  237 echo "Checking for Apache web server daemon" >> $SETUP_LOG
  238 
  239 # Try to find Apache daemon
  240 if [ -z "$APACHE_BIN" ]
  241     then
  242         APACHE_BIN_FOUND=`which httpd 2>/dev/null`
  243         if [ -z "$APACHE_BIN_FOUND" ]
  244             then
  245                 APACHE_BIN_FOUND=`which apache2ctl 2>/dev/null`
  246                 if [ -z "$APACHE_BIN_FOUND" ]
  247                     then
  248                         APACHE_BIN_FOUND=`which apachectl 2>/dev/null`
  249                         if [ -z "$APACHE_BIN_FOUND" ]
  250                             then
  251                                 APACHE_BIN_FOUND=`which httpd2 2>/dev/null`
  252                         fi
  253                 fi
  254         fi
  255 fi
  256 echo "Found Apache daemon $APACHE_BIN_FOUND" >> $SETUP_LOG
  257 
  258 # Ask user's confirmation
  259 res=0
  260 while [ $res -eq 0 ]
  261     do
  262         echo -n "Where is Apache daemon binary [$APACHE_BIN_FOUND] ?"
  263         read ligne
  264         if [ -z "$ligne" ]
  265             then
  266                 APACHE_BIN=$APACHE_BIN_FOUND
  267             else
  268                 APACHE_BIN="$ligne"
  269         fi
  270         # Ensure file exists and is executable
  271         if [ -x $APACHE_BIN ]
  272             then
  273                 res=1
  274             else
  275                 echo "*** ERROR: $APACHE_BIN is not executable !"
  276                 res=0
  277         fi
  278         # Ensure file is not a directory
  279         if [ -d $APACHE_BIN ]
  280             then
  281                 echo "*** ERROR: $APACHE_BIN is a directory !"
  282                 res=0
  283         fi
  284 done
  285 echo "OK, using Apache daemon $APACHE_BIN ;-)"
  286 echo "Using Apache daemon $APACHE_BIN" >> $SETUP_LOG
  287 echo
  288 
  289 echo
  290 echo "+----------------------------------------------------------+"
  291 echo "| Checking for Apache main configuration file...        |"
  292 echo "+----------------------------------------------------------+"
  293 echo
  294 
  295 # Try to find Apache main configuration file
  296 echo "Checking for Apache main configuration file" >> $SETUP_LOG
  297 if [ -z "$APACHE_CONFIG_FILE" ]
  298     then
  299         APACHE_ROOT=`eval $APACHE_BIN -V | grep "HTTPD_ROOT" | cut -d'=' -f2 | tr -d '"'`
  300         echo "Found Apache HTTPD_ROOT $APACHE_ROOT" >> $SETUP_LOG
  301         APACHE_CONFIG=`eval $APACHE_BIN -V | grep "SERVER_CONFIG_FILE" | cut -d'=' -f2 | tr -d '"'`
  302         echo "Found Apache SERVER_CONFIG_FILE $APACHE_CONFIG" >> $SETUP_LOG
  303         if [ -e $APACHE_CONFIG ]
  304             then
  305                 APACHE_CONFIG_FILE_FOUND="$APACHE_CONFIG"
  306             else
  307                 APACHE_CONFIG_FILE_FOUND="$APACHE_ROOT/$APACHE_CONFIG"
  308         fi
  309 fi
  310 echo "Found Apache main configuration file $APACHE_CONFIG_FILE_FOUND" >> $SETUP_LOG
  311 
  312 # Ask user's confirmation
  313 res=0
  314 while [ $res -eq 0 ]
  315     do
  316         echo -n "Where is Apache main configuration file [$APACHE_CONFIG_FILE_FOUND] ?"
  317         read ligne
  318         if [ -z "$ligne" ]
  319             then
  320                 APACHE_CONFIG_FILE=$APACHE_CONFIG_FILE_FOUND
  321             else
  322                 APACHE_CONFIG_FILE="$ligne"
  323         fi
  324         # Ensure file is not a directory
  325         if [ -d $APACHE_CONFIG_FILE ]
  326             then
  327                 echo "*** ERROR: $APACHE_CONFIG_FILE is a directory !"
  328                 res=0
  329         fi
  330         # Ensure file exists and is readable
  331         if [ -r $APACHE_CONFIG_FILE ]
  332             then
  333                 res=1
  334             else
  335                 echo "*** ERROR: $APACHE_CONFIG_FILE is not readable !"
  336                 res=0
  337         fi
  338 done
  339 echo "OK, using Apache main configuration file $APACHE_CONFIG_FILE ;-)"
  340 echo "Using Apache main configuration file $APACHE_CONFIG_FILE" >> $SETUP_LOG
  341 echo
  342 
  343 echo
  344 echo "+----------------------------------------------------------+"
  345 echo "| Checking for Apache user account...                  |"
  346 echo "+----------------------------------------------------------+"
  347 echo
  348 
  349 # Try to find Apache main configuration file
  350 echo "Checking for Apache user account" >> $SETUP_LOG
  351 if [ -z "$APACHE_USER" ]
  352     then
  353         case $UNIX_DISTRIBUTION in
  354             "debian")
  355                 if [ -f /etc/apache2/envvars ]
  356                     then
  357                         . /etc/apache2/envvars
  358                 fi
  359                 APACHE_USER_FOUND=$APACHE_RUN_USER
  360             ;;
  361             "suse")
  362                 if [ -f /etc/apache2/uid.conf ]
  363                     then
  364                         APACHE_USER_FOUND=`cat /etc/apache2/uid.conf | grep "User" | tail -1 | cut -d' ' -f2`
  365                 fi
  366             ;;
  367             "redhat")
  368                 APACHE_USER_FOUND=`cat $APACHE_CONFIG_FILE | grep "User " | tail -1 | cut -d' ' -f2`
  369             ;;
  370         esac
  371 fi
  372 echo "Found Apache user account $APACHE_USER_FOUND" >> $SETUP_LOG
  373 
  374 # Ask user's confirmation
  375 res=0
  376 while [ $res -eq 0 ]
  377     do
  378         echo -n "Which user account is running Apache web server [$APACHE_USER_FOUND] ?"
  379         read ligne
  380         if [ -z "$ligne" ]
  381             then
  382                 APACHE_USER=$APACHE_USER_FOUND
  383             else
  384                 APACHE_USER="$ligne"
  385         fi
  386         # Ensure group exist in /etc/passwd
  387         if [ `cat /etc/passwd | grep $APACHE_USER | wc -l` -eq 0 ]
  388             then
  389                 echo "*** ERROR: account $APACHE_USER not found in system table /etc/passwd !"
  390             else
  391                 res=1
  392         fi
  393 done
  394 echo "OK, Apache is running under user account $APACHE_USER ;-)"
  395 echo "Using Apache user account $APACHE_USER" >> $SETUP_LOG
  396 echo
  397 
  398 echo
  399 echo "+----------------------------------------------------------+"
  400 echo "| Checking for Apache group...                            |"
  401 echo "+----------------------------------------------------------+"
  402 echo
  403 
  404 # Try to find Apache main configuration file
  405 echo "Checking for Apache group" >> $SETUP_LOG
  406 if [ -z "$APACHE_GROUP" ]
  407     then
  408         case $UNIX_DISTRIBUTION in
  409             "debian")
  410                 if [ -f /etc/apache2/envvars ]
  411                     then
  412                         . /etc/apache2/envvars
  413                 fi
  414                 APACHE_GROUP_FOUND=$APACHE_RUN_USER
  415             ;;
  416             "suse")
  417                 if [ -f /etc/apache2/uid.conf ]
  418                     then
  419                         APACHE_GROUP_FOUND=`cat /etc/apache2/uid.conf | grep "Group" | tail -1 | cut -d' ' -f2`
  420                 fi
  421             ;;
  422             "redhat")
  423                 APACHE_GROUP_FOUND=`cat $APACHE_CONFIG_FILE | grep "Group " | tail -1 | cut -d' ' -f2`
  424             ;;
  425         esac
  426 
  427         if [ -z "$APACHE_GROUP_FOUND" ]
  428             then
  429                 # No group found, assume group name is the same as account
  430                 echo "No Apache user group found, assuming group name is the same as user account" >> $SETUP_LOG
  431                 APACHE_GROUP_FOUND=$APACHE_USER
  432         fi
  433 fi
  434 echo "Found Apache user group $APACHE_GROUP_FOUND" >> $SETUP_LOG
  435 
  436 # Ask user's confirmation
  437 res=0
  438 while [ $res -eq 0 ]
  439     do
  440         echo -n "Which user group is running Apache web server [$APACHE_GROUP_FOUND] ?"
  441         read ligne
  442         if [ -z "$ligne" ]
  443             then
  444                 APACHE_GROUP=$APACHE_GROUP_FOUND
  445             else
  446                 APACHE_GROUP="$ligne"
  447         fi
  448         # Ensure group exist in /etc/group
  449         if [ `cat /etc/group | grep $APACHE_GROUP | wc -l` -eq 0 ]
  450             then
  451                 echo "*** ERROR: group $APACHE_GROUP not found in system table /etc/group !"
  452             else
  453                 res=1
  454         fi
  455 done
  456 echo "OK, Apache is running under users group $APACHE_GROUP ;-)"
  457 echo "Using Apache user group $APACHE_GROUP" >> $SETUP_LOG
  458 echo
  459 
  460 
  461 echo
  462 echo "+----------------------------------------------------------+"
  463 echo "| Checking for Apache Include configuration directory...   |"
  464 echo "+----------------------------------------------------------+"
  465 echo
  466 
  467 # Try to find Apache includes configuration directory
  468 echo "Checking for Apache Include configuration directory" >> $SETUP_LOG
  469 if [ -z "$APACHE_CONFIG_DIRECTORY" ]
  470     then
  471         if [ -d "$APACHE_ROOT/conf.d" ]
  472             then
  473                 APACHE_CONFIG_DIRECTORY_FOUND="$APACHE_ROOT/conf.d"
  474         elif [ -d "$APACHE_ROOT/conf-available" ]
  475             then
  476                 APACHE_CONFIG_DIRECTORY_FOUND="$APACHE_ROOT/conf-available"
  477             else
  478                 APACHE_CONFIG_DIRECTORY_FOUND=""
  479         fi
  480 
  481         if [ -d "$APACHE_CONFIG_DIRECTORY_FOUND" ]
  482             then
  483                 echo "Found Apache Include configuration directory $APACHE_CONFIG_DIRECTORY_FOUND" >> $SETUP_LOG
  484         fi
  485 fi
  486 
  487 # Ask user's confirmation
  488 echo "Setup found Apache Include configuration directory in"
  489 echo "$APACHE_CONFIG_DIRECTORY_FOUND."
  490 echo "Setup will put OCS Inventory NG Apache configuration in this directory."
  491 res=0
  492 while [ $res -eq 0 ]
  493     do
  494         echo -n "Where is Apache Include configuration directory [$APACHE_CONFIG_DIRECTORY_FOUND] ?"
  495         read ligne
  496         if [ -z "$ligne" ]
  497             then
  498                 APACHE_CONFIG_DIRECTORY=$APACHE_CONFIG_DIRECTORY_FOUND
  499             else
  500                 APACHE_CONFIG_DIRECTORY="$ligne"
  501         fi
  502 
  503         # Ensure file is a directory
  504         if [ -d $APACHE_CONFIG_DIRECTORY ]
  505             then
  506                 res=1
  507             else
  508                 echo "*** ERROR: $APACHE_CONFIG_DIRECTORY is not a directory !"
  509                 res=0
  510         fi
  511 
  512         # Ensure directory exists and is writable
  513         if [ -w $APACHE_CONFIG_DIRECTORY ]
  514             then
  515                 res=1
  516             else
  517                 echo "*** ERROR: $APACHE_CONFIG_DIRECTORY is not writable !"
  518                 res=0
  519         fi
  520 done
  521 
  522 echo "OK, Apache Include configuration directory $APACHE_CONFIG_DIRECTORY found ;-)"
  523 echo "Using Apache Include configuration directory $APACHE_CONFIG_DIRECTORY" >> $SETUP_LOG
  524 echo
  525 
  526 
  527 echo
  528 echo "+----------------------------------------------------------+"
  529 echo "| Checking for PERL Interpreter...                        |"
  530 echo "+----------------------------------------------------------+"
  531 echo
  532 
  533 echo "Checking for PERL Interpreter" >> $SETUP_LOG
  534 if [ -z "$PERL_BIN" ]
  535     then
  536         echo "PERL Interpreter not found !"
  537         echo "PERL Interpreter not found" >> $SETUP_LOG
  538         echo "OCS Inventory NG is not able to work without PERL Interpreter."
  539         echo "Setup manually PERL first."
  540         echo "Installation aborted !"
  541         echo "installation aborted" >> $SETUP_LOG
  542         exit 1
  543     else
  544         echo "Found PERL interpreter at <$PERL_BIN> ;-)"
  545         echo "Found PERL interpreter at <$PERL_BIN>" >> $SETUP_LOG
  546 fi
  547 
  548 # Ask user's confirmation
  549 res=0
  550 while [ $res -eq 0 ]
  551     do
  552         echo -n "Where is PERL interpreter binary [$PERL_BIN] ?"
  553         read ligne
  554         if [ -n "$ligne" ]
  555             then
  556                 PERL_BIN="$ligne"
  557         fi
  558 
  559         # Ensure file exists and is executable
  560         if [ -x $PERL_BIN ]
  561             then
  562                 res=1
  563             else
  564                 echo "*** ERROR: $PERL_BIN is not executable !"
  565                 res=0
  566         fi
  567 
  568         # Ensure file is not a directory
  569         if [ -d $PERL_BIN ]
  570             then
  571                 echo "*** ERROR: $PERL_BIN is a directory !"
  572                 res=0
  573         fi
  574 done
  575 
  576 echo "OK, using PERL interpreter $PERL_BIN ;-)"
  577 echo "Using PERL interpreter $PERL_BIN" >> $SETUP_LOG
  578 echo
  579 
  580 
  581 echo
  582 echo -n "Do you wish to setup Communication server on this computer ([y]/n)?"
  583 read ligne
  584 if [ -z "$ligne" ] || [ "$ligne" = "y" ] || [ "$ligne" = "Y" ]
  585     then
  586         # Setting up Communication server
  587         echo >> $SETUP_LOG
  588         echo "============================================================" >> $SETUP_LOG
  589         echo "Installing Communication server" >> $SETUP_LOG
  590         echo "============================================================" >> $SETUP_LOG
  591         echo
  592 
  593         echo
  594         echo "+----------------------------------------------------------+"
  595         echo "|             Checking for Make utility...                 |"
  596         echo "+----------------------------------------------------------+"
  597         echo
  598 
  599         echo "Checking for Make utility" >> $SETUP_LOG
  600         if [ -z "$MAKE" ]
  601             then
  602                 echo "Make utility not found !"
  603                 echo "Make utility not found" >> $SETUP_LOG
  604                 echo "Setup is not able to build OCS Inventory NG Perl module."
  605                 echo "Unable to build OCS Inventory NG Perl module !" >> $SETUP_LOG
  606                 exit 1
  607             else
  608                 echo "OK, Make utility found at <$MAKE> ;-)"
  609                 echo "Make utility found at <$MAKE>" >> $SETUP_LOG
  610         fi
  611         echo
  612 
  613         echo "+----------------------------------------------------------+"
  614         echo "|        Checking for Apache mod_perl version...           |"
  615         echo "+----------------------------------------------------------+"
  616         echo
  617 
  618         echo "Checking for Apache mod_perl version 1.99_22 or higher"
  619         echo "Checking for Apache mod_perl version 1.99_22 or higher" >> $SETUP_LOG
  620         $PERL_BIN -mmod_perl2 -e 'print "mod_perl 1.99_22 or higher is available\n"' >> $SETUP_LOG 2>&1
  621         if [ $? -ne 0 ]
  622             then
  623                 # mod_perl 2 not found !
  624                 echo "Checking for Apache mod_perl version 1.99_21 or previous"
  625                 echo "Checking for Apache mod_perl version 1.99_21 or previous" >> $SETUP_LOG
  626                 $PERL_BIN -mmod_perl -e 'print "mod_perl 1.99_21 or previous is available\n"' >> $SETUP_LOG 2>&1
  627                 if [ $? -ne 0 ]
  628                     then
  629                         # mod_perl 1 not found => Ask user
  630                         res=0
  631                         while [ $res -eq 0 ]
  632                             do
  633                                 echo "Setup is unable to determine your Apache mod_perl version."
  634                                 echo "Apache must have module mod_perl enabled. As configuration differs from"
  635                                 echo "mod_perl 1.99_21 or previous AND mod_perl 1.99_22 or higher, Setup must"
  636                                 echo "know which release Apache is using."
  637                                 echo "You can find which release you are using by running the following command"
  638                                 echo "  - On RPM enabled OS, rpm -q mod_perl"
  639                                 echo "  - On DPKG enabled OS, dpkg -l libapache*-mod-perl*"
  640                                 echo "Enter 1 for mod_perl 1.99_21 or previous."
  641                                 echo "Enter 2 for mod_perl 1.99_22 and higher."
  642                                 echo -n "Which version of Apache mod_perl the computer is running ([1]/2) ?"
  643                                 read ligne
  644                                 if [ -z "$ligne" ]
  645                                     then
  646                                         APACHE_MOD_PERL_VERSION=1
  647                                     else
  648                                         APACHE_MOD_PERL_VERSION=$ligne
  649                                 fi
  650                                 res=1
  651                         done
  652                     else
  653                         echo "Found that mod_perl version 1.99_21 or previous is available."
  654                         APACHE_MOD_PERL_VERSION=1
  655                 fi
  656             else
  657                 echo "Found that mod_perl version 1.99_22 or higher is available."
  658                 APACHE_MOD_PERL_VERSION=2
  659         fi
  660         if [ $APACHE_MOD_PERL_VERSION -eq 1 ]
  661             then
  662                 echo "OK, Apache is using mod_perl version 1.99_21 or previous ;-)"
  663                 echo "Using mod_perl version 1.99_21 or previous" >> $SETUP_LOG
  664             else
  665                 echo "OK, Apache is using mod_perl version 1.99_22 or higher ;-)"
  666                 echo "Using mod_perl version 1.99_22 or higher" >> $SETUP_LOG
  667         fi
  668         echo
  669 
  670         echo "+----------------------------------------------------------+"
  671         echo "|    Checking for Communication server log directory...    |"
  672         echo "+----------------------------------------------------------+"
  673         echo
  674         echo "Checking for Communication server log directory" >> $SETUP_LOG
  675 
  676         # Ask user
  677         res=0
  678         while [ $res -eq 0 ]
  679             do
  680                 echo "Communication server can create detailed logs. This logs can be enabled"
  681                 echo "by setting integer value of LOGLEVEL to 1 in Administration console"
  682                 echo "menu Configuration."
  683                 echo -n "Where to put Communication server log directory [$OCS_COM_SRV_LOG] ?"
  684                 read ligne
  685                 if [ -n "$ligne" ]
  686                     then
  687                         OCS_COM_SRV_LOG=$ligne
  688                 fi
  689                 res=1
  690         done
  691 
  692         echo "OK, Communication server will put logs into directory $OCS_COM_SRV_LOG ;-)"
  693         echo "Using $OCS_COM_SRV_LOG as Communication server log directory" >> $SETUP_LOG
  694         echo
  695 
  696 
  697         echo "+----------------------------------------------------------------------------+"
  698         echo "|    Checking for Communication server plugins configuration directory...    |"
  699         echo "+----------------------------------------------------------------------------+"
  700         echo
  701         echo "Checking for Communication server plugins configuration directory" >> $SETUP_LOG
  702 
  703         # Ask user
  704         res=0
  705         while [ $res -eq 0 ]
  706             do
  707                 echo "Communication server need a directory for plugins configuration files. "
  708                 echo -n "Where to put Communication server plugins configuration files [$OCS_COM_SRV_PLUGINS_CONFIG_DIR] ?"
  709                 read ligne
  710                 if [ -n "$ligne" ]
  711                     then
  712                         OCS_COM_SRV_PLUGINS_CONFIG_DIR=$ligne
  713                 fi
  714                 res=1
  715         done
  716         echo "OK, Communication server will put plugins configuration files into directory $OCS_COM_SRV_PLUGINS_CONFIG_DIR ;-)"
  717         echo "Using $OCS_COM_SRV_PLUGINS_CONFIG_DIR as Communication server plugins configuration directory" >> $SETUP_LOG
  718         echo
  719 
  720 
  721         echo "+-------------------------------------------------------------------+"
  722         echo "|   Checking for Communication server plugins perl directory...     |"
  723         echo "+-------------------------------------------------------------------+"
  724         echo
  725         echo "Checking for Communication server perl directory" >> $SETUP_LOG
  726 
  727         # Ask user
  728         res=0
  729         while [ $res -eq 0 ]
  730             do
  731                 echo "Communication server need a directory for plugins Perl modules files."
  732                 echo -n "Where to put Communication server plugins Perl modules files [$OCS_COM_SRV_PLUGINS_PERL_DIR] ?"
  733                 read ligne
  734                 if [ -n "$ligne" ]
  735                     then
  736                         OCS_COM_SRV_PLUGINS_PERL_DIR=$ligne
  737                 fi
  738                 res=1
  739         done
  740         echo "OK, Communication server will put plugins Perl modules files into directory $OCS_COM_SRV_PLUGINS_PERL_DIR ;-)"
  741         echo "Using $OCS_COM_SRV_PLUGINS_PERL_DIR as Communication server plugins perl directory" >> $SETUP_LOG
  742         echo
  743 
  744         # jump to communication server directory
  745         echo "Entering Apache sub directory" >> $SETUP_LOG
  746 
  747         # Check for required Perl Modules (if missing, please install before)
  748         #   - DBI 1.40 or higher
  749         #   - Apache::DBI 0.93 or higher
  750         #   - DBD::mysql 2.9004 or higher
  751         #   - Compress::Zlib 1.33 or higher
  752         #   - XML::Simple 2.12 or higher
  753         #   - Net::IP 1.21 or higher
  754         #   - SOAP::Lite
  755         #   - Archive::Zip
  756         echo
  757         echo "+----------------------------------------------------------+"
  758         echo "| Checking for required Perl Modules...                   |"
  759         echo "+----------------------------------------------------------+"
  760         echo
  761 
  762         REQUIRED_PERL_MODULE_MISSING=0
  763         DBI=0
  764         APACHE_DBI=0
  765         DBD_MYSQL=0
  766         COMPRESS_ZLIB=0
  767         XML_SIMPLE=0
  768         NET_IP=0
  769         SOAP_LITE=0
  770         ARCHIVE_ZIP=0
  771 
  772         echo "Checking for DBI PERL module..."
  773         echo "Checking for DBI PERL module" >> $SETUP_LOG
  774         $PERL_BIN -mDBI -e 'print "PERL module DBI is available\n"' >> $SETUP_LOG 2>&1
  775         if [ $? -ne 0 ]
  776             then
  777                 echo "*** ERROR: PERL module DBI is not installed !"
  778                 REQUIRED_PERL_MODULE_MISSING=1
  779                 DBI=1
  780             else
  781                 echo "Found that PERL module DBI is available."
  782         fi
  783 
  784         echo "Checking for Apache::DBI PERL module..."
  785         echo "Checking for Apache::DBI PERL module" >> $SETUP_LOG
  786         $PERL_BIN -mApache::DBI -e 'print "PERL module Apache::DBI is available\n"' >> $SETUP_LOG 2>&1
  787         if [ $? -ne 0 ]
  788             then
  789                 echo "*** ERROR: PERL module Apache::DBI is not installed !"
  790                 REQUIRED_PERL_MODULE_MISSING=1
  791                 APACHE_DBI=1
  792             else
  793                 echo "Found that PERL module Apache::DBI is available."
  794         fi
  795 
  796         echo "Checking for DBD::mysql PERL module..."
  797         echo "Checking for DBD::mysql PERL module" >> $SETUP_LOG
  798         $PERL_BIN -mDBD::mysql -e 'print "PERL module DBD::mysql is available\n"' >> $SETUP_LOG 2>&1
  799         if [ $? -ne 0 ]
  800             then
  801                 echo "*** ERROR: PERL module DBD::mysql is not installed !"
  802                 REQUIRED_PERL_MODULE_MISSING=1
  803                 DBD_MYSQL=1
  804             else
  805                 echo "Found that PERL module DBD::mysql is available."
  806         fi
  807 
  808         echo "Checking for Compress::Zlib PERL module..."
  809         echo "Checking for Compress::Zlib PERL module" >> $SETUP_LOG
  810         $PERL_BIN -mCompress::Zlib -e 'print "PERL module Compress::Zlib is available\n"' >> $SETUP_LOG 2>&1
  811         if [ $? -ne 0 ]
  812             then
  813                 echo "*** ERROR: PERL module Compress::Zlib is not installed !"
  814                 REQUIRED_PERL_MODULE_MISSING=1
  815                 COMPRESS_ZLIB=1
  816             else
  817                 echo "Found that PERL module Compress::Zlib is available."
  818         fi
  819 
  820         echo "Checking for XML::Simple PERL module..."
  821         echo "Checking for XML::Simple PERL module" >> $SETUP_LOG
  822         $PERL_BIN -mXML::Simple -e 'print "PERL module XML::Simple is available\n"' >> $SETUP_LOG 2>&1
  823         if [ $? -ne 0 ]
  824             then
  825                 echo "*** ERROR: PERL module XML::Simple is not installed !"
  826                 REQUIRED_PERL_MODULE_MISSING=1
  827                 XML_SIMPLE=1
  828             else
  829                 echo "Found that PERL module XML::Simple is available."
  830         fi
  831 
  832         echo "Checking for Net::IP PERL module..."
  833         echo "Checking for Net::IP PERL module" >> $SETUP_LOG
  834         $PERL_BIN -mNet::IP -e 'print "PERL module Net::IP is available\n"' >> $SETUP_LOG 2>&1
  835         if [ $? -ne 0 ]
  836             then
  837                 echo "*** ERROR: PERL module Net::IP is not installed !"
  838                 REQUIRED_PERL_MODULE_MISSING=1
  839                 NET_IP=1
  840             else
  841                 echo "Found that PERL module Net::IP is available."
  842         fi
  843 
  844         # Check for SOAP::Lite
  845         echo "Checking for SOAP::Lite Perl module..."
  846         echo "Checking for SOAP::Lite Perl module" >> $SETUP_LOG
  847         $PERL_BIN -mSOAP::Lite -e 'print "PERL module SOAP::Lite is available\n"' >> $SETUP_LOG 2>&1
  848         if [ $? -ne 0 ]
  849             then
  850                 echo "*** ERROR: PERL module SOAP::Lite is not installed !"
  851                 REQUIRED_PERL_MODULE_MISSING=1
  852                 SOAP_LITE=1
  853             else
  854                 echo "Found that PERL module SOAP::Lite is available."
  855         fi
  856 
  857         # Check for Zip::Archive
  858         echo "Checking for Archive::Zip Perl module..."
  859         echo "Checking for Archive::Zip Perl module" >> $SETUP_LOG
  860         $PERL_BIN -mArchive::Zip -e 'print "PERL module Archive::Zip is available\n"' >> $SETUP_LOG 2>&1
  861         if [ $? -ne 0 ]
  862             then
  863                 echo "*** ERROR: PERL module Archive::Zip is not installed !"
  864                 REQUIRED_PERL_MODULE_MISSING=1
  865                 ARCHIVE_ZIP=1
  866             else
  867                 echo "Found that PERL module Archive::Zip is available."
  868         fi
  869 
  870         if [ $REQUIRED_PERL_MODULE_MISSING -ne 0 ]
  871             then
  872                 echo "*** ERROR: There is one or more required PERL modules missing on your computer !"
  873                 echo "Please, install missing PERL modules first."
  874                 echo " "
  875                 echo "OCS setup.sh can install perl module from packages for you"
  876                 echo "The script will use the native package from your operating system like apt or rpm"
  877                 echo -n "Do you wish to continue (y/[n])?"
  878                 read ligne
  879                 if [ "$ligne" = "y" ] || [ "$ligne" = "Y" ]
  880                     then
  881                         case $UNIX_DISTRIBUTION in
  882                             "redhat")
  883                                 echo "RedHat based automatic installation"
  884                                 if [ $DBI -eq 1 ]
  885                                     then
  886                                         PACKAGE="$PACKAGE perl-DBI"
  887                                 fi
  888                                 if [ $APACHE_DBI -eq 1 ]
  889                                     then
  890                                         PACKAGE="$PACKAGE perl-Apache-DBI"
  891                                 fi
  892                                 if [ $DBD_MYSQL -eq 1 ]
  893                                     then
  894                                         PACKAGE="$PACKAGE perl-DBD-MySQL"
  895                                 fi
  896                                 if [ $COMPRESS_ZLIB -eq 1 ]
  897                                     then
  898                                         PACKAGE="$PACKAGE perl-Compress-Zlib"
  899                                 fi
  900                                 if [ $XML_SIMPLE -eq 1 ]
  901                                     then
  902                                         PACKAGE="$PACKAGE perl-XML-Simple"
  903                                 fi
  904                                 if [ $NET_IP -eq 1 ]
  905                                     then
  906                                         PACKAGE="$PACKAGE perl-Net-IP"
  907                                 fi
  908                                 if [ $SOAP_LITE -eq 1 ]
  909                                     then
  910                                         PACKAGE="$PACKAGE perl-SOAP-Lite"
  911                                 fi
  912                                 if [ $ARCHIVE_ZIP -eq 1 ]
  913                                     then
  914                                         PACKAGE="$PACKAGE perl-Archive-Zip"
  915                                 fi
  916 
  917                                 yum install $PACKAGE
  918                                 if [ $? != 0 ]
  919                                     then
  920                                         echo "Installation aborted !"
  921                                         echo "Installation script encounter problems to install packages !"
  922                                         echo "One or more required PERL modules missing !" >> $SETUP_LOG
  923                                         echo "Installation aborted" >> $SETUP_LOG
  924                                         exit 1
  925                                 fi
  926                                 echo "All packages have been installed on this computer"
  927                             ;;
  928 
  929                             "debian")
  930                                 echo "Debian based automatic installation"
  931                                 if [ $DBI -eq 1 ]
  932                                     then
  933                                         PACKAGE="$PACKAGE libdbi-perl"
  934                                 fi
  935                                 if [ $APACHE_DBI -eq 1 ]
  936                                     then
  937                                         PACKAGE="$PACKAGE libapache-dbi-perl"
  938                                 fi
  939                                 if [ $DBD_MYSQL -eq 1 ]
  940                                     then
  941                                         PACKAGE="$PACKAGE libdbd-mysql-perl"
  942                                 fi
  943                                 if [ $COMPRESS_ZLIB -eq 1 ]
  944                                     then
  945                                         PACKAGE="$PACKAGE libcompress-zlib-perl"
  946                                 fi
  947                                 if [ $XML_SIMPLE -eq 1 ]
  948                                     then
  949                                         PACKAGE="$PACKAGE libxml-simple-perl"
  950                                 fi
  951                                 if [ $NET_IP -eq 1 ]
  952                                     then
  953                                         PACKAGE="$PACKAGE libnet-ip-perl"
  954                                 fi
  955                                 if [ $SOAP_LITE -eq 1 ]
  956                                     then
  957                                         PACKAGE="$PACKAGE libsoap-lite-perl"
  958                                 fi
  959                                 if [ $ARCHIVE_ZIP -eq 1 ]
  960                                     then
  961                                         PACKAGE="$PACKAGE libarchive-zip-perl"
  962                                 fi
  963 
  964                                 apt-get update
  965                                 apt-get install $PACKAGE
  966                                 if [ $? -ne 0 ]
  967                                     then
  968                                         echo "Installation aborted !"
  969                                         echo "Installation script encounter problems to install packages !"
  970                                         echo "One or more required PERL modules missing !" >> $SETUP_LOG
  971                                         echo "Installation aborted" >> $SETUP_LOG
  972                                         exit 1
  973                                 fi
  974                                 echo "All packages have been installed on this computer"
  975                             ;;
  976 
  977                             *)
  978                                 echo "Installation aborted !"
  979                                 echo "Installation script cannot find missing packages for your distribution"
  980                                 echo "One or more required PERL modules missing !" >> $SETUP_LOG
  981                                 echo "Installation aborted" >> $SETUP_LOG
  982                                 exit 1
  983                             ;;
  984                         esac
  985                     else
  986                         echo "Installation aborted !"
  987                         echo "Please, install missing PERL modules first."
  988                         echo "One or more required PERL modules missing !" >> $SETUP_LOG
  989                         echo "Installation aborted" >> $SETUP_LOG
  990                         exit 1
  991                 fi
  992         fi
  993 
  994         # Check for optional Perl Modules
  995         #   - Apache2::SOAP, not required, used only in web service
  996         #   - XML::Entities 0.02, not required, used only in web service
  997         #
  998         echo
  999         echo "+----------------------------------------------------------+"
 1000         echo "|         Checking for optional Perl Modules...            |"
 1001         echo "+----------------------------------------------------------+"
 1002         echo
 1003         echo "Checking for Apache2::SOAP PERL module..."
 1004         echo "Checking for Apache2::SOAP PERL module" >> $SETUP_LOG
 1005                 $PERL_BIN -mSOAP::Transport::HTTP2 -e 'print "PERL module Apache2::SOAP is available\n"' >> $SETUP_LOG 2>&1
 1006                 if [ $? -ne 0 ]
 1007                         then
 1008                                 echo "PERL module Apache2::SOAP is available\n" >> $SETUP_LOG
 1009                                 echo "*** Warning: PERL module Apache2::SOAP is not installed !"
 1010                                 echo "This module is only required by OCS Inventory NG SOAP Web Service."
 1011                                 echo -n "Do you wish to continue ([y]/n] ?"
 1012                                 read ligne
 1013                                 if [ -z "$ligne" ] || [ "$ligne" = "y" ]
 1014                                         then
 1015                                                 echo "User choose to continue setup without PERL module SOAP::Apache2" >> $SETUP_LOG
 1016                                         else
 1017                                                 echo
 1018                                                 echo "Installation aborted !"
 1019                                                 echo "User choose to abort installation !" >> $SETUP_LOG
 1020                                                 exit 1
 1021                                 fi
 1022                         else
 1023                                 echo "Found that PERL module SOAP::Apache2 is available."
 1024                 fi
 1025 
 1026         echo "Checking for XML::Entities PERL module..."
 1027         echo "Checking for XML::Entities PERL module" >> $SETUP_LOG
 1028         $PERL_BIN -mXML::Entities -e 'print "PERL module XML::Entities is available\n"' >> $SETUP_LOG 2>&1
 1029         if [ $? -ne 0 ]
 1030             then
 1031                 echo "*** Warning: PERL module XML::Entities is not installed !"
 1032                 echo "This module is only required by OCS Inventory NG SOAP Web Service."
 1033                 echo -n "Do you wish to continue ([y]/n] ?"
 1034                 read ligne
 1035                 if [ -z "$ligne" ] || [ "$ligne" = "y" ]
 1036                     then
 1037                         echo "User choose to continue setup without PERL module XML::Entities" >> $SETUP_LOG
 1038                     else
 1039                         echo
 1040                         echo "Installation aborted !"
 1041                         echo "User choose to abort installation !" >> $SETUP_LOG
 1042                         exit 1
 1043                 fi
 1044             else
 1045                 echo "Found that PERL module XML::Entities is available."
 1046         fi
 1047         echo
 1048 
 1049         echo
 1050         echo -n "Do you wish to setup Rest API server on this computer ([y]/n)?"
 1051         read ligne
 1052         if [ -z "$ligne" ] || [ "$ligne" = "y" ] || [ "$ligne" = "Y" ]
 1053             then
 1054                 echo
 1055                 echo "+----------------------------------------------------------+"
 1056                 echo "| Checking for REST API Dependencies ...                       |"
 1057                 echo "+----------------------------------------------------------+"
 1058                 echo
 1059 
 1060                 # Dependencies :
 1061                 # => Mojolicious::Lite
 1062                 # => Plack
 1063                 # => Switch
 1064 
 1065                 $PERL_BIN -mMojolicious::Lite -e 'print "PERL module Mojolicious::Lite is available\n"' >> $SETUP_LOG 2>&1
 1066                 if [ $? -ne 0 ]
 1067                     then
 1068                         echo "*** ERROR: PERL module Mojolicious::Lite is not installed !"
 1069                         echo -n "Do you wish to continue (y/[n])?"
 1070                         read ligne
 1071                         if [ "$ligne" = "y" ] || [ "$ligne" = "Y" ]
 1072                             then
 1073                                 echo "User choose to continue setup without PERL module Mojolicious::Lite" >> $SETUP_LOG
 1074                             else
 1075                                 echo
 1076                                 echo "Installation aborted !"
 1077                                 echo "User choose to abort installation !" >> $SETUP_LOG
 1078                                 exit 1
 1079                         fi
 1080                     else
 1081                         echo "Found that PERL module Mojolicious::Lite is available."
 1082                 fi
 1083 
 1084                 $PERL_BIN -mSwitch -e 'print "PERL module Switch is available\n"' >> $SETUP_LOG 2>&1
 1085                 if [ $? -ne 0 ]
 1086                     then
 1087                         echo "*** ERROR: PERL module Switch is not installed !"
 1088                         echo -n "Do you wish to continue (y/[n])?"
 1089                         read ligne
 1090                         if [ "$ligne" = "y" ] || [ "$ligne" = "Y" ]
 1091                             then
 1092                                 echo "User choose to continue setup without PERL module Switch" >> $SETUP_LOG
 1093                             else
 1094                                 echo
 1095                                 echo "Installation aborted !"
 1096                                 echo "User choose to abort installation !" >> $SETUP_LOG
 1097                                 exit 1
 1098                         fi
 1099                     else
 1100                         echo "Found that PERL module Switch is available."
 1101                 fi
 1102 
 1103                 $PERL_BIN -mPlack::Handler -e 'print "PERL module Plack::Handler is available\n"' >> $SETUP_LOG 2>&1
 1104                 if [ $? -ne 0 ]
 1105                     then
 1106                         echo "*** ERROR: PERL module Plack::Handler is not installed !"
 1107                         echo -n "Do you wish to continue (y/[n])?"
 1108                         read ligne
 1109                         if [ "$ligne" = "y" ] || [ "$ligne" = "Y" ]
 1110                             then
 1111                                 echo "User choose to continue setup without PERL module Plack::Handler" >> $SETUP_LOG
 1112                             else
 1113                                 echo
 1114                                 echo "Installation aborted !"
 1115                                 echo "User choose to abort installation !" >> $SETUP_LOG
 1116                                 exit 1
 1117                         fi
 1118                     else
 1119                         echo "Found that PERL module Plack::Handler is available."
 1120                 fi
 1121 
 1122                 echo
 1123                 echo "+----------------------------------------------------------+"
 1124                 echo "| Configuring REST API Server files ...                        |"
 1125                 echo "+----------------------------------------------------------+"
 1126                 echo
 1127 
 1128                 # Get first INC path to determine a valid path
 1129                 REST_API_DIRECTORY=$($PERL_BIN -e "print \"@INC[2]\"")
 1130 
 1131                 echo -n "Where do you want the API code to be store [$REST_API_DIRECTORY] ?"
 1132                 read ligne
 1133                 if [ -z "$ligne" ]
 1134                     then
 1135                         REST_API_DIRECTORY=$REST_API_DIRECTORY
 1136                     else
 1137                         REST_API_DIRECTORY="$ligne"
 1138                 fi
 1139 
 1140                 echo "Copying files to $REST_API_DIRECTORY"
 1141                 echo "Copying files to $REST_API_DIRECTORY" >> $SETUP_LOG
 1142 
 1143                 echo
 1144                 echo "+----------------------------------------------------------+"
 1145                 echo "| Configuring REST API Server configuration files ...          |"
 1146                 echo "+----------------------------------------------------------+"
 1147                 echo
 1148 
 1149                 echo "Configuring Rest API server (file $API_REST_APACHE_CONF_FILE)" >> $SETUP_LOG
 1150                 cp etc/ocsinventory/$API_REST_APACHE_CONF_FILE $API_REST_APACHE_CONF_FILE.local
 1151                 $PERL_BIN -pi -e "s#'REST_API_PATH'#'$REST_API_DIRECTORY'#g" $API_REST_APACHE_CONF_FILE.local
 1152                 $PERL_BIN -pi -e "s#'REST_API_LOADER_PATH'#'$REST_API_DIRECTORY/Api/Ocsinventory/Restapi/Loader.pm'#g" $API_REST_APACHE_CONF_FILE.local
 1153                 echo "Writing Rest API configuration to file $APACHE_CONFIG_DIRECTORY/$API_REST_APACHE_CONF_FILE" >> $SETUP_LOG
 1154                 cp -f $API_REST_APACHE_CONF_FILE.local $APACHE_CONFIG_DIRECTORY/zz-$API_REST_APACHE_CONF_FILE >> $SETUP_LOG 2>&1
 1155                 cp -r Api/ $REST_API_DIRECTORY
 1156 
 1157             fi
 1158         echo
 1159         echo "+----------------------------------------------------------+"
 1160         echo "|                 OK, looks good ;-)                       |"
 1161         echo "|                                                          |"
 1162         echo "|     Configuring Communication server Perl modules...     |"
 1163         echo "+----------------------------------------------------------+"
 1164         echo
 1165         echo "Configuring Communication server (perl Makefile.PL)" >> $SETUP_LOG
 1166         cd "Apache"
 1167         $PERL_BIN Makefile.PL
 1168         if [ $? -ne 0 ]
 1169             then
 1170                 echo -n "Warning: Prerequisites too old ! Do you wish to continue (y/[n])?"
 1171                 read ligne
 1172                 if [ "$ligne" = "y" ]
 1173                     then
 1174                         echo "Maybe Communication server will encounter problems. Continuing anyway."
 1175                         echo "Warning: Prerequisites too old ! Continuing anyway" >> $SETUP_LOG
 1176                     else
 1177                         echo "Installation aborted !"
 1178                         exit 1
 1179                 fi
 1180         fi
 1181 
 1182         echo
 1183         echo "+----------------------------------------------------------+"
 1184         echo "|                 OK, looks good ;-)                       |"
 1185         echo "|                                                          |"
 1186         echo "|      Preparing Communication server Perl modules...      |"
 1187         echo "+----------------------------------------------------------+"
 1188         echo
 1189         echo "Preparing Communication server Perl modules (make)" >> $SETUP_LOG
 1190         $MAKE >> $SETUP_LOG 2>&1
 1191         if [ $? -ne 0 ]
 1192             then
 1193                 echo "*** ERROR: Prepare failed, please look at error in $SETUP_LOG and fix !"
 1194                 echo
 1195                 echo "Installation aborted !"
 1196                 exit 1
 1197         fi
 1198 
 1199         echo
 1200         echo "+----------------------------------------------------------+"
 1201         echo "|                 OK, prepare finshed ;-)                  |"
 1202         echo "|                                                          |"
 1203         echo "|     Installing Communication server Perl modules...      |"
 1204         echo "+----------------------------------------------------------+"
 1205         echo
 1206         echo "Installing Communication server Perl modules (make install)" >> $SETUP_LOG
 1207         $MAKE install >> $SETUP_LOG 2>&1
 1208         if [ $? -ne 0 ]
 1209             then
 1210                 echo "*** ERROR: Install of Perl modules failed, please look at error in $SETUP_LOG and fix !"
 1211                 echo
 1212                 echo "Installation aborted !"
 1213                 exit 1
 1214         fi
 1215         cd ".."
 1216 
 1217         echo
 1218         echo "+----------------------------------------------------------+"
 1219         echo "| OK, Communication server Perl modules install finished;-)|"
 1220         echo "|                                                          |"
 1221         echo "|     Creating Communication server log directory...       |"
 1222         echo "+----------------------------------------------------------+"
 1223         echo
 1224         echo "Creating Communication server log directory $OCS_COM_SRV_LOG."
 1225         echo "Creating Communication server log directory $OCS_COM_SRV_LOG" >> $SETUP_LOG
 1226         mkdir -p $OCS_COM_SRV_LOG >> $SETUP_LOG 2>&1
 1227         if [ $? -ne 0 ]
 1228             then
 1229                 echo "*** ERROR: Unable to create log directory, please look at error in $SETUP_LOG and fix !"
 1230                 echo
 1231                 echo "Installation aborted !"
 1232                 exit 1
 1233         fi
 1234 
 1235         echo
 1236         echo "Fixing Communication server log directory files permissions."
 1237         echo "Fixing Communication server log directory permissions" >> $SETUP_LOG
 1238         chown -R $APACHE_USER:$APACHE_GROUP $OCS_COM_SRV_LOG >> $SETUP_LOG 2>&1
 1239         if [ $? -ne 0 ]
 1240             then
 1241                 echo "*** ERROR: Unable to set log directory permissions, please look at error in $SETUP_LOG and fix !"
 1242                 echo
 1243                 echo "Installation aborted !"
 1244                 exit 1
 1245         fi
 1246 
 1247         chmod -R gu+rwx $OCS_COM_SRV_LOG >> $SETUP_LOG 2>&1
 1248         if [ $? -ne 0 ]
 1249             then
 1250                 echo "*** ERROR: Unable to set log directory permissions, please look at error in $SETUP_LOG and fix !"
 1251                 echo
 1252                 echo "Installation aborted !"
 1253                 exit 1
 1254         fi
 1255 
 1256         chmod -R o-w $OCS_COM_SRV_LOG >> $SETUP_LOG 2>&1
 1257         if [ $? -ne 0 ]
 1258             then
 1259                 echo "*** ERROR: Unable to set log directory permissions, please look at error in $SETUP_LOG and fix !"
 1260                 echo
 1261                 echo "Installation aborted !"
 1262                 exit 1
 1263         fi
 1264 
 1265         # Log rotation, BSD style
 1266         if [ -f $NEWSYSLOG_CONF_FILE ]
 1267             then
 1268                 echo "*** WARNING Please configure log rotation for files in $OCS_COM_SRV_LOG"
 1269         fi
 1270 
 1271         # Log rotation, Linux flavor
 1272         if [ -d $LOGROTATE_CONF_DIR ]
 1273             then
 1274                 echo "Configuring logrotate for Communication server."
 1275                 echo "Configuring logrotate (ed logrotate.ocsinventory-NG)" >> $SETUP_LOG
 1276                 cp etc/logrotate.d/$COM_SERVER_LOGROTATE_CONF_FILE logrotate.$COM_SERVER_LOGROTATE_CONF_FILE.local
 1277                 $PERL_BIN -pi -e "s#PATH_TO_LOG_DIRECTORY#$OCS_COM_SRV_LOG#g" logrotate.$COM_SERVER_LOGROTATE_CONF_FILE.local
 1278                 echo "******** Begin updated logrotate.$COM_SERVER_LOGROTATE_CONF_FILE.local ***********" >> $SETUP_LOG
 1279                 cat logrotate.$COM_SERVER_LOGROTATE_CONF_FILE.local >> $SETUP_LOG
 1280                 echo "******** End updated logrotate.COM_SERVER_LOGROTATE_CONF_FILE.local ***********" >> $SETUP_LOG
 1281                 echo "Removing old communication server logrotate file $LOGROTATE_CONF_DIR/ocsinventory-NG"
 1282                 echo "Removing old communication server logrotate file $LOGROTATE_CONF_DIR/ocsinventory-NG" >> $SETUP_LOG
 1283                 rm -f "$LOGROTATE_CONF_DIR/ocsinventory-NG"
 1284                 echo "Writing communication server logrotate to file $LOGROTATE_CONF_DIR/$COM_SERVER_LOGROTATE_CONF_FILE"
 1285                 echo "Writing communication server logrotate to file $LOGROTATE_CONF_DIR/$COM_SERVER_LOGROTATE_CONF_FILE" >> $SETUP_LOG
 1286                 cp -f logrotate.$COM_SERVER_LOGROTATE_CONF_FILE.local $LOGROTATE_CONF_DIR/$COM_SERVER_LOGROTATE_CONF_FILE >> $SETUP_LOG 2>&1
 1287                 if [ $? -ne 0 ]
 1288                     then
 1289                         echo "*** ERROR: Unable to configure log rotation, please look at error in $SETUP_LOG and fix !"
 1290                         echo
 1291                         echo "Installation aborted !"
 1292                         exit 1
 1293                 fi
 1294         fi
 1295         echo
 1296 
 1297         echo
 1298         echo "+----------------------------------------------------------------------+"
 1299         echo "|        OK, Communication server log directory created ;-)            |"
 1300         echo "|                                                                      |"
 1301         echo "|   Creating Communication server plugins configuration directory...   |"
 1302         echo "+----------------------------------------------------------------------+"
 1303         echo
 1304         echo "Creating Communication server plugins configuration directory $OCS_COM_SRV_PLUGINS_CONFIG_DIR."
 1305         echo "Creating Communication server plugins configuration directory $OCS_COM_SRV_PLUGINS_CONFIG_DIR" >> $SETUP_LOG
 1306         mkdir -p $OCS_COM_SRV_PLUGINS_CONFIG_DIR >> $SETUP_LOG 2>&1
 1307         if [ $? -ne 0 ]
 1308             then
 1309                 echo "*** ERROR: Unable to create plugins confguration directory, please look at error in $SETUP_LOG and fix !"
 1310                 echo
 1311                 echo "Installation aborted !"
 1312                 exit 1
 1313         fi
 1314         echo
 1315 
 1316         echo
 1317         echo "+----------------------------------------------------------------------+"
 1318         echo "| OK, Communication server plugins configuration directory created ;-) |"
 1319         echo "|                                                                      |"
 1320         echo "|        Creating Communication server plugins Perl directory...       |"
 1321         echo "+----------------------------------------------------------------------+"
 1322         echo
 1323         echo "Creating Communication server plugins Perl directory $OCS_COM_SRV_PLUGINS_PERL_DIR."
 1324         echo "Creating Communication server plugins Perl directory $OCS_COM_SRV_PLUGINS_PERL_DIR" >> $SETUP_LOG
 1325         mkdir -p "$OCS_COM_SRV_PLUGINS_PERL_DIR/Apache/Ocsinventory/Plugins" >> $SETUP_LOG 2>&1
 1326         if [ $? -ne 0 ]
 1327             then
 1328                 echo "*** ERROR: Unable to create plugins Perl directory, please look at error in $SETUP_LOG and fix !"
 1329                 echo
 1330                 echo "Installation aborted !"
 1331                 exit 1
 1332         fi
 1333         echo
 1334 
 1335         echo
 1336         echo "+----------------------------------------------------------------------+"
 1337         echo "|     OK, Communication server plugins Perl directory created ;-)      |"
 1338         echo "|                                                                      |"
 1339         echo "|               Now configuring Apache web server...                   |"
 1340         echo "+----------------------------------------------------------------------+"
 1341         echo
 1342         echo "To ensure Apache loads mod_perl before OCS Inventory NG Communication Server,"
 1343         echo "Setup can name Communication Server Apache configuration file"
 1344         echo "'z-$COM_SERVER_APACHE_CONF_FILE' instead of '$COM_SERVER_APACHE_CONF_FILE'."
 1345         echo "Do you allow Setup renaming Communication Server Apache configuration file"
 1346         echo -n "to 'z-$COM_SERVER_APACHE_CONF_FILE' ([y]/n) ?"
 1347         read ligne
 1348         if [ -z $ligne ] || [ "$ligne" = "y" ] || [ "$ligne" = "Y" ]
 1349             then
 1350                 echo "OK, using 'z-$COM_SERVER_APACHE_CONF_FILE' as Communication Server Apache configuration file"
 1351                 echo "OK, using 'z-$COM_SERVER_APACHE_CONF_FILE' as Communication Server Apache configuration file" >> $SETUP_LOG
 1352                 FORCE_LOAD_AFTER_PERL_CONF=1
 1353             else
 1354                 echo "OK, using '$COM_SERVER_APACHE_CONF_FILE' as Communication Server Apache configuration file"
 1355                 echo "OK, using '$COM_SERVER_APACHE_CONF_FILE' as Communication Server Apache configuration file" >> $SETUP_LOG
 1356                 FORCE_LOAD_AFTER_PERL_CONF=0
 1357         fi
 1358 
 1359         echo "Configuring Apache web server (file $COM_SERVER_APACHE_CONF_FILE)" >> $SETUP_LOG
 1360         cp etc/ocsinventory/$COM_SERVER_APACHE_CONF_FILE $COM_SERVER_APACHE_CONF_FILE.local
 1361         $PERL_BIN -pi -e "s#DATABASE_SERVER#$DB_SERVER_HOST#g" $COM_SERVER_APACHE_CONF_FILE.local
 1362         $PERL_BIN -pi -e "s#DATABASE_PORT#$DB_SERVER_PORT#g" $COM_SERVER_APACHE_CONF_FILE.local
 1363         $PERL_BIN -pi -e "s#VERSION_MP#$APACHE_MOD_PERL_VERSION#g" $COM_SERVER_APACHE_CONF_FILE.local
 1364         $PERL_BIN -pi -e "s#PATH_TO_LOG_DIRECTORY#$OCS_COM_SRV_LOG#g" $COM_SERVER_APACHE_CONF_FILE.local
 1365         $PERL_BIN -pi -e "s#PATH_TO_PLUGINS_CONFIG_DIRECTORY#$OCS_COM_SRV_PLUGINS_CONFIG_DIR#g" $COM_SERVER_APACHE_CONF_FILE.local
 1366         $PERL_BIN -pi -e "s#PATH_TO_PLUGINS_PERL_DIRECTORY#$OCS_COM_SRV_PLUGINS_PERL_DIR#g" $COM_SERVER_APACHE_CONF_FILE.local
 1367         echo "******** Begin updated $COM_SERVER_APACHE_CONF_FILE.local ***********" >> $SETUP_LOG
 1368         cat $COM_SERVER_APACHE_CONF_FILE.local >> $SETUP_LOG
 1369         echo "******** End updated $COM_SERVER_APACHE_CONF_FILE.local ***********" >> $SETUP_LOG
 1370         echo "Removing old communication server configuration to file $APACHE_CONFIG_DIRECTORY/ocsinventory.conf"
 1371         echo "Removing old communication server configuration to file $APACHE_CONFIG_DIRECTORY/ocsinventory.conf" >> $SETUP_LOG
 1372         rm -f "$APACHE_CONFIG_DIRECTORY/ocsinventory.conf"
 1373         if [ $FORCE_LOAD_AFTER_PERL_CONF -eq 1 ]
 1374             then
 1375                 rm -f "$APACHE_CONFIG_DIRECTORY/$COM_SERVER_APACHE_CONF_FILE"
 1376                 echo "Writing communication server configuration to file $APACHE_CONFIG_DIRECTORY/z-$COM_SERVER_APACHE_CONF_FILE"
 1377                 echo "Writing communication server configuration to file $APACHE_CONFIG_DIRECTORY/z-$COM_SERVER_APACHE_CONF_FILE" >> $SETUP_LOG
 1378                 cp -f $COM_SERVER_APACHE_CONF_FILE.local $APACHE_CONFIG_DIRECTORY/z-$COM_SERVER_APACHE_CONF_FILE >> $SETUP_LOG 2>&1
 1379                 res=$?
 1380                 COM_SERVER_APACHE_CONF_FILE="z-$COM_SERVER_APACHE_CONF_FILE"
 1381             else
 1382                 echo "Writing communication server configuration to file $APACHE_CONFIG_DIRECTORY/$COM_SERVER_APACHE_CONF_FILE"
 1383                 echo "Writing communication server configuration to file $APACHE_CONFIG_DIRECTORY/$COM_SERVER_APACHE_CONF_FILE" >> $SETUP_LOG
 1384                 cp -f $COM_SERVER_APACHE_CONF_FILE.local $APACHE_CONFIG_DIRECTORY/$COM_SERVER_APACHE_CONF_FILE >> $SETUP_LOG 2>&1
 1385                 res=$?
 1386         fi
 1387         if [ $res -ne 0 ]
 1388             then
 1389                 echo "*** ERROR: Unable to write $APACHE_CONFIG_DIRECTORY/$COM_SERVER_APACHE_CONF_FILE, please look at error in $SETUP_LOG and fix !"
 1390                 echo
 1391                 echo "Installation aborted !"
 1392                 exit 1
 1393         fi
 1394         echo
 1395 
 1396         echo "+----------------------------------------------------------------------+"
 1397         echo "|       OK, Communication server setup successfully finished ;-)       |"
 1398         echo "|                                                                      |"
 1399         echo "| Please, review $APACHE_CONFIG_DIRECTORY/$COM_SERVER_APACHE_CONF_FILE |"
 1400         echo "|         to ensure all is good. Then restart Apache daemon.           |"
 1401         echo "+----------------------------------------------------------------------+"
 1402         echo
 1403         echo "Leaving Apache directory" >> $SETUP_LOG
 1404         echo "Communication server installation successful" >> $SETUP_LOG
 1405 fi
 1406 
 1407 echo
 1408 echo "Do you wish to setup Administration Server (Web Administration Console)"
 1409 echo -n "on this computer ([y]/n)?"
 1410 read ligne
 1411 if [ -z "$ligne" ] || [ "$ligne" = "y" ] || [ "$ligne" = "Y" ]
 1412     then
 1413         # Install Administration server
 1414         echo >> $SETUP_LOG
 1415         echo "============================================================" >> $SETUP_LOG
 1416         echo "Installing Administration server" >> $SETUP_LOG
 1417         echo "============================================================" >> $SETUP_LOG
 1418 
 1419         echo
 1420         echo "+----------------------------------------------------------+"
 1421         echo "|    Checking for Administration Server directories...     |"
 1422         echo "+----------------------------------------------------------+"
 1423         echo
 1424         echo "CAUTION: Setup now install files in accordance with Filesystem Hierarchy"
 1425         echo "Standard. So, no file is installed under Apache root document directory"
 1426         echo "(Refer to Apache configuration files to locate it)."
 1427         echo "If you're upgrading from OCS Inventory NG Server 1.01 and previous, YOU"
 1428         echo "MUST REMOVE (or move) directories 'ocsreports' and 'download' from Apache"
 1429         echo "root document directory."
 1430         echo "If you choose to move directory, YOU MUST MOVE 'download' directory to"
 1431         echo "Administration Server writable/cache directory (by default"
 1432         echo "$ADM_SERVER_VAR_DIR), especially if you use deployment feature."
 1433         echo
 1434         echo -n "Do you wish to continue ([y]/n)?"
 1435         read ligne
 1436         if [ -z "$ligne" ] || [ "$ligne" = "y" ] || [ "$ligne" = "Y" ]
 1437             then
 1438                 echo "Assuming directories 'ocsreports' and 'download' removed from"
 1439                 echo "Apache root document directory."
 1440                 echo
 1441             else
 1442                 echo "Installation aborted !"
 1443                 echo
 1444                 exit 1
 1445         fi
 1446 
 1447         echo "Checking for Administration Server directories..." >> $SETUP_LOG
 1448         echo "Where to copy Administration Server static files for PHP Web Console"
 1449         echo -n "[$ADM_SERVER_STATIC_DIR] ?"
 1450         read ligne
 1451         if test -z $ligne
 1452             then
 1453                 ADM_SERVER_STATIC_DIR=$ADM_SERVER_STATIC_DIR
 1454             else
 1455                 ADM_SERVER_STATIC_DIR="$ligne"
 1456         fi
 1457 
 1458         echo "OK, using directory $ADM_SERVER_STATIC_DIR to install static files ;-)"
 1459         echo "Using directory $ADM_SERVER_STATIC_DIR for static files" >> $SETUP_LOG
 1460         echo
 1461         echo "Where to create writable/cache directories for deployment packages,"
 1462         echo -n "administration console logs, IPDiscover and SNMP [$ADM_SERVER_VAR_DIR] ?"
 1463         read ligne
 1464         if test -z $ligne
 1465             then
 1466                 ADM_SERVER_VAR_DIR=$ADM_SERVER_VAR_DIR
 1467             else
 1468                 ADM_SERVER_VAR_DIR="$ligne"
 1469         fi
 1470 
 1471         echo "OK, writable/cache directory is $ADM_SERVER_VAR_DIR ;-)"
 1472         echo "Using $ADM_SERVER_VAR_DIR as writable/cache directory" >> $SETUP_LOG
 1473         echo
 1474 
 1475         # Check for required Perl Modules (if missing, please install before)
 1476         #   - DBI 1.40 or higher
 1477         #   - DBD::mysql 2.9004 or higher
 1478         #   - XML::Simple 2.12 or higher
 1479         #   - Net::IP 1.21 or higher
 1480         #
 1481         echo
 1482         echo "+----------------------------------------------------------+"
 1483         echo "|         Checking for required Perl Modules...            |"
 1484         echo "+----------------------------------------------------------+"
 1485         echo
 1486         REQUIRED_PERL_MODULE_MISSING=0
 1487         echo "Checking for DBI PERL module..."
 1488         echo "Checking for DBI PERL module" >> $SETUP_LOG
 1489         $PERL_BIN -mDBI -e 'print "PERL module DBI is available\n"' >> $SETUP_LOG 2>&1
 1490         if [ $? -ne 0 ]
 1491             then
 1492                 echo "*** ERROR: PERL module DBI is not installed !"
 1493                 REQUIRED_PERL_MODULE_MISSING=1
 1494             else
 1495                 echo "Found that PERL module DBI is available."
 1496         fi
 1497 
 1498         echo "Checking for DBD::mysql PERL module..."
 1499         echo "Checking for DBD::mysql PERL module" >> $SETUP_LOG
 1500         $PERL_BIN -mDBD::mysql -e 'print "PERL module DBD::mysql is available\n"' >> $SETUP_LOG 2>&1
 1501         if [ $? -ne 0 ]
 1502             then
 1503                 echo "*** ERROR: PERL module DBD::mysql is not installed !"
 1504                 REQUIRED_PERL_MODULE_MISSING=1
 1505             else
 1506                 echo "Found that PERL module DBD::mysql is available."
 1507         fi
 1508 
 1509         echo "Checking for XML::Simple PERL module..."
 1510         echo "Checking for XML::Simple PERL module" >> $SETUP_LOG
 1511         $PERL_BIN -mXML::Simple -e 'print "PERL module XML::Simple is available\n"' >> $SETUP_LOG 2>&1
 1512         if [ $? -ne 0 ]
 1513             then
 1514                 echo "*** ERROR: PERL module XML::Simple is not installed !"
 1515                 REQUIRED_PERL_MODULE_MISSING=1
 1516             else
 1517                 echo "Found that PERL module XML::Simple is available."
 1518         fi
 1519 
 1520         echo "Checking for Net::IP PERL module..."
 1521         echo "Checking for Net::IP PERL module" >> $SETUP_LOG
 1522         $PERL_BIN -mNet::IP -e 'print "PERL module Net::IP is available\n"' >> $SETUP_LOG 2>&1
 1523         if [ $? -ne 0 ]
 1524             then
 1525                 echo "*** ERROR: PERL module Net::IP is not installed !"
 1526                 REQUIRED_PERL_MODULE_MISSING=1
 1527             else
 1528                 echo "Found that PERL module Net::IP is available."
 1529         fi
 1530 
 1531         if [ $REQUIRED_PERL_MODULE_MISSING -ne 0 ]
 1532             then
 1533                 echo "*** ERROR: There is one or more required PERL modules missing on your computer !"
 1534                 echo "Please, install missing PERL modules first."
 1535                 echo "Installation aborted !"
 1536                 echo "One or more required PERL modules missing !" >> $SETUP_LOG
 1537                 echo "Installation aborted" >> $SETUP_LOG
 1538                 exit 1
 1539         fi
 1540 
 1541         echo
 1542         echo "+----------------------------------------------------------+"
 1543         echo "|      Installing files for Administration server...       |"
 1544         echo "+----------------------------------------------------------+"
 1545         echo
 1546         echo "Creating PHP directory $ADM_SERVER_STATIC_DIR/$ADM_SERVER_STATIC_REPORTS_DIR."
 1547         echo "Creating PHP directory $ADM_SERVER_STATIC_DIR/$ADM_SERVER_STATIC_REPORTS_DIR" >> $SETUP_LOG
 1548         mkdir -p $ADM_SERVER_STATIC_DIR/$ADM_SERVER_STATIC_REPORTS_DIR >> $SETUP_LOG 2>&1
 1549         if [ $? != 0 ]
 1550             then
 1551                 echo "*** ERROR: Unable to create $ADM_SERVER_STATIC_DIR/$ADM_SERVER_STATIC_REPORTS_DIR, please look at error in $SETUP_LOG and fix !"
 1552                 echo
 1553                 echo "Installation aborted !"
 1554                 exit 1
 1555         fi
 1556 
 1557         echo "Copying PHP files to $ADM_SERVER_STATIC_DIR/$ADM_SERVER_STATIC_REPORTS_DIR."
 1558         echo "Copying PHP files to $ADM_SERVER_STATIC_DIR/$ADM_SERVER_STATIC_REPORTS_DIR" >> $SETUP_LOG
 1559         cp -Rf ocsreports/* $ADM_SERVER_STATIC_DIR/$ADM_SERVER_STATIC_REPORTS_DIR/ >> $SETUP_LOG 2>&1
 1560         if [ $? -ne 0 ]
 1561             then
 1562                 echo "*** ERROR: Unable to copy files in $ADM_SERVER_STATIC_DIR/$ADM_SERVER_STATIC_REPORTS_DIR, please look at error in $SETUP_LOG and fix !"
 1563                 echo
 1564                 echo "Installation aborted !"
 1565                 exit 1
 1566         fi
 1567 
 1568         echo "Fixing permissions on directory $ADM_SERVER_STATIC_DIR/$ADM_SERVER_STATIC_REPORTS_DIR."
 1569         echo "Fixing permissions on directory $ADM_SERVER_STATIC_DIR/$ADM_SERVER_STATIC_REPORTS_DIR" >> $SETUP_LOG
 1570         # Set PHP pages directory owned by root, group Apache
 1571         chown -R root:$APACHE_GROUP $ADM_SERVER_STATIC_DIR/$ADM_SERVER_STATIC_REPORTS_DIR >> $SETUP_LOG 2>&1
 1572         # Set "download/" "upload/" "plugins/main_section" "plugins/computer_detail" "plugins/language" "config/" own to apache
 1573         chown -R $APACHE_USER:$APACHE_GROUPE $ADM_SERVER_STATIC_DIR/$ADM_SERVER_STATIC_REPORTS_DIR/config >> $SETUP_LOG 2>&1
 1574         chown -R $APACHE_USER:$APACHE_GROUPE $ADM_SERVER_STATIC_DIR/$ADM_SERVER_STATIC_REPORTS_DIR/plugins/computer_detail >> $SETUP_LOG 2>&1
 1575         chown -R $APACHE_USER:$APACHE_GROUPE $ADM_SERVER_STATIC_DIR/$ADM_SERVER_STATIC_REPORTS_DIR/plugins/main_sections >> $SETUP_LOG 2>&1
 1576         chown -R $APACHE_USER:$APACHE_GROUPE $ADM_SERVER_STATIC_DIR/$ADM_SERVER_STATIC_REPORTS_DIR/plugins/language >> $SETUP_LOG 2>&1
 1577         chown -R $APACHE_USER:$APACHE_GROUPE $ADM_SERVER_STATIC_DIR/$ADM_SERVER_STATIC_REPORTS_DIR/download >> $SETUP_LOG 2>&1
 1578         chown -R $APACHE_USER:$APACHE_GROUPE $ADM_SERVER_STATIC_DIR/$ADM_SERVER_STATIC_REPORTS_DIR/upload >> $SETUP_LOG 2>&1
 1579         chown $APACHE_USER:$APACHE_GROUPE $ADM_SERVER_STATIC_DIR/$ADM_SERVER_STATIC_REPORTS_DIR >> $SETUP_LOG 2>&1
 1580 
 1581         if [ $? -ne 0 ]
 1582             then
 1583                 echo "*** ERROR: Unable to set permissions on $ADM_SERVER_STATIC_DIR/$ADM_SERVER_STATIC_REPORTS_DIR, please look at error in $SETUP_LOG and fix !"
 1584                 echo
 1585                 echo "Installation aborted !"
 1586                 exit 1
 1587         fi
 1588 
 1589         # Set PHP pages writable by root only
 1590         chmod -R go-w $ADM_SERVER_STATIC_DIR/$ADM_SERVER_STATIC_REPORTS_DIR >> $SETUP_LOG 2>&1
 1591         if [ $? -ne 0 ]
 1592             then
 1593                 echo "*** ERROR: Unable to set permissions on $ADM_SERVER_STATIC_DIR/$ADM_SERVER_STATIC_REPORTS_DIR, please look at error in $SETUP_LOG and fix !"
 1594                 echo
 1595                 echo "Installation aborted !"
 1596                 exit 1
 1597         fi
 1598 
 1599         # Set database configuration file dbconfig.inc.php writable by Apache
 1600         echo "Creating database configuration file $ADM_SERVER_STATIC_DIR/$ADM_SERVER_STATIC_REPORTS_DIR/dbconfig.inc.php."
 1601         echo "Creating database configuration file $ADM_SERVER_STATIC_DIR/$ADM_SERVER_STATIC_REPORTS_DIR/dbconfig.inc.php" >> $SETUP_LOG
 1602         rm -f $ADM_SERVER_STATIC_DIR/$ADM_SERVER_STATIC_REPORTS_DIR/dbconfig.inc.php
 1603         echo "<?php" >> $ADM_SERVER_STATIC_DIR/$ADM_SERVER_STATIC_REPORTS_DIR/dbconfig.inc.php
 1604         echo -n '$_SESSION["SERVEUR_SQL"]="' >> $ADM_SERVER_STATIC_DIR/$ADM_SERVER_STATIC_REPORTS_DIR/dbconfig.inc.php
 1605         echo -n "$DB_SERVER_HOST" >> $ADM_SERVER_STATIC_DIR/$ADM_SERVER_STATIC_REPORTS_DIR/dbconfig.inc.php
 1606         echo '";' >> $ADM_SERVER_STATIC_DIR/$ADM_SERVER_STATIC_REPORTS_DIR/dbconfig.inc.php
 1607         echo -n '$_SESSION["COMPTE_BASE"]="' >> $ADM_SERVER_STATIC_DIR/$ADM_SERVER_STATIC_REPORTS_DIR/dbconfig.inc.php
 1608         echo -n "$DB_SERVER_USER" >> $ADM_SERVER_STATIC_DIR/$ADM_SERVER_STATIC_REPORTS_DIR/dbconfig.inc.php
 1609         echo '";' >> $ADM_SERVER_STATIC_DIR/$ADM_SERVER_STATIC_REPORTS_DIR/dbconfig.inc.php
 1610         echo -n '$_SESSION["PSWD_BASE"]="' >> $ADM_SERVER_STATIC_DIR/$ADM_SERVER_STATIC_REPORTS_DIR/dbconfig.inc.php
 1611         echo -n "$DB_SERVER_PWD" >> $ADM_SERVER_STATIC_DIR/$ADM_SERVER_STATIC_REPORTS_DIR/dbconfig.inc.php
 1612         echo '";' >> $ADM_SERVER_STATIC_DIR/$ADM_SERVER_STATIC_REPORTS_DIR/dbconfig.inc.php
 1613         echo "?>" >> $ADM_SERVER_STATIC_DIR/$ADM_SERVER_STATIC_REPORTS_DIR/dbconfig.inc.php
 1614         chown root:$APACHE_GROUP $ADM_SERVER_STATIC_DIR/$ADM_SERVER_STATIC_REPORTS_DIR/dbconfig.inc.php
 1615         chmod g+w $ADM_SERVER_STATIC_DIR/$ADM_SERVER_STATIC_REPORTS_DIR/dbconfig.inc.php >> $SETUP_LOG 2>&1
 1616         if [ $? -ne 0 ]
 1617             then
 1618                 echo "*** ERROR: Unable to set permissions on $ADM_SERVER_STATIC_DIR/$ADM_SERVER_STATIC_REPORTS_DIR/dbconfig.inc.php, please look at error in $SETUP_LOG and fix !"
 1619                 echo
 1620                 echo "Installation aborted !"
 1621                 exit 1
 1622         fi
 1623 
 1624         echo "Creating IPDiscover directory $ADM_SERVER_VAR_DIR/$ADM_SERVER_VAR_IPD_DIR."
 1625         echo "Creating IPDiscover directory $ADM_SERVER_VAR_DIR/$ADM_SERVER_VAR_IPD_DIR" >> $SETUP_LOG
 1626         mkdir -p $ADM_SERVER_VAR_DIR/$ADM_SERVER_VAR_IPD_DIR >> $SETUP_LOG 2>&1
 1627         if [ $? != 0 ]
 1628             then
 1629                 echo "*** ERROR: Unable to create $ADM_SERVER_VAR_DIR/$ADM_SERVER_VAR_IPD_DIR, please look at error in $SETUP_LOG and fix !"
 1630                 echo
 1631                 echo "Installation aborted !"
 1632                 exit 1
 1633         fi
 1634 
 1635         echo "Fixing permissions on directory $ADM_SERVER_VAR_DIR/$ADM_SERVER_VAR_IPD_DIR."
 1636         echo "Fixing permissions on directory $ADM_SERVER_VAR_DIR/$ADM_SERVER_VAR_IPD_DIR" >> $SETUP_LOG
 1637         # Set IPD area owned by root, group Apache
 1638         chown -R root:$APACHE_GROUP $ADM_SERVER_VAR_DIR/$ADM_SERVER_VAR_IPD_DIR >> $SETUP_LOG 2>&1
 1639         if [ $? -ne 0 ]
 1640             then
 1641                 echo "*** ERROR: Unable to set permissions on $ADM_SERVER_VAR_DIR/$ADM_SERVER_VAR_IPD_DIR, please look at error in $SETUP_LOG and fix !"
 1642                 echo
 1643                 echo "Installation aborted !"
 1644                 exit 1
 1645         fi
 1646 
 1647         # Set IPD area writable by root only
 1648         chmod -R go-w $ADM_SERVER_VAR_DIR/$ADM_SERVER_VAR_IPD_DIR >> $SETUP_LOG 2>&1
 1649         if [ $? -ne 0 ]
 1650             then
 1651                 echo "*** ERROR: Unable to set permissions on $ADM_SERVER_VAR_DIR/$ADM_SERVER_VAR_IPD_DIR, please look at error in $SETUP_LOG and fix !"
 1652                 echo
 1653                 echo "Installation aborted !"
 1654                 exit 1
 1655         fi
 1656 
 1657         # Set IPD area writable by Apache group
 1658         chmod g+w $ADM_SERVER_VAR_DIR/$ADM_SERVER_VAR_IPD_DIR >> $SETUP_LOG 2>&1
 1659         if [ $? -ne 0 ]
 1660             then
 1661                 echo "*** ERROR: Unable to set permissions on $ADM_SERVER_VAR_DIR/$ADM_SERVER_VAR_IPD_DIR, please look at error in $SETUP_LOG and fix !"
 1662                 echo
 1663                 echo "Installation aborted !"
 1664                 exit 1
 1665         fi
 1666 
 1667         #Create packages directory
 1668         echo "Creating packages directory $ADM_SERVER_VAR_DIR/$ADM_SERVER_VAR_PACKAGES_DIR."
 1669         echo "Creating packages directory $ADM_SERVER_VAR_DIR/$ADM_SERVER_VAR_PACKAGES_DIR" >> $SETUP_LOG
 1670         mkdir -p $ADM_SERVER_VAR_DIR/$ADM_SERVER_VAR_PACKAGES_DIR >> $SETUP_LOG 2>&1
 1671         if [ $? != 0 ]
 1672             then
 1673                 echo "*** ERROR: Unable to create $ADM_SERVER_VAR_DIR/$ADM_SERVER_VAR_PACKAGES_DIR, please look at error in $SETUP_LOG and fix !"
 1674                 echo
 1675                 echo "Installation aborted !"
 1676                 exit 1
 1677         fi
 1678 
 1679         echo "Fixing permissions on directory $ADM_SERVER_VAR_DIR/$ADM_SERVER_VAR_PACKAGES_DIR."
 1680         echo "Fixing permissions on directory $ADM_SERVER_VAR_DIR/$ADM_SERVER_VAR_PACKAGES_DIR" >> $SETUP_LOG
 1681         # Set package area owned by root, group Apache
 1682         chown -R root:$APACHE_GROUP $ADM_SERVER_VAR_DIR/$ADM_SERVER_VAR_PACKAGES_DIR >> $SETUP_LOG 2>&1
 1683         if [ $? -ne 0 ]
 1684             then
 1685                 echo "*** ERROR: Unable to set permissions on $ADM_SERVER_VAR_DIR/$ADM_SERVER_VAR_PACKAGES_DIR, please look at error in $SETUP_LOG and fix !"
 1686                 echo
 1687                 echo "Installation aborted !"
 1688                 exit 1
 1689         fi
 1690 
 1691         # Set package area writable by root and Apache group only
 1692         chmod -R g+w,o-w $ADM_SERVER_VAR_DIR/$ADM_SERVER_VAR_PACKAGES_DIR >> $SETUP_LOG 2>&1
 1693         if [ $? -ne 0 ]
 1694             then
 1695                 echo "*** ERROR: Unable to set permissions on $ADM_SERVER_VAR_DIR/$ADM_SERVER_VAR_PACKAGES_DIR, please look at error in $SETUP_LOG and fix !"
 1696                 echo
 1697                 echo "Installation aborted !"
 1698                 exit 1
 1699         fi
 1700 
 1701         # Create snmp custom mibs directory
 1702         echo "Creating snmp mibs directory $ADM_SERVER_VAR_DIR/$ADM_SERVER_VAR_SNMP_DIR."
 1703         echo "Creating snmp mibs directory $ADM_SERVER_VAR_DIR/$ADM_SERVER_VAR_SNMP_DIR" >> $SETUP_LOG
 1704         mkdir -p $ADM_SERVER_VAR_DIR/$ADM_SERVER_VAR_SNMP_DIR >> $SETUP_LOG 2>&1
 1705         if [ $? != 0 ]
 1706             then
 1707                 echo "*** ERROR: Unable to create $ADM_SERVER_VAR_DIR/$ADM_SERVER_VAR_SNMP_DIR, please look at error in $SETUP_LOG and fix !"
 1708                 echo
 1709                 echo "Installation aborted !"
 1710                 exit 1
 1711         fi
 1712 
 1713         echo "Fixing permissions on directory $ADM_SERVER_VAR_DIR/$ADM_SERVER_VAR_SNMP_DIR."
 1714         echo "Fixing permissions on directory $ADM_SERVER_VAR_DIR/$ADM_SERVER_VAR_SNMP_DIR" >> $SETUP_LOG
 1715         # Set snmp area owned by root, group Apache
 1716         chown -R root:$APACHE_GROUP $ADM_SERVER_VAR_DIR/$ADM_SERVER_VAR_SNMP_DIR >> $SETUP_LOG 2>&1
 1717         if [ $? -ne 0 ]
 1718             then
 1719                 echo "*** ERROR: Unable to set permissions on $ADM_SERVER_VAR_DIR/$ADM_SERVER_VAR_SNMP_DIR, please look at error in $SETUP_LOG and fix !"
 1720                 echo
 1721                 echo "Installation aborted !"
 1722                 exit 1
 1723         fi
 1724 
 1725         # Set snmp area writable by root and Apache group only
 1726         chmod -R g+w,o-w $ADM_SERVER_VAR_DIR/$ADM_SERVER_VAR_SNMP_DIR >> $SETUP_LOG 2>&1
 1727         if [ $? -ne 0 ]
 1728             then
 1729                 echo "*** ERROR: Unable to set permissions on $ADM_SERVER_VAR_DIR/$ADM_SERVER_VAR_SNMP_DIR, please look at error in $SETUP_LOG and fix !"
 1730                 echo
 1731                 echo "Installation aborted !"
 1732                 exit 1
 1733         fi
 1734 
 1735         # Create logs directory
 1736         echo "Creating Administration server log files directory $ADM_SERVER_VAR_DIR/$ADM_SERVER_VAR_LOGS_DIR."
 1737         echo "Creating Administration server log files directory $ADM_SERVER_VAR_DIR/$ADM_SERVER_VAR_LOGS_DIR" >> $SETUP_LOG
 1738         mkdir -p $ADM_SERVER_VAR_DIR/$ADM_SERVER_VAR_LOGS_DIR >> $SETUP_LOG 2>&1
 1739         if [ $? != 0 ]
 1740             then
 1741                 echo "*** ERROR: Unable to create $ADM_SERVER_VAR_DIR/$ADM_SERVER_VAR_LOGS_DIR, please look at error in $SETUP_LOG and fix !"
 1742                 echo
 1743                 echo "Installation aborted !"
 1744                 exit 1
 1745         fi
 1746 
 1747         echo "Fixing permissions on directory $ADM_SERVER_VAR_DIR/$ADM_SERVER_VAR_LOGS_DIR."
 1748         echo "Fixing permissions on directory $ADM_SERVER_VAR_DIR/$ADM_SERVER_VAR_LOGS_DIR" >> $SETUP_LOG
 1749         # Set log files area owned by root, group Apache
 1750         chown -R root:$APACHE_GROUP $ADM_SERVER_VAR_DIR/$ADM_SERVER_VAR_LOGS_DIR >> $SETUP_LOG 2>&1
 1751         if [ $? -ne 0 ]
 1752             then
 1753                 echo "*** ERROR: Unable to set permissions on $ADM_SERVER_VAR_DIR/$ADM_SERVER_VAR_LOGS_DIR, please look at error in $SETUP_LOG and fix !"
 1754                 echo
 1755                 echo "Installation aborted !"
 1756                 exit 1
 1757         fi
 1758 
 1759         # Set log files area writable by root and Apache group only
 1760         chmod -R g+w,o-w $ADM_SERVER_VAR_DIR/$ADM_SERVER_VAR_LOGS_DIR >> $SETUP_LOG 2>&1
 1761         if [ $? -ne 0 ]
 1762             then
 1763                 echo "*** ERROR: Unable to set permissions on $ADM_SERVER_VAR_DIR/$ADM_SERVER_VAR_LOGS_DIR, please look at error in $SETUP_LOG and fix !"
 1764                 echo
 1765                 echo "Installation aborted !"
 1766                 exit 1
 1767         fi
 1768 
 1769         echo "Creating Administration server scripts log files directory $ADM_SERVER_VAR_DIR/$ADM_SERVER_VAR_SCRIPTS_LOGS_DIR."
 1770         echo "Creating Administration server scripts log files directory $ADM_SERVER_VAR_DIR/$ADM_SERVER_VAR_SCRIPTS_LOGS_DIR" >> $SETUP_LOG
 1771         mkdir -p $ADM_SERVER_VAR_DIR/$ADM_SERVER_VAR_SCRIPTS_LOGS_DIR >> $SETUP_LOG 2>&1
 1772         if [ $? != 0 ]
 1773             then
 1774                 echo "*** ERROR: Unable to create $ADM_SERVER_VAR_DIR/$ADM_SERVER_VAR_SCRIPTS_LOGS_DIR, please look at error in $SETUP_LOG and fix !"
 1775                 echo
 1776                 echo "Installation aborted !"
 1777                 exit 1
 1778         fi
 1779 
 1780         echo "Fixing permissions on directory $ADM_SERVER_VAR_DIR/$ADM_SERVER_VAR_SCRIPTS_LOGS_DIR."
 1781         echo "Fixing permissions on directory $ADM_SERVER_VAR_DIR/$ADM_SERVER_VAR_SCRIPTS_LOGS_DIR" >> $SETUP_LOG
 1782         # Set scripts log files area owned by root, group Apache
 1783         chown -R root:$APACHE_GROUP $ADM_SERVER_VAR_DIR/$ADM_SERVER_VAR_SCRIPTS_LOGS_DIR >> $SETUP_LOG 2>&1
 1784         if [ $? -ne 0 ]
 1785             then
 1786                 echo "*** ERROR: Unable to set permissions on $ADM_SERVER_VAR_DIR/$ADM_SERVER_VAR_SCRIPTS_LOGS_DIR, please look at error in $SETUP_LOG and fix !"
 1787                 echo
 1788                 echo "Installation aborted !"
 1789                 exit 1
 1790         fi
 1791 
 1792         # Set scripts log files area writable by root and Apache group only
 1793         chmod -R g+w,o-w $ADM_SERVER_VAR_DIR/$ADM_SERVER_VAR_SCRIPTS_LOGS_DIR >> $SETUP_LOG 2>&1
 1794         if [ $? -ne 0 ]
 1795             then
 1796                 echo "*** ERROR: Unable to set permissions on $ADM_SERVER_VAR_DIR/$ADM_SERVER_VAR_SCRIPTS_LOGS_DIR, please look at error in $SETUP_LOG and fix !"
 1797                 echo
 1798                 echo "Installation aborted !"
 1799                 exit 1
 1800         fi
 1801 
 1802         echo "Configuring IPDISCOVER-UTIL Perl script."
 1803         echo "Configuring IPDISCOVER-UTIL Perl script (ed ipdiscover-util.pl)" >> $SETUP_LOG
 1804         cp binutils/ipdiscover-util.pl ipdiscover-util.pl.local >> $SETUP_LOG 2>&1
 1805         $PERL_BIN -pi -e "s#localhost#$DB_SERVER_HOST#g" ipdiscover-util.pl.local
 1806         $PERL_BIN -pi -e "s#3306#$DB_SERVER_PORT#g" ipdiscover-util.pl.local
 1807         # echo "******** Begin updated ipdiscover-util.pl.local script ***********" >> $SETUP_LOG
 1808         # cat ipdiscover-util.pl.local >> $SETUP_LOG
 1809         # echo "******** End updated ipdiscover-util.pl.local script ***********" >> $SETUP_LOG
 1810         echo "Installing IPDISCOVER-UTIL Perl script."
 1811         echo "Installing IPDISCOVER-UTIL Perl script" >> $SETUP_LOG
 1812         cp ipdiscover-util.pl.local $ADM_SERVER_STATIC_DIR/$ADM_SERVER_STATIC_REPORTS_DIR/ipdiscover-util.pl >> $SETUP_LOG 2>&1
 1813         if [ $? -ne 0 ]
 1814             then
 1815                 echo "*** ERROR: Unable to copy files in $ADM_SERVER_STATIC_DIR/$ADM_SERVER_STATIC_REPORTS_DIR, please look at error in $SETUP_LOG and fix !"
 1816                 echo
 1817                 echo "Installation aborted !"
 1818                 exit 1
 1819         fi
 1820 
 1821         echo "Fixing permissions on IPDISCOVER-UTIL Perl script."
 1822         echo "Fixing permissions on IPDISCOVER-UTIL Perl script" >> $SETUP_LOG
 1823         chown root:$APACHE_GROUP $ADM_SERVER_STATIC_DIR/$ADM_SERVER_STATIC_REPORTS_DIR/ipdiscover-util.pl >> $SETUP_LOG 2>&1
 1824         if [ $? -ne 0 ]
 1825             then
 1826                 echo "*** ERROR: Unable to set permissions on $ADM_SERVER_STATIC_DIR/$ADM_SERVER_STATIC_REPORTS_DIR, please look at error in $SETUP_LOG and fix !"
 1827                 echo
 1828                 echo "Installation aborted !"
 1829                 exit 1
 1830         fi
 1831         chmod gou+x $ADM_SERVER_STATIC_DIR/$ADM_SERVER_STATIC_REPORTS_DIR/ipdiscover-util.pl >> $SETUP_LOG 2>&1
 1832         if [ $? -ne 0 ]
 1833             then
 1834                 echo "*** ERROR: Unable to set permissions on $ADM_SERVER_STATIC_DIR/$ADM_SERVER_STATIC_REPORTS_DIR, please look at error in $SETUP_LOG and fix !"
 1835                 echo
 1836                 echo "Installation aborted !"
 1837                 exit 1
 1838         fi
 1839 
 1840         echo "Configuring Apache web server (file $ADM_SERVER_APACHE_CONF_FILE)" >> $SETUP_LOG
 1841         cp etc/ocsinventory/$ADM_SERVER_APACHE_CONF_FILE $ADM_SERVER_APACHE_CONF_FILE.local
 1842         $PERL_BIN -pi -e "s#OCSREPORTS_ALIAS#$ADM_SERVER_REPORTS_ALIAS#g" $ADM_SERVER_APACHE_CONF_FILE.local
 1843         $PERL_BIN -pi -e "s#PATH_TO_OCSREPORTS_DIR#$ADM_SERVER_STATIC_DIR/$ADM_SERVER_STATIC_REPORTS_DIR#g" $ADM_SERVER_APACHE_CONF_FILE.local
 1844         $PERL_BIN -pi -e "s#IPD_ALIAS#$ADM_SERVER_IPD_ALIAS#g" $ADM_SERVER_APACHE_CONF_FILE.local
 1845         $PERL_BIN -pi -e "s#PATH_TO_IPD_DIR#$ADM_SERVER_VAR_DIR/$ADM_SERVER_VAR_IPD_DIR#g" $ADM_SERVER_APACHE_CONF_FILE.local
 1846         $PERL_BIN -pi -e "s#PACKAGES_ALIAS#$ADM_SERVER_PACKAGES_ALIAS#g" $ADM_SERVER_APACHE_CONF_FILE.local
 1847         $PERL_BIN -pi -e "s#PATH_TO_PACKAGES_DIR#$ADM_SERVER_VAR_DIR/$ADM_SERVER_VAR_PACKAGES_DIR#g" $ADM_SERVER_APACHE_CONF_FILE.local
 1848         $PERL_BIN -pi -e "s#SNMP_ALIAS#$ADM_SERVER_SNMP_ALIAS#g" $ADM_SERVER_APACHE_CONF_FILE.local
 1849         $PERL_BIN -pi -e "s#PATH_TO_SNMP_DIR#$ADM_SERVER_VAR_DIR/$ADM_SERVER_VAR_SNMP_DIR#g" $ADM_SERVER_APACHE_CONF_FILE.local
 1850         echo "******** Begin updated $ADM_SERVER_APACHE_CONF_FILE.local ***********" >> $SETUP_LOG
 1851         cat $ADM_SERVER_APACHE_CONF_FILE.local >> $SETUP_LOG
 1852         echo "******** End updated $ADM_SERVER_APACHE_CONF_FILE.local ***********" >> $SETUP_LOG
 1853         echo "Writing Administration server configuration to file $APACHE_CONFIG_DIRECTORY/$ADM_SERVER_APACHE_CONF_FILE"
 1854         echo "Writing communication server configuration to file $APACHE_CONFIG_DIRECTORY/$ADM_SERVER_APACHE_CONF_FILE" >> $SETUP_LOG
 1855         cp -f $ADM_SERVER_APACHE_CONF_FILE.local $APACHE_CONFIG_DIRECTORY/$ADM_SERVER_APACHE_CONF_FILE >> $SETUP_LOG 2>&1
 1856 
 1857         #Fix permissions on server side for plugin engine (perl / plugins) dir usually in etc/ocsinventory-server..
 1858         # Where are located OCS Communication server plugins configuration files
 1859         chown -R $APACHE_USER:$APACHE_GROUPE $OCS_COM_SRV_PLUGINS_CONFIG_DIR
 1860         # Where are located OCS Communication server plugins perl files
 1861         chown -R $APACHE_USER:$APACHE_GROUPE $OCS_COM_SRV_PLUGINS_PERL_DIR
 1862         if [ $? -ne 0 ]
 1863             then
 1864                 echo "*** ERROR: Unable to write $APACHE_CONFIG_DIRECTORY/$ADM_SERVER_APACHE_CONF_FILE, please look at error in $SETUP_LOG and fix !"
 1865                 echo
 1866                 echo "Installation aborted !"
 1867                 exit 1
 1868         fi
 1869         echo
 1870 
 1871         echo "+----------------------------------------------------------------------+"
 1872         echo "|        OK, Administration server installation finished ;-)           |"
 1873         echo "|                                                                      |"
 1874         echo "| Please, review $APACHE_CONFIG_DIRECTORY/$ADM_SERVER_APACHE_CONF_FILE"
 1875         echo "|          to ensure all is good and restart Apache daemon.            |"
 1876         echo "|                                                                      |"
 1877         echo "| Then, point your browser to http://server/$ADM_SERVER_REPORTS_ALIAS"
 1878         echo "|        to configure database server and create/update schema.        |"
 1879         echo "+----------------------------------------------------------------------+"
 1880         echo
 1881         echo "Administration server installation successful" >> $SETUP_LOG
 1882 fi
 1883 
 1884 echo
 1885 echo "Setup has created a log file $SETUP_LOG. Please, save this file."
 1886 echo "If you encounter error while running OCS Inventory NG Management server,"
 1887 echo "we can ask you to show us its content !"
 1888 echo
 1889 echo "DON'T FORGET TO RESTART APACHE DAEMON !"
 1890 echo
 1891 echo "Enjoy OCS Inventory NG ;-)"
 1892 echo
 1893 exit 0