diff --git a/features/bootstrap/CentreonAwieContext.php b/features/bootstrap/CentreonAwieContext.php index 11a0361..ca985a8 100644 --- a/features/bootstrap/CentreonAwieContext.php +++ b/features/bootstrap/CentreonAwieContext.php @@ -1,6 +1,6 @@ . -# -# Linking this program statically or dynamically with other modules is making a -# combined work based on this program. Thus, the terms and conditions of the GNU +# +# Linking this program statically or dynamically with other modules is making a +# combined work based on this program. Thus, the terms and conditions of the GNU # General Public License cover the whole combination. -# -# As a special exception, the copyright holders of this program give CENTREON -# permission to link this program with independent modules to produce an executable, -# regardless of the license terms of these independent modules, and to copy and -# distribute the resulting executable under terms of CENTREON choice, provided that -# CENTREON also meet, for each linked independent module, the terms and conditions -# of the license of that module. An independent module is a module which is not -# derived from this program. If you modify this program, you may extend this +# +# As a special exception, the copyright holders of this program give CENTREON +# permission to link this program with independent modules to produce an executable, +# regardless of the license terms of these independent modules, and to copy and +# distribute the resulting executable under terms of CENTREON choice, provided that +# CENTREON also meet, for each linked independent module, the terms and conditions +# of the license of that module. An independent module is a module which is not +# derived from this program. If you modify this program, you may extend this # exception to your version of the program, but you are not obliged to do so. If you # do not wish to do so, delete this exception statement from your version. -# +# # For more information : contact@centreon.com -# +# # Define module information RNAME="Centreon Web Import/Export" @@ -79,7 +79,7 @@ function usage() { ### Main -# define where is a centreon source +# define where is a centreon source BASE_DIR=$(dirname $0) ## set directory BASE_DIR=$( cd $BASE_DIR; pwd ) @@ -103,7 +103,7 @@ export line LOG_DIR="$BASE_DIR/log" LOG_FILE="$PWD/install.log" -## Valid if you are root +## Valid if you are root USERID=`id -u` if [ "$USERID" != "0" ]; then echo -e "You must exec with root user" @@ -121,11 +121,11 @@ do silent_install="1" user_conf="${OPTARG%/}" ;; - \?|h) usage ; - exit 0 + \?|h) usage ; + exit 0 ;; - * ) usage ; - exit 1 + * ) usage ; + exit 1 ;; esac done @@ -136,7 +136,7 @@ if [ "$_tmp_install_opts" -eq 0 ] ; then fi #Export variable for all programs -export silent_install CENTREON_CONF +export silent_install CENTREON_CONF ## init LOG_FILE # backup old log file... @@ -163,11 +163,11 @@ binary_fail="0" # For the moment, I check if all binary exists in path. # After, I must look a solution to use complet path by binary for binary in $BINARIES; do - if [ ! -e ${binary} ] ; then + if [ ! -e ${binary} ] ; then pathfind "$binary" if [ "$?" -eq 0 ] ; then echo_success "${binary}" "$ok" - else + else echo_failure "${binary}" "$fail" log "ERR" "\$binary not found in \$PATH" binary_fail=1 diff --git a/libinstall/functions.sh b/libinstall/functions.sh index 6642be9..beaeded 100644 --- a/libinstall/functions.sh +++ b/libinstall/functions.sh @@ -33,7 +33,7 @@ SETCOLOR_NORMAL="\\033[0;39m" ## @Globals LOG_FILE #---- function echo_info() { - echo -e "${1}${MOVE_TO_COL}${SETCOLOR_INFO}${2}${SETCOLOR_NORMAL}" + echo -e "${1}${MOVE_TO_COL}${SETCOLOR_INFO}${2}${SETCOLOR_NORMAL}" echo -e "$1 : $2" >> $LOG_FILE } @@ -46,7 +46,7 @@ function echo_info() { ## @Globals LOG_FILE #---- function echo_success() { - echo -e "${1}${MOVE_TO_COL}${SETCOLOR_SUCCESS}${2}${SETCOLOR_NORMAL}" + echo -e "${1}${MOVE_TO_COL}${SETCOLOR_SUCCESS}${2}${SETCOLOR_NORMAL}" echo -e "$1 : $2" >> $LOG_FILE } @@ -113,7 +113,7 @@ function log() { function define_specific_binary_vars() { local vars_bin="GREP CAT SED CHMOD CHOWN RM MKDIR CP MV" local var_bin_tolower="" - for var_bin in $vars_bin ; + for var_bin in $vars_bin ; do if [ -z $(eval echo \$$var_bin) ] ; then var_bin_tolower="$(echo $var_bin | tr [:upper:] [:lower:])" @@ -192,9 +192,9 @@ function yes_no_default() { read res [ -z "$res" ] && res="$default" done - if [ "$res" = "$yes" ] ; then + if [ "$res" = "$yes" ] ; then return 0 - else + else return 1 fi } @@ -285,7 +285,7 @@ function get_spaces_modulo_forge_url() { function print_footer() { forge_url_spaces=`get_spaces_modulo_forge_url;` spaces_x=`echo $forge_url_spaces | cut -d":" -f1` - + echo -e "################################################################################" echo -e "# #" echo -e "# Go to the URL : http://your-server/centreon/ to finish the setup #" @@ -307,14 +307,14 @@ function get_centreon_parameters() { WEB_USER=`${CAT} $CENTREON_CONF/$FILE_CONF | ${GREP} "WEB_USER" | cut -d '=' -f2`; WEB_GROUP=`${CAT} $CENTREON_CONF/$FILE_CONF | ${GREP} "WEB_GROUP" | cut -d '=' -f2`; - + MONITORINGENGINE_BINARY=`${CAT} $CENTREON_CONF/$FILE_CONF | ${GREP} "MONITORINGENGINE_BINARY" | cut -d '=' -f2`; PLUGIN_DIR=`${CAT} $CENTREON_CONF/$FILE_CONF | ${GREP} "PLUGIN_DIR" | cut -d '=' -f2`; MONITORINGENGINE_USER=`${CAT} $CENTREON_CONF/$FILE_CONF | ${GREP} "MONITORINGENGINE_USER" | cut -d '=' -f2`; CENTREON_GROUP=`${CAT} $CENTREON_CONF/$FILE_CONF | ${GREP} "CENTREON_GROUP" | cut -d '=' -f2`; PLUGIN_DIR=`${CAT} $CENTREON_CONF/$CENTPLUGINS_FILE_CONF | ${GREP} "PLUGIN_DIR" | cut -d '=' -f2` - + RESULT=0 # check centreon parameters if [ "$CENTREON_DIR" != "" ] ; then @@ -355,8 +355,8 @@ function get_centreon_parameters() { fi - #if [ "$RESULT" -eq 10 ]; then - if [ "$RESULT" -eq 9 ]; then + #if [ "$RESULT" -eq 10 ]; then + if [ "$RESULT" -eq 9 ]; then return 1; else return 0; @@ -423,24 +423,24 @@ function install_module_web() { ${CHMOD} -R 755 $TEMP_D/* >> $LOG_FILE 2>> $LOG_FILE if [ "$?" -eq 0 ] ; then echo_success "Setting right" "$ok" - else + else echo_failure "Setting right" "$fail" exit 1 fi - + RESULT=0 ${CHOWN} -R $WEB_USER.$WEB_GROUP $TEMP_D/* >> $LOG_FILE 2>> $LOG_FILE if [ "$?" -eq 0 ] ; then RESULT=`expr $RESULT + 1` fi - + if [ "$RESULT" -eq 1 ] ; then echo_success "Setting owner/group" "$ok" - else + else echo_failure "Setting owner/group" "$fail" exit 1 fi - + RESULT=0 find $TEMP_D -type f -exec ${SED} -i -e 's|@CENTREON_ETC@|'$CENTREON_CONF'|g' \{\} \; 2>> $LOG_FILE if [ "$?" -eq 0 ] ; then @@ -449,11 +449,11 @@ function install_module_web() { if [ "$RESULT" -eq 1 ] ; then echo_success "Changing macro" "$ok" - else + else echo_failure "Changing macro" "$fail" exit 1 fi - + if [ ! -d $INSTALL_DIR_MODULE ] ; then RESULT=0 ${MKDIR} $INSTALL_DIR_MODULE >> $LOG_FILE 2>> $LOG_FILE @@ -468,19 +468,19 @@ function install_module_web() { if [ "$?" -eq 0 ] ; then RESULT=`expr $RESULT + 1` fi - + if [ "$RESULT" -eq 3 ] ; then echo_success "Create module directory" "$ok" - else + else echo_failure "Create module directory" "$fail" exit 1 fi fi - + ${CP} -Rf --preserve $TEMP_D/* $INSTALL_DIR_MODULE >> $LOG_FILE 2>> $LOG_FILE if [ "$?" -eq 0 ] ; then echo_success "Copying module" "$ok" - else + else echo_failure "Copying module" "$fail" exit 1 fi @@ -494,11 +494,11 @@ function install_module_end() { ${RM} -Rf $TEMP_D $TEMP >> $LOG_FILE 2>> $LOG_FILE if [ "$?" -eq 0 ] ; then echo_success "Delete temp install directory" "$ok" - else + else echo_failure "Delete temp install directory" "$fail" exit 1 fi - + echo "" echo "$line" echo -e "\tEnd of $RNAME installation" diff --git a/www/modules/centreon-awie/centreon-awie.conf.php b/www/modules/centreon-awie/centreon-awie.conf.php index bba10e4..3f9aaba 100644 --- a/www/modules/centreon-awie/centreon-awie.conf.php +++ b/www/modules/centreon-awie/centreon-awie.conf.php @@ -1,6 +1,6 @@ clapiConnector->import($fileName); return $import; } - - } diff --git a/www/modules/centreon-awie/class/Export.class.php b/www/modules/centreon-awie/class/Export.class.php index cbdc39d..2460b00 100644 --- a/www/modules/centreon-awie/class/Export.class.php +++ b/www/modules/centreon-awie/class/Export.class.php @@ -1,6 +1,6 @@ tmpName = 'centreon-clapi-export-' . time(); $this->tmpFile = '/tmp/' . $this->tmpName . '.txt'; } - + /** * @param $type * @return array @@ -93,10 +93,7 @@ private function generateInstance($value) $result = $this->generateObject('ENGINECFG'); $cmdScript['result'] .= $result['result']; $cmdScript['error'] .= $result['error']; - - } elseif (!empty($value['INSTANCE_filter'])) { - $query = 'SELECT `id` FROM `nagios_server` WHERE `name` = "' . $value['INSTANCE_filter'] . '"'; $res = $this->db->query($query); $pollerId = null; @@ -109,7 +106,7 @@ private function generateInstance($value) $result = $this->generateObject('INSTANCE', $filter); $cmdScript['result'] = $result['result']; $cmdScript['error'] = $result['error']; - + // check is missed pollerId if ($pollerId === null) { return $cmdScript; @@ -175,7 +172,7 @@ public function generateGroup($object, $value) } } } - + /** * @param $object * @param string $filter diff --git a/www/modules/centreon-awie/class/ZipAndDownload.class.php b/www/modules/centreon-awie/class/ZipAndDownload.class.php index d910cf4..9e0cbe6 100644 --- a/www/modules/centreon-awie/class/ZipAndDownload.class.php +++ b/www/modules/centreon-awie/class/ZipAndDownload.class.php @@ -1,6 +1,6 @@