From 70a5b8115a76d9a405d11221d16850a48d130692 Mon Sep 17 00:00:00 2001 From: "Luiz G. Costa" Date: Fri, 31 May 2019 10:05:40 +0100 Subject: [PATCH 1/4] remove white space from the end of line --- install.sh | 58 +++++++++---------- libinstall/functions.sh | 46 +++++++-------- .../centreon-awie/class/ClapiObject.class.php | 2 +- .../centreon-awie/class/Export.class.php | 6 +- 4 files changed, 56 insertions(+), 56 deletions(-) diff --git a/install.sh b/install.sh index a45f33b..400fe9f 100644 --- a/install.sh +++ b/install.sh @@ -3,34 +3,34 @@ # Copyright 2005-2018 CENTREON # Centreon is developped by : Julien Mathis and Romain Le Merlus under # GPL Licence 2.0. -# -# This program is free software; you can redistribute it and/or modify it under -# the terms of the GNU General Public License as published by the Free Software +# +# This program is free software; you can redistribute it and/or modify it under +# the terms of the GNU General Public License as published by the Free Software # Foundation ; either version 2 of the License. -# +# # This program is distributed in the hope that it will be useful, but WITHOUT ANY -# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. See the GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along with +# +# You should have received a copy of the GNU General Public License along with # this program; if not, see . -# -# 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/class/ClapiObject.class.php b/www/modules/centreon-awie/class/ClapiObject.class.php index 87a4284..5dc00ff 100644 --- a/www/modules/centreon-awie/class/ClapiObject.class.php +++ b/www/modules/centreon-awie/class/ClapiObject.class.php @@ -63,7 +63,7 @@ private function connectToClapi() /** * Export - * + * * @param $withoutClose disable using of PHP exit function (default: false) * @return mixed */ diff --git a/www/modules/centreon-awie/class/Export.class.php b/www/modules/centreon-awie/class/Export.class.php index cbdc39d..5b3cf7a 100644 --- a/www/modules/centreon-awie/class/Export.class.php +++ b/www/modules/centreon-awie/class/Export.class.php @@ -39,7 +39,7 @@ public function __construct($clapiConnector, $dependencyInjector) $this->tmpName = 'centreon-clapi-export-' . time(); $this->tmpFile = '/tmp/' . $this->tmpName . '.txt'; } - + /** * @param $type * @return array @@ -109,7 +109,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 +175,7 @@ public function generateGroup($object, $value) } } } - + /** * @param $object * @param string $filter From 4c56bab458627c941416faadfcfe9e37c082158b Mon Sep 17 00:00:00 2001 From: "Luiz G. Costa" Date: Fri, 31 May 2019 10:07:01 +0100 Subject: [PATCH 2/4] fix copyright year --- features/bootstrap/CentreonAwieContext.php | 2 +- www/modules/centreon-awie/centreon-awie.conf.php | 2 +- www/modules/centreon-awie/class/ClapiObject.class.php | 2 +- www/modules/centreon-awie/class/Export.class.php | 2 +- www/modules/centreon-awie/class/ZipAndDownload.class.php | 2 +- www/modules/centreon-awie/core/formExporter.php | 2 +- www/modules/centreon-awie/core/formImporter.php | 2 +- www/modules/centreon-awie/core/generateExport.php | 2 +- www/modules/centreon-awie/core/js/Export.js | 2 +- www/modules/centreon-awie/core/js/Import.js | 2 +- www/modules/centreon-awie/core/launchImport.php | 2 +- www/modules/centreon-awie/core/submitExport.php | 2 +- 12 files changed, 12 insertions(+), 12 deletions(-) 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 @@ Date: Fri, 31 May 2019 10:07:27 +0100 Subject: [PATCH 3/4] fix typo --- install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install.sh b/install.sh index 400fe9f..6675fba 100644 --- a/install.sh +++ b/install.sh @@ -1,7 +1,7 @@ #!/bin/bash # # Copyright 2005-2018 CENTREON -# Centreon is developped by : Julien Mathis and Romain Le Merlus under +# Centreon is developed by : Julien Mathis and Romain Le Merlus under # GPL Licence 2.0. # # This program is free software; you can redistribute it and/or modify it under From eb7a28e770a886d44f95ff668ba3ebedb48e41c8 Mon Sep 17 00:00:00 2001 From: "Luiz G. Costa" Date: Fri, 31 May 2019 10:14:02 +0100 Subject: [PATCH 4/4] some fixes PSR-2 --- www/modules/centreon-awie/class/ClapiObject.class.php | 2 -- www/modules/centreon-awie/class/Export.class.php | 3 --- 2 files changed, 5 deletions(-) diff --git a/www/modules/centreon-awie/class/ClapiObject.class.php b/www/modules/centreon-awie/class/ClapiObject.class.php index ff69b93..ae4e6ea 100644 --- a/www/modules/centreon-awie/class/ClapiObject.class.php +++ b/www/modules/centreon-awie/class/ClapiObject.class.php @@ -83,6 +83,4 @@ public function import($fileName) $import = $this->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 7dfe0d1..2460b00 100644 --- a/www/modules/centreon-awie/class/Export.class.php +++ b/www/modules/centreon-awie/class/Export.class.php @@ -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;