From 60266c40a61d2bb5bcf8096c570d851d3e1012dd Mon Sep 17 00:00:00 2001 From: deajan Date: Thu, 31 Mar 2016 10:02:42 +0200 Subject: [PATCH] Fixed bogus SSH_OPTS variable --- dev/debug_obackup.sh | 22 +++++++++++++--------- dev/n_obackup.sh | 2 +- dev/ofunctions.sh | 20 ++++++++++++-------- obackup.sh | 22 +++++++++++++--------- 4 files changed, 39 insertions(+), 27 deletions(-) diff --git a/dev/debug_obackup.sh b/dev/debug_obackup.sh index d37de97..7d146b9 100755 --- a/dev/debug_obackup.sh +++ b/dev/debug_obackup.sh @@ -2,13 +2,13 @@ ###### Remote push/pull (or local) backup script for files & databases PROGRAM="obackup" -AUTHOR="(L) 2013-2016 by Orsiris de Jong" +AUTHOR="(C) 2013-2016 by Orsiris de Jong" CONTACT="http://www.netpower.fr/obackup - ozy@netpower.fr" PROGRAM_VERSION=2.0-pre PROGRAM_BUILD=2016031801 IS_STABLE=no -## FUNC_BUILD=2016032501 +## FUNC_BUILD=2016033101 ## BEGIN Generic functions for osync & obackup written in 2013-2016 by Orsiris de Jong - http://www.netpower.fr - ozy@netpower.fr ## type -p does not work on platforms other than linux (bash). If if does not work, always assume output is not a zero exitcode @@ -92,11 +92,15 @@ function Dummy { } function _Logger { - local svalue="${1}" # What to log to screen + local svalue="${1}" # What to log to stdout local lvalue="${2:-$svalue}" # What to log to logfile, defaults to screen value + local evalue="${3}" # What to log to stderr echo -e "$lvalue" >> "$LOG_FILE" - if [ $_SILENT -eq 0 ]; then + # Special case in daemon mode where systemctl doesn't need double timestamps + if [ "$sync_on_changes" == "1" ]; then + cat <<< "$evalue" 1>&2 # Log to stderr in daemon mode + elif [ $_SILENT -eq 0 ]; then echo -e "$svalue" fi } @@ -114,15 +118,15 @@ function Logger { # if [ "$level" == "CRITICAL" ]; then - _Logger "$prefix\e[41m$value\e[0m" "$prefix$level:$value" + _Logger "$prefix\e[41m$value\e[0m" "$prefix$level:$value" "$level:$value" ERROR_ALERT=1 return elif [ "$level" == "ERROR" ]; then - _Logger "$prefix\e[91m$value\e[0m" "$prefix$level:$value" + _Logger "$prefix\e[91m$value\e[0m" "$prefix$level:$value" "$level:$value" ERROR_ALERT=1 return elif [ "$level" == "WARN" ]; then - _Logger "$prefix\e[93m$value\e[0m" "$prefix$level:$value" + _Logger "$prefix\e[93m$value\e[0m" "$prefix$level:$value" "$level:$value" WARN_ALERT=1 return elif [ "$level" == "NOTICE" ]; then @@ -495,7 +499,7 @@ function GetRemoteOS { exit 1 ;; *) - if [ "$IGNORE_OS_VER" == "yes" ]; then #DOC: Undocumented option + if [ "$IGNORE_OS_TYPE" == "yes" ]; then #DOC: Undocumented option Logger "Running on unknown remote OS [$remote_os_var]." "WARN" return fi @@ -978,7 +982,7 @@ function PostInit { __CheckArguments 0 $# ${FUNCNAME[0]} "$@" #__WITH_PARANOIA_DEBUG # Define remote commands - SSH_CMD="$(type -p ssh) $SSH_COMP -i $SSH_RSA_PRIVATE_KEY $SSH_IGNORE_KNOWN_HOSTS $REMOTE_USER@$REMOTE_HOST -p $REMOTE_PORT" + SSH_CMD="$(type -p ssh) $SSH_COMP -i $SSH_RSA_PRIVATE_KEY $SSH_OPTS $REMOTE_USER@$REMOTE_HOST -p $REMOTE_PORT" SCP_CMD="$(type -p scp) $SSH_COMP -i $SSH_RSA_PRIVATE_KEY -P $REMOTE_PORT" RSYNC_SSH_CMD="$(type -p ssh) $SSH_COMP -i $SSH_RSA_PRIVATE_KEY -p $REMOTE_PORT" } diff --git a/dev/n_obackup.sh b/dev/n_obackup.sh index 619f7db..3b4018c 100755 --- a/dev/n_obackup.sh +++ b/dev/n_obackup.sh @@ -2,7 +2,7 @@ ###### Remote push/pull (or local) backup script for files & databases PROGRAM="obackup" -AUTHOR="(L) 2013-2016 by Orsiris de Jong" +AUTHOR="(C) 2013-2016 by Orsiris de Jong" CONTACT="http://www.netpower.fr/obackup - ozy@netpower.fr" PROGRAM_VERSION=2.0-pre PROGRAM_BUILD=2016031801 diff --git a/dev/ofunctions.sh b/dev/ofunctions.sh index 7fa8fc0..c9f3f43 100644 --- a/dev/ofunctions.sh +++ b/dev/ofunctions.sh @@ -1,4 +1,4 @@ -## FUNC_BUILD=2016032501 +## FUNC_BUILD=2016033101 ## BEGIN Generic functions for osync & obackup written in 2013-2016 by Orsiris de Jong - http://www.netpower.fr - ozy@netpower.fr ## type -p does not work on platforms other than linux (bash). If if does not work, always assume output is not a zero exitcode @@ -82,11 +82,15 @@ function Dummy { } function _Logger { - local svalue="${1}" # What to log to screen + local svalue="${1}" # What to log to stdout local lvalue="${2:-$svalue}" # What to log to logfile, defaults to screen value + local evalue="${3}" # What to log to stderr echo -e "$lvalue" >> "$LOG_FILE" - if [ $_SILENT -eq 0 ]; then + # Special case in daemon mode where systemctl doesn't need double timestamps + if [ "$sync_on_changes" == "1" ]; then + cat <<< "$evalue" 1>&2 # Log to stderr in daemon mode + elif [ $_SILENT -eq 0 ]; then echo -e "$svalue" fi } @@ -104,15 +108,15 @@ function Logger { # if [ "$level" == "CRITICAL" ]; then - _Logger "$prefix\e[41m$value\e[0m" "$prefix$level:$value" + _Logger "$prefix\e[41m$value\e[0m" "$prefix$level:$value" "$level:$value" ERROR_ALERT=1 return elif [ "$level" == "ERROR" ]; then - _Logger "$prefix\e[91m$value\e[0m" "$prefix$level:$value" + _Logger "$prefix\e[91m$value\e[0m" "$prefix$level:$value" "$level:$value" ERROR_ALERT=1 return elif [ "$level" == "WARN" ]; then - _Logger "$prefix\e[93m$value\e[0m" "$prefix$level:$value" + _Logger "$prefix\e[93m$value\e[0m" "$prefix$level:$value" "$level:$value" WARN_ALERT=1 return elif [ "$level" == "NOTICE" ]; then @@ -485,7 +489,7 @@ function GetRemoteOS { exit 1 ;; *) - if [ "$IGNORE_OS_VER" == "yes" ]; then #DOC: Undocumented option + if [ "$IGNORE_OS_TYPE" == "yes" ]; then #DOC: Undocumented option Logger "Running on unknown remote OS [$remote_os_var]." "WARN" return fi @@ -968,7 +972,7 @@ function PostInit { __CheckArguments 0 $# ${FUNCNAME[0]} "$@" #__WITH_PARANOIA_DEBUG # Define remote commands - SSH_CMD="$(type -p ssh) $SSH_COMP -i $SSH_RSA_PRIVATE_KEY $SSH_IGNORE_KNOWN_HOSTS $REMOTE_USER@$REMOTE_HOST -p $REMOTE_PORT" + SSH_CMD="$(type -p ssh) $SSH_COMP -i $SSH_RSA_PRIVATE_KEY $SSH_OPTS $REMOTE_USER@$REMOTE_HOST -p $REMOTE_PORT" SCP_CMD="$(type -p scp) $SSH_COMP -i $SSH_RSA_PRIVATE_KEY -P $REMOTE_PORT" RSYNC_SSH_CMD="$(type -p ssh) $SSH_COMP -i $SSH_RSA_PRIVATE_KEY -p $REMOTE_PORT" } diff --git a/obackup.sh b/obackup.sh index 472e850..8250a94 100755 --- a/obackup.sh +++ b/obackup.sh @@ -2,13 +2,13 @@ ###### Remote push/pull (or local) backup script for files & databases PROGRAM="obackup" -AUTHOR="(L) 2013-2016 by Orsiris de Jong" +AUTHOR="(C) 2013-2016 by Orsiris de Jong" CONTACT="http://www.netpower.fr/obackup - ozy@netpower.fr" PROGRAM_VERSION=2.0-pre PROGRAM_BUILD=2016031801 IS_STABLE=no -## FUNC_BUILD=2016032501 +## FUNC_BUILD=2016033101 ## BEGIN Generic functions for osync & obackup written in 2013-2016 by Orsiris de Jong - http://www.netpower.fr - ozy@netpower.fr ## type -p does not work on platforms other than linux (bash). If if does not work, always assume output is not a zero exitcode @@ -87,11 +87,15 @@ function Dummy { } function _Logger { - local svalue="${1}" # What to log to screen + local svalue="${1}" # What to log to stdout local lvalue="${2:-$svalue}" # What to log to logfile, defaults to screen value + local evalue="${3}" # What to log to stderr echo -e "$lvalue" >> "$LOG_FILE" - if [ $_SILENT -eq 0 ]; then + # Special case in daemon mode where systemctl doesn't need double timestamps + if [ "$sync_on_changes" == "1" ]; then + cat <<< "$evalue" 1>&2 # Log to stderr in daemon mode + elif [ $_SILENT -eq 0 ]; then echo -e "$svalue" fi } @@ -109,15 +113,15 @@ function Logger { # if [ "$level" == "CRITICAL" ]; then - _Logger "$prefix\e[41m$value\e[0m" "$prefix$level:$value" + _Logger "$prefix\e[41m$value\e[0m" "$prefix$level:$value" "$level:$value" ERROR_ALERT=1 return elif [ "$level" == "ERROR" ]; then - _Logger "$prefix\e[91m$value\e[0m" "$prefix$level:$value" + _Logger "$prefix\e[91m$value\e[0m" "$prefix$level:$value" "$level:$value" ERROR_ALERT=1 return elif [ "$level" == "WARN" ]; then - _Logger "$prefix\e[93m$value\e[0m" "$prefix$level:$value" + _Logger "$prefix\e[93m$value\e[0m" "$prefix$level:$value" "$level:$value" WARN_ALERT=1 return elif [ "$level" == "NOTICE" ]; then @@ -480,7 +484,7 @@ function GetRemoteOS { exit 1 ;; *) - if [ "$IGNORE_OS_VER" == "yes" ]; then #DOC: Undocumented option + if [ "$IGNORE_OS_TYPE" == "yes" ]; then #DOC: Undocumented option Logger "Running on unknown remote OS [$remote_os_var]." "WARN" return fi @@ -908,7 +912,7 @@ function PreInit { function PostInit { # Define remote commands - SSH_CMD="$(type -p ssh) $SSH_COMP -i $SSH_RSA_PRIVATE_KEY $SSH_IGNORE_KNOWN_HOSTS $REMOTE_USER@$REMOTE_HOST -p $REMOTE_PORT" + SSH_CMD="$(type -p ssh) $SSH_COMP -i $SSH_RSA_PRIVATE_KEY $SSH_OPTS $REMOTE_USER@$REMOTE_HOST -p $REMOTE_PORT" SCP_CMD="$(type -p scp) $SSH_COMP -i $SSH_RSA_PRIVATE_KEY -P $REMOTE_PORT" RSYNC_SSH_CMD="$(type -p ssh) $SSH_COMP -i $SSH_RSA_PRIVATE_KEY -p $REMOTE_PORT" }