Fixed infamous exclude bug introduced with no globbing
This commit is contained in:
parent
a1c29f62d5
commit
f134ed35a3
|
@ -28,6 +28,8 @@ UNDER WORK
|
||||||
RECENT CHANGES
|
RECENT CHANGES
|
||||||
--------------
|
--------------
|
||||||
|
|
||||||
|
- Prevent debug mode to send alert emails
|
||||||
|
- Fixed an infamous bug introduced with exclude pattern globbing preventing multiple exludes to be processed
|
||||||
- Fixed an issue with empty RSYNC_EXCLUDE_FILES
|
- Fixed an issue with empty RSYNC_EXCLUDE_FILES
|
||||||
- Lowered default compression level for email alerts (for low end systems
|
- Lowered default compression level for email alerts (for low end systems
|
||||||
- Prevent exclude pattern globbing before the pattern reaches the rsync cmd
|
- Prevent exclude pattern globbing before the pattern reaches the rsync cmd
|
||||||
|
|
30
osync.sh
30
osync.sh
|
@ -4,7 +4,7 @@ PROGRAM="Osync" # Rsync based two way sync engine with fault tolerance
|
||||||
AUTHOR="(L) 2013-2015 by Orsiris \"Ozy\" de Jong"
|
AUTHOR="(L) 2013-2015 by Orsiris \"Ozy\" de Jong"
|
||||||
CONTACT="http://www.netpower.fr/osync - ozy@netpower.fr"
|
CONTACT="http://www.netpower.fr/osync - ozy@netpower.fr"
|
||||||
PROGRAM_VERSION=0.99RC4
|
PROGRAM_VERSION=0.99RC4
|
||||||
PROGRAM_BUILD=1802201501
|
PROGRAM_BUILD=2003201502
|
||||||
|
|
||||||
## type doesn't work on platforms other than linux (bash). If if doesn't work, always assume output is not a zero exitcode
|
## type doesn't work on platforms other than linux (bash). If if doesn't work, always assume output is not a zero exitcode
|
||||||
if ! type -p "$BASH" > /dev/null
|
if ! type -p "$BASH" > /dev/null
|
||||||
|
@ -19,7 +19,7 @@ then
|
||||||
DEBUG=no
|
DEBUG=no
|
||||||
SLEEP_TIME=1
|
SLEEP_TIME=1
|
||||||
else
|
else
|
||||||
SLEEP_TIME=10
|
SLEEP_TIME=3
|
||||||
fi
|
fi
|
||||||
|
|
||||||
SCRIPT_PID=$$
|
SCRIPT_PID=$$
|
||||||
|
@ -123,8 +123,13 @@ function TrapStop
|
||||||
function TrapQuit
|
function TrapQuit
|
||||||
{
|
{
|
||||||
if [ $error_alert -ne 0 ]
|
if [ $error_alert -ne 0 ]
|
||||||
|
then
|
||||||
|
if [ "$DEBUG" != "yes" ]
|
||||||
then
|
then
|
||||||
SendAlert
|
SendAlert
|
||||||
|
else
|
||||||
|
Log "Debug mode, no alert mail will be sent."
|
||||||
|
fi
|
||||||
UnlockDirectories
|
UnlockDirectories
|
||||||
CleanUp
|
CleanUp
|
||||||
LogError "Osync finished with errors."
|
LogError "Osync finished with errors."
|
||||||
|
@ -724,18 +729,27 @@ function RsyncExcludePattern
|
||||||
{
|
{
|
||||||
# Disable globbing so wildcards from exclusions don't get expanded
|
# Disable globbing so wildcards from exclusions don't get expanded
|
||||||
set -f
|
set -f
|
||||||
OLD_IFS=$IFS
|
rest="$RSYNC_EXCLUDE_PATTERN"
|
||||||
IFS=$PATH_SEPARATOR_CHAR
|
while [ -n "$rest" ]
|
||||||
for excludedir in "$RSYNC_EXCLUDE_PATTERN"
|
|
||||||
do
|
do
|
||||||
|
# Take the string until first occurence until $PATH_SEPARATOR_CHAR
|
||||||
|
str=${rest%%;*}
|
||||||
|
# Handle the last case
|
||||||
|
if [ "$rest" = "${rest/$PATH_SEPARATOR_CHAR/}" ]
|
||||||
|
then
|
||||||
|
rest=
|
||||||
|
else
|
||||||
|
# Cut everything before the first occurence of $PATH_SEPARATOR_CHAR
|
||||||
|
rest=${rest#*$PATH_SEPARATOR_CHAR}
|
||||||
|
fi
|
||||||
|
|
||||||
if [ "$RSYNC_EXCLUDE" == "" ]
|
if [ "$RSYNC_EXCLUDE" == "" ]
|
||||||
then
|
then
|
||||||
RSYNC_EXCLUDE="--exclude=\"$excludedir\""
|
RSYNC_EXCLUDE="--exclude=\"$str\""
|
||||||
else
|
else
|
||||||
RSYNC_EXCLUDE="$RSYNC_EXCLUDE --exclude=\"$excludedir\""
|
RSYNC_EXCLUDE="$RSYNC_EXCLUDE --exclude=\"$str\""
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
IFS=$OLD_IFS
|
|
||||||
set +f
|
set +f
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue