-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
47 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,13 +3,12 @@ | |
PROGRAM="osync" # Rsync based two way sync engine with fault tolerance | ||
AUTHOR="(C) 2013-2017 by Orsiris de Jong" | ||
CONTACT="http://www.netpower.fr/osync - [email protected]" | ||
PROGRAM_VERSION=1.2-RC2 | ||
PROGRAM_BUILD=2017020802 | ||
IS_STABLE=yes | ||
|
||
# Execution order #__WITH_PARANOIA_DEBUG | ||
# Function Name Is parallel #__WITH_PARANOIA_DEBUG | ||
PROGRAM_VERSION=1.2-RC3 | ||
PROGRAM_BUILD=2017021001 | ||
IS_STABLE=no | ||
|
||
##### Execution order #__WITH_PARANOIA_DEBUG | ||
##### Function Name Is parallel #__WITH_PARANOIA_DEBUG | ||
# GetLocalOS no #__WITH_PARANOIA_DEBUG | ||
# InitLocalOSDependingSettings no #__WITH_PARANOIA_DEBUG | ||
# CheckEnvironment no #__WITH_PARANOIA_DEBUG | ||
|
@@ -41,8 +40,8 @@ IS_STABLE=yes | |
# CleanUp no #__WITH_PARANOIA_DEBUG | ||
|
||
|
||
_OFUNCTIONS_VERSION=2.1-RC2 | ||
_OFUNCTIONS_BUILD=2017020801 | ||
_OFUNCTIONS_VERSION=2.1-RC3 | ||
_OFUNCTIONS_BUILD=2017021003 | ||
_OFUNCTIONS_BOOTSTRAP=true | ||
|
||
## BEGIN Generic bash functions written in 2013-2017 by Orsiris de Jong - http://www.netpower.fr - [email protected] | ||
|
@@ -267,6 +266,10 @@ function Logger { | |
prefix="" | ||
fi | ||
|
||
## Obfuscate _REMOTE_TOKEN in logs (for ssh_filter usage only in osync and obackup) | ||
value="${value/env _REMOTE_TOKEN=$_REMOTE_TOKEN/__(o_O)__}" | ||
value="${value/env _REMOTE_TOKEN=\$_REMOTE_TOKEN/__(o_O)__}" | ||
|
||
if [ "$level" == "CRITICAL" ]; then | ||
_Logger "$prefix($level):$value" "$prefix\e[1;33;41m$value\e[0m" true | ||
ERROR_ALERT=true | ||
|
@@ -1885,18 +1888,18 @@ function SetConfFileValue () { | |
local file="${1}" | ||
local name="${2}" | ||
local value="${3}" | ||
local separator="${4:-#}" | ||
|
||
if grep "^$name=" "$file" > /dev/null; then | ||
# Using -i.tmp for BSD compat | ||
sed -i.tmp "s/^$name=.*/$name=$value/" "$file" | ||
sed -i.tmp "s$separator^$name=.*$separator$name=$value$separator" "$file" | ||
rm -f "$file.tmp" | ||
Logger "Set [$name] to [$value] in config file [$file]." "DEBUG" | ||
else | ||
Logger "Cannot set value [$name] to [$value] in config file [$file]." "ERROR" | ||
fi | ||
} | ||
|
||
|
||
# If using "include" statements, make sure the script does not get executed unless it's loaded by bootstrap | ||
_OFUNCTIONS_BOOTSTRAP=true | ||
[ "$_OFUNCTIONS_BOOTSTRAP" != true ] && echo "Please use bootstrap.sh to load this dev version of $(basename $0)" && exit 1 | ||
|
@@ -2864,7 +2867,7 @@ function treeList { | |
return 0 | ||
else | ||
Logger "Cannot create replica file list in [$replicaPath]." "CRITICAL" $retval | ||
Logger "Command was [$rsyncCmd]." "WARN" | ||
_LOGGER_SILENT=true Logger "Command was [$rsyncCmd]." "WARN" | ||
Logger "Command output\n$(cat $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$replicaType.error.$SCRIPT_PID.$TSTAMP)" "WARN" | ||
return $retval | ||
fi | ||
|
@@ -2907,7 +2910,7 @@ function deleteList { | |
if [ $retval -ne 0 ]; then | ||
Logger "Could not prepare $replicaType deletion list." "CRITICAL" $retval | ||
Logger "Command was [$cmd]." "WARN" | ||
_LOGGER_SILENT=true Logger "Command was [$cmd]." "WARN" | ||
return $retval | ||
fi | ||
|
@@ -2966,7 +2969,7 @@ function _getFileCtimeMtimeRemote { | |
retval=$? | ||
if [ $retval -ne 0 ]; then | ||
Logger "Sending ctime required file list failed with [$retval] on $replicaType. Stopping execution." "CRITICAL" $retval | ||
Logger "Command was [$cmd]." "WARN" | ||
_LOGGER_SILENT=true Logger "Command was [$cmd]." "WARN" | ||
if [ -f "$RUN_DIR/$PROGRAM.ctime_mtime.$replicaType.$SCRIPT_PID.$TSTAMP" ]; then | ||
Logger "Command output:\n$(cat $RUN_DIR/$PROGRAM.ctime_mtime.$replicaType.$SCRIPT_PID.$TSTAMP)" "WARN" | ||
fi | ||
|
@@ -3032,7 +3035,7 @@ function syncAttrs { | |
if [ $retval -ne 0 ] && [ $retval -ne 24 ]; then | ||
Logger "Getting list of files that need updates failed [$retval]. Stopping execution." "CRITICAL" $retval | ||
Logger "Command was [$rsyncCmd]." "WARN" | ||
_LOGGER_SILENT=true Logger "Command was [$rsyncCmd]." "WARN" | ||
if [ -f "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP" ]; then | ||
Logger "Rsync output:\n$(cat $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP)" "NOTICE" | ||
fi | ||
|
@@ -3119,7 +3122,7 @@ function syncAttrs { | |
if [ $retval -ne 0 ] && [ $retval -ne 24 ]; then | ||
Logger "Updating file attributes on $destReplica [$retval]. Stopping execution." "CRITICAL" $retval | ||
Logger "Command was [$rsyncCmd]." "WARN" | ||
_LOGGER_SILENT=true Logger "Command was [$rsyncCmd]." "WARN" | ||
if [ -f "$RUN_DIR/$PROGRAM.attr-update.$destReplica.$SCRIPT_PID.$TSTAMP" ]; then | ||
Logger "Rsync output:\n$(cat $RUN_DIR/$PROGRAM.attr-update.$destReplica.$SCRIPT_PID.$TSTAMP)" "NOTICE" | ||
fi | ||
|
@@ -3182,7 +3185,7 @@ function syncUpdate { | |
if [ $retval -ne 0 ] && [ $retval -ne 24 ]; then | ||
Logger "Updating $destinationReplica replica failed. Stopping execution." "CRITICAL" $retval | ||
Logger "Command was [$rsyncCmd]." "WARN" | ||
_LOGGER_SILENT=true Logger "Command was [$rsyncCmd]." "WARN" | ||
if [ -f "$RUN_DIR/$PROGRAM.update.$destinationReplica.$SCRIPT_PID.$TSTAMP" ]; then | ||
Logger "Rsync output:\n$(cat $RUN_DIR/$PROGRAM.update.$destinationReplica.$SCRIPT_PID.$TSTAMP)" "NOTICE" | ||
fi | ||
|
@@ -3313,7 +3316,7 @@ function _deleteRemote { | |
retval=$? | ||
if [ $retval -ne 0 ]; then | ||
Logger "Cannot copy the deletion list to remote replica." "ERROR" $retval | ||
Logger "Command was [$rsyncCmd]." "WARN" | ||
_LOGGER_SILENT=true Logger "Command was [$rsyncCmd]." "WARN" | ||
if [ -f "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.precopy.$SCRIPT_PID.$TSTAMP" ]; then | ||
Logger "$(cat $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.precopy.$SCRIPT_PID.$TSTAMP)" "ERROR" | ||
fi | ||
|
@@ -3524,7 +3527,7 @@ ENDSSH | |
retval=$? | ||
if [ $retval -ne 0 ]; then | ||
Logger "Cannot copy back the failed deletion list to initiator replica." "CRITICAL" $retval | ||
Logger "Command was [$rsyncCmd]." "WARN" | ||
_LOGGER_SILENT=true Logger "Command was [$rsyncCmd]." "WARN" | ||
if [ -f "$RUN_DIR/$PROGRAM.remote_failed_deletion_list_copy.$SCRIPT_PID.$TSTAMP" ]; then | ||
Logger "Comand output: $(cat $RUN_DIR/$PROGRAM.remote_failed_deletion_list_copy.$SCRIPT_PID.$TSTAMP)" "NOTICE" | ||
fi | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,15 +3,14 @@ | |
PROGRAM="osync" # Rsync based two way sync engine with fault tolerance | ||
AUTHOR="(C) 2013-2017 by Orsiris de Jong" | ||
CONTACT="http://www.netpower.fr/osync - [email protected]" | ||
PROGRAM_VERSION=1.2-RC2 | ||
PROGRAM_BUILD=2017020802 | ||
IS_STABLE=yes | ||
PROGRAM_VERSION=1.2-RC3 | ||
PROGRAM_BUILD=2017021001 | ||
IS_STABLE=no | ||
|
||
|
||
|
||
|
||
_OFUNCTIONS_VERSION=2.1-RC2 | ||
_OFUNCTIONS_BUILD=2017020801 | ||
_OFUNCTIONS_VERSION=2.1-RC3 | ||
_OFUNCTIONS_BUILD=2017021003 | ||
_OFUNCTIONS_BOOTSTRAP=true | ||
|
||
## BEGIN Generic bash functions written in 2013-2017 by Orsiris de Jong - http://www.netpower.fr - [email protected] | ||
|
@@ -226,6 +225,10 @@ function Logger { | |
prefix="" | ||
fi | ||
|
||
## Obfuscate _REMOTE_TOKEN in logs (for ssh_filter usage only in osync and obackup) | ||
value="${value/env _REMOTE_TOKEN=$_REMOTE_TOKEN/__(o_O)__}" | ||
value="${value/env _REMOTE_TOKEN=\$_REMOTE_TOKEN/__(o_O)__}" | ||
|
||
if [ "$level" == "CRITICAL" ]; then | ||
_Logger "$prefix($level):$value" "$prefix\e[1;33;41m$value\e[0m" true | ||
ERROR_ALERT=true | ||
|
@@ -1746,18 +1749,18 @@ function SetConfFileValue () { | |
local file="${1}" | ||
local name="${2}" | ||
local value="${3}" | ||
local separator="${4:-#}" | ||
|
||
if grep "^$name=" "$file" > /dev/null; then | ||
# Using -i.tmp for BSD compat | ||
sed -i.tmp "s/^$name=.*/$name=$value/" "$file" | ||
sed -i.tmp "s$separator^$name=.*$separator$name=$value$separator" "$file" | ||
rm -f "$file.tmp" | ||
Logger "Set [$name] to [$value] in config file [$file]." "DEBUG" | ||
else | ||
Logger "Cannot set value [$name] to [$value] in config file [$file]." "ERROR" | ||
fi | ||
} | ||
|
||
|
||
# If using "include" statements, make sure the script does not get executed unless it's loaded by bootstrap | ||
_OFUNCTIONS_BOOTSTRAP=true | ||
[ "$_OFUNCTIONS_BOOTSTRAP" != true ] && echo "Please use bootstrap.sh to load this dev version of $(basename $0)" && exit 1 | ||
|
@@ -2694,7 +2697,7 @@ function treeList { | |
return 0 | ||
else | ||
Logger "Cannot create replica file list in [$replicaPath]." "CRITICAL" $retval | ||
Logger "Command was [$rsyncCmd]." "WARN" | ||
_LOGGER_SILENT=true Logger "Command was [$rsyncCmd]." "WARN" | ||
Logger "Command output\n$(cat $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$replicaType.error.$SCRIPT_PID.$TSTAMP)" "WARN" | ||
return $retval | ||
fi | ||
|
@@ -2736,7 +2739,7 @@ function deleteList { | |
if [ $retval -ne 0 ]; then | ||
Logger "Could not prepare $replicaType deletion list." "CRITICAL" $retval | ||
Logger "Command was [$cmd]." "WARN" | ||
_LOGGER_SILENT=true Logger "Command was [$cmd]." "WARN" | ||
return $retval | ||
fi | ||
|
@@ -2793,7 +2796,7 @@ function _getFileCtimeMtimeRemote { | |
retval=$? | ||
if [ $retval -ne 0 ]; then | ||
Logger "Sending ctime required file list failed with [$retval] on $replicaType. Stopping execution." "CRITICAL" $retval | ||
Logger "Command was [$cmd]." "WARN" | ||
_LOGGER_SILENT=true Logger "Command was [$cmd]." "WARN" | ||
if [ -f "$RUN_DIR/$PROGRAM.ctime_mtime.$replicaType.$SCRIPT_PID.$TSTAMP" ]; then | ||
Logger "Command output:\n$(cat $RUN_DIR/$PROGRAM.ctime_mtime.$replicaType.$SCRIPT_PID.$TSTAMP)" "WARN" | ||
fi | ||
|
@@ -2858,7 +2861,7 @@ function syncAttrs { | |
if [ $retval -ne 0 ] && [ $retval -ne 24 ]; then | ||
Logger "Getting list of files that need updates failed [$retval]. Stopping execution." "CRITICAL" $retval | ||
Logger "Command was [$rsyncCmd]." "WARN" | ||
_LOGGER_SILENT=true Logger "Command was [$rsyncCmd]." "WARN" | ||
if [ -f "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP" ]; then | ||
Logger "Rsync output:\n$(cat $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP)" "NOTICE" | ||
fi | ||
|
@@ -2945,7 +2948,7 @@ function syncAttrs { | |
if [ $retval -ne 0 ] && [ $retval -ne 24 ]; then | ||
Logger "Updating file attributes on $destReplica [$retval]. Stopping execution." "CRITICAL" $retval | ||
Logger "Command was [$rsyncCmd]." "WARN" | ||
_LOGGER_SILENT=true Logger "Command was [$rsyncCmd]." "WARN" | ||
if [ -f "$RUN_DIR/$PROGRAM.attr-update.$destReplica.$SCRIPT_PID.$TSTAMP" ]; then | ||
Logger "Rsync output:\n$(cat $RUN_DIR/$PROGRAM.attr-update.$destReplica.$SCRIPT_PID.$TSTAMP)" "NOTICE" | ||
fi | ||
|
@@ -3007,7 +3010,7 @@ function syncUpdate { | |
if [ $retval -ne 0 ] && [ $retval -ne 24 ]; then | ||
Logger "Updating $destinationReplica replica failed. Stopping execution." "CRITICAL" $retval | ||
Logger "Command was [$rsyncCmd]." "WARN" | ||
_LOGGER_SILENT=true Logger "Command was [$rsyncCmd]." "WARN" | ||
if [ -f "$RUN_DIR/$PROGRAM.update.$destinationReplica.$SCRIPT_PID.$TSTAMP" ]; then | ||
Logger "Rsync output:\n$(cat $RUN_DIR/$PROGRAM.update.$destinationReplica.$SCRIPT_PID.$TSTAMP)" "NOTICE" | ||
fi | ||
|
@@ -3136,7 +3139,7 @@ function _deleteRemote { | |
retval=$? | ||
if [ $retval -ne 0 ]; then | ||
Logger "Cannot copy the deletion list to remote replica." "ERROR" $retval | ||
Logger "Command was [$rsyncCmd]." "WARN" | ||
_LOGGER_SILENT=true Logger "Command was [$rsyncCmd]." "WARN" | ||
if [ -f "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.precopy.$SCRIPT_PID.$TSTAMP" ]; then | ||
Logger "$(cat $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.precopy.$SCRIPT_PID.$TSTAMP)" "ERROR" | ||
fi | ||
|
@@ -3338,7 +3341,7 @@ ENDSSH | |
retval=$? | ||
if [ $retval -ne 0 ]; then | ||
Logger "Cannot copy back the failed deletion list to initiator replica." "CRITICAL" $retval | ||
Logger "Command was [$rsyncCmd]." "WARN" | ||
_LOGGER_SILENT=true Logger "Command was [$rsyncCmd]." "WARN" | ||
if [ -f "$RUN_DIR/$PROGRAM.remote_failed_deletion_list_copy.$SCRIPT_PID.$TSTAMP" ]; then | ||
Logger "Comand output: $(cat $RUN_DIR/$PROGRAM.remote_failed_deletion_list_copy.$SCRIPT_PID.$TSTAMP)" "NOTICE" | ||
fi | ||
|