From b4255318e6ef96e8f44ed0cf5a31c7c3d43bb9d0 Mon Sep 17 00:00:00 2001 From: deajan Date: Wed, 28 Dec 2016 23:25:11 +0100 Subject: [PATCH] Simplified CreateDirectoryRemote --- dev/n_obackup.sh | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/dev/n_obackup.sh b/dev/n_obackup.sh index 954424d..a5b692f 100755 --- a/dev/n_obackup.sh +++ b/dev/n_obackup.sh @@ -10,7 +10,7 @@ PROGRAM="obackup" AUTHOR="(C) 2013-2016 by Orsiris de Jong" CONTACT="http://www.netpower.fr/obackup - ozy@netpower.fr" PROGRAM_VERSION=2.1-dev -PROGRAM_BUILD=2016122801 +PROGRAM_BUILD=2016122802 IS_STABLE=no include #### OFUNCTIONS FULL SUBSET #### @@ -622,19 +622,16 @@ function _CreateDirectoryRemote { $SSH_CMD env _DEBUG="'$_DEBUG'" env _PARANOIA_DEBUG="'$_PARANOIA_DEBUG'" env _LOGGER_SILENT="'$_LOGGER_SILENT'" env _LOGGER_VERBOSE="'$_LOGGER_VERBOSE'" env _LOGGER_PREFIX="'$_LOGGER_PREFIX'" env _LOGGER_ERR_ONLY="'$_LOGGER_ERR_ONLY'" \ env PROGRAM="'$PROGRAM'" env SCRIPT_PID="'$SCRIPT_PID'" TSTAMP="'$TSTAMP'" \ -env dirToCreate="'$dirToCreate'" $COMMAND_SUDO' bash -s' << 'ENDSSH' > "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP" 2> "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.error.$SCRIPT_PID.$TSTAMP" & +env dirToCreate="'$dirToCreate'" $COMMAND_SUDO' bash -s' << 'ENDSSH' > "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP" 2&1 & include #### DEBUG SUBSET #### include #### TrapError SUBSET #### include #### RemoteLogger SUBSET #### if [ ! -d "$dirToCreate" ]; then # No sudo, you should have all necessary rights - mkdir -p "$dirToCreate" > $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP 2>&1 & + mkdir -p "$dirToCreate" if [ $? != 0 ]; then RemoteLogger "Cannot create directory [$dirToCreate]" "CRITICAL" - if [ -f $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP ]; then - RemoteLogger "Command output: $(cat $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP)" "ERROR" - fi return 1 fi fi @@ -642,7 +639,7 @@ ENDSSH WaitForTaskCompletion $! 720 1800 $SLEEP_TIME $KEEP_LOGGING true true false if [ $? != 0 ]; then Logger "Cannot create remote directory [$dirToCreate]." "CRITICAL" - Logger "Command output:\n$(cat $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.error.$SCRIPT_PID.$TSTAMP)" "ERROR" + Logger "Command output:\n$(cat $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP)" "ERROR" return 1 fi }