Added option to ignore unknown OS
This commit is contained in:
parent
d11bd61473
commit
8428662d61
|
@ -11,7 +11,7 @@ PROGRAM_VERSION=1.1-dev
|
|||
PROGRAM_BUILD=2016031002
|
||||
IS_STABLE=no
|
||||
|
||||
## FUNC_BUILD=2016031101
|
||||
## FUNC_BUILD=2016031901
|
||||
## 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
|
||||
|
@ -20,6 +20,21 @@ if ! type "$BASH" > /dev/null; then
|
|||
exit 127
|
||||
fi
|
||||
|
||||
#### obackup & osync specific code BEGIN ####
|
||||
|
||||
## Log a state message every $KEEP_LOGGING seconds. Should not be equal to soft or hard execution time so your log will not be unnecessary big.
|
||||
KEEP_LOGGING=1801
|
||||
|
||||
## Correct output of sort command (language agnostic sorting)
|
||||
export LC_ALL=C
|
||||
|
||||
# Standard alert mail body
|
||||
MAIL_ALERT_MSG="Execution of $PROGRAM instance $INSTANCE_ID on $(date) has warnings/errors."
|
||||
|
||||
#### obackup & osync specific code END ####
|
||||
|
||||
#### MINIMAL-FUNCTION-SET BEGIN ####
|
||||
|
||||
# Environment variables
|
||||
_DRYRUN=0
|
||||
_SILENT=0
|
||||
|
@ -44,8 +59,6 @@ else
|
|||
_VERBOSE=1
|
||||
fi
|
||||
|
||||
#### MINIMAL-FUNCTION-SET BEGIN ####
|
||||
|
||||
SCRIPT_PID=$$
|
||||
|
||||
LOCAL_USER=$(whoami)
|
||||
|
@ -67,14 +80,6 @@ else
|
|||
RUN_DIR=.
|
||||
fi
|
||||
|
||||
## Log a state message every $KEEP_LOGGING seconds. Should not be equal to soft or hard execution time so your log will not be unnecessary big.
|
||||
KEEP_LOGGING=1801
|
||||
|
||||
## Correct output of sort command (language agnostic sorting)
|
||||
export LC_ALL=C
|
||||
|
||||
# Standard alert mail body
|
||||
MAIL_ALERT_MSG="Execution of $PROGRAM instance $INSTANCE_ID on $(date) has warnings/errors."
|
||||
|
||||
# Default alert attachment filename
|
||||
ALERT_LOG_FILE="$RUN_DIR/$PROGRAM.last.log"
|
||||
|
@ -277,8 +282,6 @@ function SendAlert {
|
|||
fi
|
||||
}
|
||||
|
||||
#### MINIMAL-FUNCTION-SET END ####
|
||||
|
||||
function TrapError {
|
||||
local job="$0"
|
||||
local line="$1"
|
||||
|
@ -288,6 +291,28 @@ function TrapError {
|
|||
fi
|
||||
}
|
||||
|
||||
function LoadConfigFile {
|
||||
local config_file="${1}"
|
||||
__CheckArguments 1 $# ${FUNCNAME[0]} "$@" #__WITH_PARANOIA_DEBUG
|
||||
|
||||
|
||||
if [ ! -f "$config_file" ]; then
|
||||
Logger "Cannot load configuration file [$config_file]. Cannot start." "CRITICAL"
|
||||
exit 1
|
||||
elif [[ "$1" != *".conf" ]]; then
|
||||
Logger "Wrong configuration file supplied [$config_file]. Cannot start." "CRITICAL"
|
||||
exit 1
|
||||
else
|
||||
grep '^[^ ]*=[^;&]*' "$config_file" > "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID" # WITHOUT COMMENTS
|
||||
# Shellcheck source=./sync.conf
|
||||
source "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID"
|
||||
fi
|
||||
|
||||
CONFIG_FILE="$config_file"
|
||||
}
|
||||
|
||||
#### MINIMAL-FUNCTION-SET END ####
|
||||
|
||||
function Spinner {
|
||||
if [ $_SILENT -eq 1 ]; then
|
||||
return 0
|
||||
|
@ -368,26 +393,6 @@ function CleanUp {
|
|||
fi
|
||||
}
|
||||
|
||||
function LoadConfigFile {
|
||||
local config_file="${1}"
|
||||
__CheckArguments 1 $# ${FUNCNAME[0]} "$@" #__WITH_PARANOIA_DEBUG
|
||||
|
||||
|
||||
if [ ! -f "$config_file" ]; then
|
||||
Logger "Cannot load configuration file [$config_file]. Cannot start." "CRITICAL"
|
||||
exit 1
|
||||
elif [[ "$1" != *".conf" ]]; then
|
||||
Logger "Wrong configuration file supplied [$config_file]. Cannot start." "CRITICAL"
|
||||
exit 1
|
||||
else
|
||||
grep '^[^ ]*=[^;&]*' "$config_file" > "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID" # WITHOUT COMMENTS
|
||||
# Shellcheck source=./sync.conf
|
||||
source "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID"
|
||||
fi
|
||||
|
||||
CONFIG_FILE="$config_file"
|
||||
}
|
||||
|
||||
function GetLocalOS {
|
||||
__CheckArguments 0 $# ${FUNCNAME[0]} "$@" #__WITH_PARANOIA_DEBUG
|
||||
|
||||
|
@ -415,6 +420,10 @@ function GetLocalOS {
|
|||
LOCAL_OS="MacOSX"
|
||||
;;
|
||||
*)
|
||||
if [ "$IGNORE_OS_TYPE" == "yes" ]; then #DOC: Undocumented option
|
||||
Logger "Running on unknown local OS." "WARN"
|
||||
return
|
||||
fi
|
||||
Logger "Running on >> $local_os_var << not supported. Please report to the author." "ERROR"
|
||||
exit 1
|
||||
;;
|
||||
|
@ -475,6 +484,10 @@ function GetRemoteOS {
|
|||
exit 1
|
||||
;;
|
||||
*)
|
||||
if [ "$IGNORE_OS_VER" == "yes" ]; then #DOC: Undocumented option
|
||||
Logger "Running on unknown remote OS." "WARN"
|
||||
return
|
||||
fi
|
||||
Logger "Running on remote OS failed. Please report to the author if the OS is not supported." "CRITICAL"
|
||||
Logger "Remote OS said:\n$remote_os_var" "CRITICAL"
|
||||
exit 1
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
## FUNC_BUILD=2016031101
|
||||
## FUNC_BUILD=2016031901
|
||||
## 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
|
||||
|
@ -7,6 +7,21 @@ if ! type "$BASH" > /dev/null; then
|
|||
exit 127
|
||||
fi
|
||||
|
||||
#### obackup & osync specific code BEGIN ####
|
||||
|
||||
## Log a state message every $KEEP_LOGGING seconds. Should not be equal to soft or hard execution time so your log will not be unnecessary big.
|
||||
KEEP_LOGGING=1801
|
||||
|
||||
## Correct output of sort command (language agnostic sorting)
|
||||
export LC_ALL=C
|
||||
|
||||
# Standard alert mail body
|
||||
MAIL_ALERT_MSG="Execution of $PROGRAM instance $INSTANCE_ID on $(date) has warnings/errors."
|
||||
|
||||
#### obackup & osync specific code END ####
|
||||
|
||||
#### MINIMAL-FUNCTION-SET BEGIN ####
|
||||
|
||||
# Environment variables
|
||||
_DRYRUN=0
|
||||
_SILENT=0
|
||||
|
@ -31,8 +46,6 @@ else
|
|||
_VERBOSE=1
|
||||
fi
|
||||
|
||||
#### MINIMAL-FUNCTION-SET BEGIN ####
|
||||
|
||||
SCRIPT_PID=$$
|
||||
|
||||
LOCAL_USER=$(whoami)
|
||||
|
@ -54,14 +67,6 @@ else
|
|||
RUN_DIR=.
|
||||
fi
|
||||
|
||||
## Log a state message every $KEEP_LOGGING seconds. Should not be equal to soft or hard execution time so your log will not be unnecessary big.
|
||||
KEEP_LOGGING=1801
|
||||
|
||||
## Correct output of sort command (language agnostic sorting)
|
||||
export LC_ALL=C
|
||||
|
||||
# Standard alert mail body
|
||||
MAIL_ALERT_MSG="Execution of $PROGRAM instance $INSTANCE_ID on $(date) has warnings/errors."
|
||||
|
||||
# Default alert attachment filename
|
||||
ALERT_LOG_FILE="$RUN_DIR/$PROGRAM.last.log"
|
||||
|
@ -264,8 +269,6 @@ function SendAlert {
|
|||
fi
|
||||
}
|
||||
|
||||
#### MINIMAL-FUNCTION-SET END ####
|
||||
|
||||
function TrapError {
|
||||
local job="$0"
|
||||
local line="$1"
|
||||
|
@ -275,6 +278,28 @@ function TrapError {
|
|||
fi
|
||||
}
|
||||
|
||||
function LoadConfigFile {
|
||||
local config_file="${1}"
|
||||
__CheckArguments 1 $# ${FUNCNAME[0]} "$@" #__WITH_PARANOIA_DEBUG
|
||||
|
||||
|
||||
if [ ! -f "$config_file" ]; then
|
||||
Logger "Cannot load configuration file [$config_file]. Cannot start." "CRITICAL"
|
||||
exit 1
|
||||
elif [[ "$1" != *".conf" ]]; then
|
||||
Logger "Wrong configuration file supplied [$config_file]. Cannot start." "CRITICAL"
|
||||
exit 1
|
||||
else
|
||||
grep '^[^ ]*=[^;&]*' "$config_file" > "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID" # WITHOUT COMMENTS
|
||||
# Shellcheck source=./sync.conf
|
||||
source "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID"
|
||||
fi
|
||||
|
||||
CONFIG_FILE="$config_file"
|
||||
}
|
||||
|
||||
#### MINIMAL-FUNCTION-SET END ####
|
||||
|
||||
function Spinner {
|
||||
if [ $_SILENT -eq 1 ]; then
|
||||
return 0
|
||||
|
@ -355,26 +380,6 @@ function CleanUp {
|
|||
fi
|
||||
}
|
||||
|
||||
function LoadConfigFile {
|
||||
local config_file="${1}"
|
||||
__CheckArguments 1 $# ${FUNCNAME[0]} "$@" #__WITH_PARANOIA_DEBUG
|
||||
|
||||
|
||||
if [ ! -f "$config_file" ]; then
|
||||
Logger "Cannot load configuration file [$config_file]. Cannot start." "CRITICAL"
|
||||
exit 1
|
||||
elif [[ "$1" != *".conf" ]]; then
|
||||
Logger "Wrong configuration file supplied [$config_file]. Cannot start." "CRITICAL"
|
||||
exit 1
|
||||
else
|
||||
grep '^[^ ]*=[^;&]*' "$config_file" > "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID" # WITHOUT COMMENTS
|
||||
# Shellcheck source=./sync.conf
|
||||
source "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID"
|
||||
fi
|
||||
|
||||
CONFIG_FILE="$config_file"
|
||||
}
|
||||
|
||||
function GetLocalOS {
|
||||
__CheckArguments 0 $# ${FUNCNAME[0]} "$@" #__WITH_PARANOIA_DEBUG
|
||||
|
||||
|
@ -402,6 +407,10 @@ function GetLocalOS {
|
|||
LOCAL_OS="MacOSX"
|
||||
;;
|
||||
*)
|
||||
if [ "$IGNORE_OS_TYPE" == "yes" ]; then #DOC: Undocumented option
|
||||
Logger "Running on unknown local OS." "WARN"
|
||||
return
|
||||
fi
|
||||
Logger "Running on >> $local_os_var << not supported. Please report to the author." "ERROR"
|
||||
exit 1
|
||||
;;
|
||||
|
@ -462,6 +471,10 @@ function GetRemoteOS {
|
|||
exit 1
|
||||
;;
|
||||
*)
|
||||
if [ "$IGNORE_OS_VER" == "yes" ]; then #DOC: Undocumented option
|
||||
Logger "Running on unknown remote OS." "WARN"
|
||||
return
|
||||
fi
|
||||
Logger "Running on remote OS failed. Please report to the author if the OS is not supported." "CRITICAL"
|
||||
Logger "Remote OS said:\n$remote_os_var" "CRITICAL"
|
||||
exit 1
|
||||
|
|
77
osync.sh
77
osync.sh
|
@ -11,7 +11,7 @@ PROGRAM_VERSION=1.1-dev
|
|||
PROGRAM_BUILD=2016031002
|
||||
IS_STABLE=no
|
||||
|
||||
## FUNC_BUILD=2016031101
|
||||
## FUNC_BUILD=2016031901
|
||||
## 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
|
||||
|
@ -20,6 +20,21 @@ if ! type "$BASH" > /dev/null; then
|
|||
exit 127
|
||||
fi
|
||||
|
||||
#### obackup & osync specific code BEGIN ####
|
||||
|
||||
## Log a state message every $KEEP_LOGGING seconds. Should not be equal to soft or hard execution time so your log will not be unnecessary big.
|
||||
KEEP_LOGGING=1801
|
||||
|
||||
## Correct output of sort command (language agnostic sorting)
|
||||
export LC_ALL=C
|
||||
|
||||
# Standard alert mail body
|
||||
MAIL_ALERT_MSG="Execution of $PROGRAM instance $INSTANCE_ID on $(date) has warnings/errors."
|
||||
|
||||
#### obackup & osync specific code END ####
|
||||
|
||||
#### MINIMAL-FUNCTION-SET BEGIN ####
|
||||
|
||||
# Environment variables
|
||||
_DRYRUN=0
|
||||
_SILENT=0
|
||||
|
@ -40,8 +55,6 @@ else
|
|||
_VERBOSE=1
|
||||
fi
|
||||
|
||||
#### MINIMAL-FUNCTION-SET BEGIN ####
|
||||
|
||||
SCRIPT_PID=$$
|
||||
|
||||
LOCAL_USER=$(whoami)
|
||||
|
@ -63,14 +76,6 @@ else
|
|||
RUN_DIR=.
|
||||
fi
|
||||
|
||||
## Log a state message every $KEEP_LOGGING seconds. Should not be equal to soft or hard execution time so your log will not be unnecessary big.
|
||||
KEEP_LOGGING=1801
|
||||
|
||||
## Correct output of sort command (language agnostic sorting)
|
||||
export LC_ALL=C
|
||||
|
||||
# Standard alert mail body
|
||||
MAIL_ALERT_MSG="Execution of $PROGRAM instance $INSTANCE_ID on $(date) has warnings/errors."
|
||||
|
||||
# Default alert attachment filename
|
||||
ALERT_LOG_FILE="$RUN_DIR/$PROGRAM.last.log"
|
||||
|
@ -266,8 +271,6 @@ function SendAlert {
|
|||
fi
|
||||
}
|
||||
|
||||
#### MINIMAL-FUNCTION-SET END ####
|
||||
|
||||
function TrapError {
|
||||
local job="$0"
|
||||
local line="$1"
|
||||
|
@ -277,6 +280,27 @@ function TrapError {
|
|||
fi
|
||||
}
|
||||
|
||||
function LoadConfigFile {
|
||||
local config_file="${1}"
|
||||
|
||||
|
||||
if [ ! -f "$config_file" ]; then
|
||||
Logger "Cannot load configuration file [$config_file]. Cannot start." "CRITICAL"
|
||||
exit 1
|
||||
elif [[ "$1" != *".conf" ]]; then
|
||||
Logger "Wrong configuration file supplied [$config_file]. Cannot start." "CRITICAL"
|
||||
exit 1
|
||||
else
|
||||
grep '^[^ ]*=[^;&]*' "$config_file" > "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID" # WITHOUT COMMENTS
|
||||
# Shellcheck source=./sync.conf
|
||||
source "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID"
|
||||
fi
|
||||
|
||||
CONFIG_FILE="$config_file"
|
||||
}
|
||||
|
||||
#### MINIMAL-FUNCTION-SET END ####
|
||||
|
||||
function Spinner {
|
||||
if [ $_SILENT -eq 1 ]; then
|
||||
return 0
|
||||
|
@ -356,25 +380,6 @@ function CleanUp {
|
|||
fi
|
||||
}
|
||||
|
||||
function LoadConfigFile {
|
||||
local config_file="${1}"
|
||||
|
||||
|
||||
if [ ! -f "$config_file" ]; then
|
||||
Logger "Cannot load configuration file [$config_file]. Cannot start." "CRITICAL"
|
||||
exit 1
|
||||
elif [[ "$1" != *".conf" ]]; then
|
||||
Logger "Wrong configuration file supplied [$config_file]. Cannot start." "CRITICAL"
|
||||
exit 1
|
||||
else
|
||||
grep '^[^ ]*=[^;&]*' "$config_file" > "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID" # WITHOUT COMMENTS
|
||||
# Shellcheck source=./sync.conf
|
||||
source "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID"
|
||||
fi
|
||||
|
||||
CONFIG_FILE="$config_file"
|
||||
}
|
||||
|
||||
function GetLocalOS {
|
||||
|
||||
local local_os_var=
|
||||
|
@ -401,6 +406,10 @@ function GetLocalOS {
|
|||
LOCAL_OS="MacOSX"
|
||||
;;
|
||||
*)
|
||||
if [ "$IGNORE_OS_TYPE" == "yes" ]; then #DOC: Undocumented option
|
||||
Logger "Running on unknown local OS." "WARN"
|
||||
return
|
||||
fi
|
||||
Logger "Running on >> $local_os_var << not supported. Please report to the author." "ERROR"
|
||||
exit 1
|
||||
;;
|
||||
|
@ -460,6 +469,10 @@ function GetRemoteOS {
|
|||
exit 1
|
||||
;;
|
||||
*)
|
||||
if [ "$IGNORE_OS_VER" == "yes" ]; then #DOC: Undocumented option
|
||||
Logger "Running on unknown remote OS." "WARN"
|
||||
return
|
||||
fi
|
||||
Logger "Running on remote OS failed. Please report to the author if the OS is not supported." "CRITICAL"
|
||||
Logger "Remote OS said:\n$remote_os_var" "CRITICAL"
|
||||
exit 1
|
||||
|
|
Loading…
Reference in New Issue