Skip to content

Commit

Permalink
Rebuilt targets
Browse files Browse the repository at this point in the history
  • Loading branch information
deajan committed Feb 10, 2017
1 parent baaf1a6 commit b28f3fc
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 37 deletions.
39 changes: 21 additions & 18 deletions dev/debug_osync.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
10 changes: 7 additions & 3 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
_OFUNCTIONS_BOOTSTRAP=true

PROGRAM=osync
PROGRAM_VERSION=1.2-RC2
PROGRAM_VERSION=1.2-RC3
PROGRAM_BINARY=$PROGRAM".sh"
PROGRAM_BATCH=$PROGRAM"-batch.sh"
SSH_FILTER="ssh_filter.sh"

SCRIPT_BUILD=2017020802
SCRIPT_BUILD=2017021002

## osync / obackup / pmocr / zsnap install script
## Tested on RHEL / CentOS 6 & 7, Fedora 23, Debian 7 & 8, Mint 17 and FreeBSD 8, 10 and 11
Expand Down Expand Up @@ -379,7 +379,11 @@ function RemoveFile {
function RemoveAll {
RemoveFile "$BIN_DIR/$PROGRAM_BINARY"
RemoveFile "$BIN_DIR/$PROGRAM_BATCH"
RemoveFile "$BIN_DIR/$SSH_FILTER"
if [ ! -f "$BIN_DIR/osync.sh" ] && [ ! -f "$BIN_DIR/obackup.sh" ]; then # Check if any other program requiring ssh filter is present before removal
RemoveFile "$BIN_DIR/$SSH_FILTER"
else
QuickLogger "Skipping removal of [$BIN_DIR/$SSH_FILTER] because other programs present that need it."
fi
RemoveFile "$SERVICE_DIR_SYSTEMD_SYSTEM/$SERVICE_FILE_SYSTEMD_SYSTEM"
RemoveFile "$SERVICE_DIR_SYSTEMD_USER/$SERVICE_FILE_SYSTEMD_SYSTEM"
RemoveFile "$SERVICE_DIR_INIT/$SERVICE_FILE_INIT"
Expand Down
35 changes: 19 additions & 16 deletions osync.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit b28f3fc

Please sign in to comment.