|
|
|
@ -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"
|
|
|
|
|