diff --git a/dev/debug_osync.sh b/dev/debug_osync.sh index ec74bac..0c7d6cd 100755 --- a/dev/debug_osync.sh +++ b/dev/debug_osync.sh @@ -9,7 +9,7 @@ PROGRAM="osync" # Rsync based two way sync engine with fault tolerance AUTHOR="(C) 2013-2018 by Orsiris de Jong" CONTACT="http://www.netpower.fr/osync - ozy@netpower.fr" PROGRAM_VERSION=1.3.0-beta1 -PROGRAM_BUILD=2018100201 +PROGRAM_BUILD=2018100202 IS_STABLE=no ##### Execution order #__WITH_PARANOIA_DEBUG @@ -43,7 +43,7 @@ IS_STABLE=no # CleanUp no #__WITH_PARANOIA_DEBUG _OFUNCTIONS_VERSION=2.3.0-RC2 -_OFUNCTIONS_BUILD=2018100204 +_OFUNCTIONS_BUILD=2018100205 _OFUNCTIONS_BOOTSTRAP=true if ! type "$BASH" > /dev/null; then @@ -349,6 +349,26 @@ function Logger { fi } +# Function is busybox compatible since busybox ash does not understand direct regex, we use expr +function IsInteger { + local value="${1}" + + if type expr > /dev/null 2>&1; then + expr "$value" : "^[0-9]\+$" > /dev/null 2>&1 + if [ $? -eq 0 ]; then + echo 1 + else + echo 0 + fi + else + if [[ $value =~ ^[0-9]+$ ]]; then + echo 1 + else + echo 0 + fi + fi +} + # Portable child (and grandchild) kill function tester under Linux, BSD and MacOS X function KillChilds { local pid="${1}" # Parent pid to kill childs @@ -1312,31 +1332,6 @@ function IsNumericExpand { eval "local value=\"${1}\"" # Needed eval so variable variables can be processed echo $(IsNumeric "$value") - # if [[ $value =~ ^-?[0-9]+([.][0-9]+)?$ ]]; then - # echo 1 - #else - # echo 0 - #fi -} - -# Function is busybox compatible since busybox ash does not understand direct regex, we use expr -function IsInteger { - local value="${1}" - - if type expr > /dev/null 2>&1; then - expr "$value" : "^[0-9]\+$" > /dev/null 2>&1 - if [ $? -eq 0 ]; then - echo 1 - else - echo 0 - fi - else - if [[ $value =~ ^[0-9]+$ ]]; then - echo 1 - else - echo 0 - fi - fi } # Converts human readable sizes into integer kilobyte sizes @@ -3612,7 +3607,7 @@ function conflictList { retval=$? #WIP - if [ $TRAVIS_RUN == true ]; then + if [ "$TRAVIS_RUN" == true ]; then echo "conflictList debug retval=$retval" cat "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.${INITIATOR[$__type]}.$SCRIPT_PID.$TSTAMP" cat "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.${TARGET[$__type]}.$SCRIPT_PID.$TSTAMP" @@ -5209,7 +5204,7 @@ function LogConflicts { local body #WIP - if [ $TRAVIS_RUN == true ]; then + if [ "$TRAVIS_RUN" == true ]; then cat "$RUN_DIR/$PROGRAM.conflictList.compare.$SCRIPT_PID.$TSTAMP" fi diff --git a/install.sh b/install.sh index fc66ccb..43e334e 100755 --- a/install.sh +++ b/install.sh @@ -10,7 +10,7 @@ PROGRAM_BINARY=$PROGRAM".sh" PROGRAM_BATCH=$PROGRAM"-batch.sh" SSH_FILTER="ssh_filter.sh" -SCRIPT_BUILD=2018100201 +SCRIPT_BUILD=2018100206 INSTANCE_ID="installer-$SCRIPT_BUILD" ## osync / obackup / pmocr / zsnap install script @@ -18,7 +18,7 @@ INSTANCE_ID="installer-$SCRIPT_BUILD" ## Please adapt this to fit your distro needs _OFUNCTIONS_VERSION=2.3.0-RC2 -_OFUNCTIONS_BUILD=2018100204 +_OFUNCTIONS_BUILD=2018100205 _OFUNCTIONS_BOOTSTRAP=true if ! type "$BASH" > /dev/null; then @@ -310,6 +310,26 @@ function Logger { fi } +# Function is busybox compatible since busybox ash does not understand direct regex, we use expr +function IsInteger { + local value="${1}" + + if type expr > /dev/null 2>&1; then + expr "$value" : "^[0-9]\+$" > /dev/null 2>&1 + if [ $? -eq 0 ]; then + echo 1 + else + echo 0 + fi + else + if [[ $value =~ ^[0-9]+$ ]]; then + echo 1 + else + echo 0 + fi + fi +} + # Portable child (and grandchild) kill function tester under Linux, BSD and MacOS X function KillChilds { local pid="${1}" # Parent pid to kill childs @@ -662,9 +682,17 @@ function GetInit { function CreateDir { local dir="${1}" + local dirMask="${2}" + local dirUser="${3}" + local dirGroup="${4}" if [ ! -d "$dir" ]; then + ( + if [ $(IsInteger $dirMask) -eq 1 ]; then + umask $dirMask + fi mkdir -p "$dir" + ) if [ $? == 0 ]; then Logger "Created directory [$dir]." "SIMPLE" else @@ -672,6 +700,20 @@ function CreateDir { exit 1 fi fi + + if [ "$dirUser" != "" ]; then + userGroup="$dirUser" + if [ "$dirGroup" != "" ]; then + userGroup="$userGroup"":$dirGroup" + fi + chown "$userGroup" "$dir" + if [ $? != 0 ]; then + Logger "Could not set directory ownership on [$dir] to [$userGroup]." "SIMPLE" + exit 1 + else + Logger "Set file ownership on [$dir] to [$userGroup]." "SIMPLE" + fi + fi } function CopyFile { @@ -703,7 +745,7 @@ function CopyFile { exit 1 else Logger "Copied [$sourcePath/$sourceFileName] to [$destPath/$destFileName]." "SIMPLE" - if [ "$fileMod" != "" ]; then + if [ "$(IsInteger $fileMod)" -eq 1 ]; then chmod "$fileMod" "$destPath/$destFileName" if [ $? != 0 ]; then Logger "Cannot set file permissions of [$destPath/$destFileName] to [$fileMod]." "SIMPLE" @@ -711,6 +753,8 @@ function CopyFile { else Logger "Set file permissions to [$fileMod] on [$destPath/$destFileName]." "SIMPLE" fi + elif [ "$fileMod" != "" ]; then + Logger "Bogus filemod [$fileMod] for [$destPath] given." "SIMPLE" fi if [ "$fileUser" != "" ]; then @@ -889,6 +933,8 @@ else Logger "Script begin, logging to [$LOG_FILE]." "DEBUG" fi +# Set default umask +umask 0022 GetLocalOS SetLocalOSSettings @@ -907,7 +953,7 @@ else if [ "$PROGRAM" == "osync" ] || [ "$PROGRAM" == "pmocr" ]; then CopyServiceFiles fi - Logger "$PROGRAM installed. Use with $BIN_DIR/$PROGRAM" "SIMPLE" + Logger "$PROGRAM installed. Use with $BIN_DIR/$PROGRAM_BINARY" "SIMPLE" if [ "$PROGRAM" == "osync" ] || [ "$PROGRAM" == "obackup" ]; then echo "" Logger "If connecting remotely, consider setup ssh filter to enhance security." "SIMPLE" diff --git a/osync.sh b/osync.sh index d4b7829..0178736 100755 --- a/osync.sh +++ b/osync.sh @@ -9,12 +9,12 @@ PROGRAM="osync" # Rsync based two way sync engine with fault tolerance AUTHOR="(C) 2013-2018 by Orsiris de Jong" CONTACT="http://www.netpower.fr/osync - ozy@netpower.fr" PROGRAM_VERSION=1.3.0-beta1 -PROGRAM_BUILD=2018100201 +PROGRAM_BUILD=2018100202 IS_STABLE=no _OFUNCTIONS_VERSION=2.3.0-RC2 -_OFUNCTIONS_BUILD=2018100204 +_OFUNCTIONS_BUILD=2018100205 _OFUNCTIONS_BOOTSTRAP=true if ! type "$BASH" > /dev/null; then @@ -306,6 +306,26 @@ function Logger { fi } +# Function is busybox compatible since busybox ash does not understand direct regex, we use expr +function IsInteger { + local value="${1}" + + if type expr > /dev/null 2>&1; then + expr "$value" : "^[0-9]\+$" > /dev/null 2>&1 + if [ $? -eq 0 ]; then + echo 1 + else + echo 0 + fi + else + if [[ $value =~ ^[0-9]+$ ]]; then + echo 1 + else + echo 0 + fi + fi +} + # Portable child (and grandchild) kill function tester under Linux, BSD and MacOS X function KillChilds { local pid="${1}" # Parent pid to kill childs @@ -1235,31 +1255,6 @@ function IsNumericExpand { eval "local value=\"${1}\"" # Needed eval so variable variables can be processed echo $(IsNumeric "$value") - # if [[ $value =~ ^-?[0-9]+([.][0-9]+)?$ ]]; then - # echo 1 - #else - # echo 0 - #fi -} - -# Function is busybox compatible since busybox ash does not understand direct regex, we use expr -function IsInteger { - local value="${1}" - - if type expr > /dev/null 2>&1; then - expr "$value" : "^[0-9]\+$" > /dev/null 2>&1 - if [ $? -eq 0 ]; then - echo 1 - else - echo 0 - fi - else - if [[ $value =~ ^[0-9]+$ ]]; then - echo 1 - else - echo 0 - fi - fi } # Converts human readable sizes into integer kilobyte sizes @@ -3426,7 +3421,7 @@ function conflictList { retval=$? #WIP - if [ $TRAVIS_RUN == true ]; then + if [ "$TRAVIS_RUN" == true ]; then echo "conflictList debug retval=$retval" cat "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.${INITIATOR[$__type]}.$SCRIPT_PID.$TSTAMP" cat "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.${TARGET[$__type]}.$SCRIPT_PID.$TSTAMP" @@ -4988,7 +4983,7 @@ function LogConflicts { local body #WIP - if [ $TRAVIS_RUN == true ]; then + if [ "$TRAVIS_RUN" == true ]; then cat "$RUN_DIR/$PROGRAM.conflictList.compare.$SCRIPT_PID.$TSTAMP" fi