Allow default inclusion / exclusions for quicksync

This commit is contained in:
deajan 2016-09-16 10:11:59 +02:00
parent 8e07fb1d0d
commit 951f6b1996
2 changed files with 25 additions and 13 deletions

View File

@ -4,7 +4,7 @@ PROGRAM="osync" # Rsync based two way sync engine with fault tolerance
AUTHOR="(C) 2013-2016 by Orsiris de Jong" AUTHOR="(C) 2013-2016 by Orsiris de Jong"
CONTACT="http://www.netpower.fr/osync - ozy@netpower.fr" CONTACT="http://www.netpower.fr/osync - ozy@netpower.fr"
PROGRAM_VERSION=1.2-beta PROGRAM_VERSION=1.2-beta
PROGRAM_BUILD=2016091601 PROGRAM_BUILD=2016091602
IS_STABLE=no IS_STABLE=no
# Execution order #__WITH_PARANOIA_DEBUG # Execution order #__WITH_PARANOIA_DEBUG
@ -1750,9 +1750,7 @@ function Init {
fi fi
## Add Rsync include / exclude patterns ## Add Rsync include / exclude patterns
if [ $_QUICK_SYNC -lt 2 ]; then
RsyncPatterns RsyncPatterns
fi
## Conflict options ## Conflict options
if [ "$CONFLICT_BACKUP" != "no" ]; then if [ "$CONFLICT_BACKUP" != "no" ]; then

View File

@ -1,6 +1,6 @@
#### MINIMAL-FUNCTION-SET BEGIN #### #### MINIMAL-FUNCTION-SET BEGIN ####
## FUNC_BUILD=2016090701 ## FUNC_BUILD=2016091601
## BEGIN Generic bash functions written in 2013-2016 by Orsiris de Jong - http://www.netpower.fr - ozy@netpower.fr ## BEGIN Generic bash functions written in 2013-2016 by Orsiris de Jong - http://www.netpower.fr - ozy@netpower.fr
## To use in a program, define the following variables: ## To use in a program, define the following variables:
@ -103,9 +103,9 @@ function _Logger {
local evalue="${3}" # What to log to stderr local evalue="${3}" # What to log to stderr
echo -e "$lvalue" >> "$LOG_FILE" echo -e "$lvalue" >> "$LOG_FILE"
CURRENT_LOG="$CURRENT_LOG"$'\n'"$lvalue" CURRENT_LOG="$CURRENT_LOG"$'\n'"$lvalue" #WIP
if [ $_LOGGER_STDERR == true ]; then if [ $_LOGGER_STDERR == true ] && [ "$evalue" != "" ]; then
cat <<< "$evalue" 1>&2 cat <<< "$evalue" 1>&2
elif [ "$_SILENT" == false ]; then elif [ "$_SILENT" == false ]; then
echo -e "$svalue" echo -e "$svalue"
@ -267,7 +267,7 @@ function SendAlert {
fi fi
# <OSYNC SPECIFIC> # <OSYNC SPECIFIC>
if [ "$_QUICK_SYNC" == "2" ]; then if [ "$_QUICK_SYNC" -eq 2 ]; then
Logger "Current task is a quicksync task. Will not send any alert." "NOTICE" Logger "Current task is a quicksync task. Will not send any alert." "NOTICE"
return 0 return 0
fi fi
@ -823,8 +823,6 @@ function CleanUp {
fi fi
} }
#### MINIMAL-FUNCTION-SET END ####
# obsolete, use StripQuotes # obsolete, use StripQuotes
function SedStripQuotes { function SedStripQuotes {
echo $(echo $1 | sed "s/^\([\"']\)\(.*\)\1\$/\2/g") echo $(echo $1 | sed "s/^\([\"']\)\(.*\)\1\$/\2/g")
@ -950,6 +948,8 @@ function GetLocalOS {
Logger "Local OS: [$local_os_var]." "DEBUG" Logger "Local OS: [$local_os_var]." "DEBUG"
} }
#### MINIMAL-FUNCTION-SET END ####
function GetRemoteOS { function GetRemoteOS {
__CheckArguments 0 $# ${FUNCNAME[0]} "$@" #__WITH_PARANOIA_DEBUG __CheckArguments 0 $# ${FUNCNAME[0]} "$@" #__WITH_PARANOIA_DEBUG
@ -1132,7 +1132,7 @@ function CheckConnectivityRemoteHost {
WaitForTaskCompletion $! 60 180 ${FUNCNAME[0]} true $KEEP_LOGGING WaitForTaskCompletion $! 60 180 ${FUNCNAME[0]} true $KEEP_LOGGING
retval=$? retval=$?
if [ $retval != 0 ]; then if [ $retval != 0 ]; then
Logger "Cannot ping [$REMOTE_HOST]. Return code [$retval]." "ERROR" Logger "Cannot ping [$REMOTE_HOST]. Return code [$retval]." "WARN"
return $retval return $retval
fi fi
fi fi
@ -1162,7 +1162,7 @@ function CheckConnectivity3rdPartyHosts {
done done
if [ $remote_3rd_party_success == false ]; then if [ $remote_3rd_party_success == false ]; then
Logger "No remote 3rd party host responded to ping. No internet ?" "ERROR" Logger "No remote 3rd party host responded to ping. No internet ?" "WARN"
return 1 return 1
else else
return 0 return 0
@ -1284,7 +1284,8 @@ function RsyncPatterns {
if [ "$RSYNC_INCLUDE_FROM" != "" ]; then if [ "$RSYNC_INCLUDE_FROM" != "" ]; then
RsyncPatternsFromAdd "include" "$RSYNC_INCLUDE_FROM" RsyncPatternsFromAdd "include" "$RSYNC_INCLUDE_FROM"
fi fi
elif [ "$RSYNC_PATTERN_FIRST" == "include" ]; then # Use default include first for quicksync runs
elif [ "$RSYNC_PATTERN_FIRST" == "include" ] || [ $_QUICK_SYNC -eq 2 ]; then
if [ "$RSYNC_INCLUDE_PATTERN" != "" ]; then if [ "$RSYNC_INCLUDE_PATTERN" != "" ]; then
RsyncPatternsAdd "include" "$RSYNC_INCLUDE_PATTERN" RsyncPatternsAdd "include" "$RSYNC_INCLUDE_PATTERN"
fi fi
@ -1489,4 +1490,17 @@ function PrintIFS {
printf "IFS is: %q" "$IFS" printf "IFS is: %q" "$IFS"
} }
# Process debugging
# Recursive function to get all parents from a pid
function ParentPid {
local pid="${1}" # Pid to analyse
local parent
parent=$(ps -p $pid -o ppid=)
echo "$pid is a child of $parent"
if [ $parent -gt 0 ]; then
ParentPid $parent
fi
}
## END Generic functions ## END Generic functions