mirror of
https://github.com/deajan/obackup.git
synced 2024-11-14 03:33:41 +01:00
Fixed regression for Mac/BSD
This commit is contained in:
parent
5808e87057
commit
7a7a7c08bc
@ -5,7 +5,7 @@ PROGRAM="obackup"
|
|||||||
AUTHOR="(C) 2013-2016 by Orsiris de Jong"
|
AUTHOR="(C) 2013-2016 by Orsiris de Jong"
|
||||||
CONTACT="http://www.netpower.fr/obackup - ozy@netpower.fr"
|
CONTACT="http://www.netpower.fr/obackup - ozy@netpower.fr"
|
||||||
PROGRAM_VERSION=2.0-RC1
|
PROGRAM_VERSION=2.0-RC1
|
||||||
PROGRAM_BUILD=2016041201
|
PROGRAM_BUILD=2016052601
|
||||||
IS_STABLE=yes
|
IS_STABLE=yes
|
||||||
|
|
||||||
## FUNC_BUILD=2016052502
|
## FUNC_BUILD=2016052502
|
||||||
@ -93,6 +93,7 @@ function Dummy {
|
|||||||
sleep .1
|
sleep .1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Sub function of Logger
|
||||||
function _Logger {
|
function _Logger {
|
||||||
local svalue="${1}" # What to log to stdout
|
local svalue="${1}" # What to log to stdout
|
||||||
local lvalue="${2:-$svalue}" # What to log to logfile, defaults to screen value
|
local lvalue="${2:-$svalue}" # What to log to logfile, defaults to screen value
|
||||||
@ -107,6 +108,7 @@ function _Logger {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# General log function with log levels
|
||||||
function Logger {
|
function Logger {
|
||||||
local value="${1}" # Sentence to log (in double quotes)
|
local value="${1}" # Sentence to log (in double quotes)
|
||||||
local level="${2}" # Log level: PARANOIA_DEBUG, DEBUG, NOTICE, WARN, ERROR, CRITIAL
|
local level="${2}" # Log level: PARANOIA_DEBUG, DEBUG, NOTICE, WARN, ERROR, CRITIAL
|
||||||
@ -150,6 +152,29 @@ function Logger {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# QuickLogger subfunction, can be called directly
|
||||||
|
function _QuickLogger {
|
||||||
|
local value="${1}"
|
||||||
|
local destination="${2}" # Destination: stdout, log, both
|
||||||
|
|
||||||
|
if ([ "$destination" == "log" ] || [ "$destination" == "both" ]); then
|
||||||
|
echo -e "$(date) - $value" >> "$LOG_FILE"
|
||||||
|
elif ([ "$destination" == "stdout" ] || [ "$destination" == "both" ]); then
|
||||||
|
echo -e "$value"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Generic quick logging function
|
||||||
|
function QuickLogger {
|
||||||
|
local value="${1}"
|
||||||
|
|
||||||
|
if [ "$_SILENT" -eq 1 ]; then
|
||||||
|
_QuickLogger "$value" "log"
|
||||||
|
else
|
||||||
|
_QuickLogger "$value" "stdout"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# Portable child (and grandchild) kill function tester under Linux, BSD and MacOS X
|
# Portable child (and grandchild) kill function tester under Linux, BSD and MacOS X
|
||||||
function KillChilds {
|
function KillChilds {
|
||||||
local pid="${1}"
|
local pid="${1}"
|
||||||
@ -1683,7 +1708,7 @@ function _CreateDirectoryLocal {
|
|||||||
|
|
||||||
if [ ! -d "$dir_to_create" ]; then
|
if [ ! -d "$dir_to_create" ]; then
|
||||||
# No sudo, you should have all necessary rights
|
# No sudo, you should have all necessary rights
|
||||||
mkdir --parents "$dir_to_create" > $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID 2>&1
|
mkdir -p "$dir_to_create" > $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID 2>&1
|
||||||
if [ $? != 0 ]; then
|
if [ $? != 0 ]; then
|
||||||
Logger "Cannot create directory [$dir_to_create]" "CRITICAL"
|
Logger "Cannot create directory [$dir_to_create]" "CRITICAL"
|
||||||
if [ -f $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID ]; then
|
if [ -f $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID ]; then
|
||||||
@ -1702,7 +1727,7 @@ function _CreateDirectoryRemote {
|
|||||||
|
|
||||||
CheckConnectivity3rdPartyHosts
|
CheckConnectivity3rdPartyHosts
|
||||||
CheckConnectivityRemoteHost
|
CheckConnectivityRemoteHost
|
||||||
cmd=$SSH_CMD' "if ! [ -d \"'$dir_to_create'\" ]; then '$COMMAND_SUDO' mkdir --parents \"'$dir_to_create'\"; fi" > '$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID' 2>&1'
|
cmd=$SSH_CMD' "if ! [ -d \"'$dir_to_create'\" ]; then '$COMMAND_SUDO' mkdir -p \"'$dir_to_create'\"; fi" > '$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID' 2>&1'
|
||||||
Logger "cmd: $cmd" "DEBUG"
|
Logger "cmd: $cmd" "DEBUG"
|
||||||
eval "$cmd" &
|
eval "$cmd" &
|
||||||
WaitForTaskCompletion $! 720 1800 ${FUNCNAME[0]}
|
WaitForTaskCompletion $! 720 1800 ${FUNCNAME[0]}
|
||||||
|
@ -5,7 +5,7 @@ PROGRAM="obackup"
|
|||||||
AUTHOR="(C) 2013-2016 by Orsiris de Jong"
|
AUTHOR="(C) 2013-2016 by Orsiris de Jong"
|
||||||
CONTACT="http://www.netpower.fr/obackup - ozy@netpower.fr"
|
CONTACT="http://www.netpower.fr/obackup - ozy@netpower.fr"
|
||||||
PROGRAM_VERSION=2.0-RC1
|
PROGRAM_VERSION=2.0-RC1
|
||||||
PROGRAM_BUILD=2016041201
|
PROGRAM_BUILD=2016052601
|
||||||
IS_STABLE=yes
|
IS_STABLE=yes
|
||||||
|
|
||||||
source "./ofunctions.sh"
|
source "./ofunctions.sh"
|
||||||
@ -490,7 +490,7 @@ function _CreateDirectoryLocal {
|
|||||||
|
|
||||||
if [ ! -d "$dir_to_create" ]; then
|
if [ ! -d "$dir_to_create" ]; then
|
||||||
# No sudo, you should have all necessary rights
|
# No sudo, you should have all necessary rights
|
||||||
mkdir --parents "$dir_to_create" > $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID 2>&1
|
mkdir -p "$dir_to_create" > $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID 2>&1
|
||||||
if [ $? != 0 ]; then
|
if [ $? != 0 ]; then
|
||||||
Logger "Cannot create directory [$dir_to_create]" "CRITICAL"
|
Logger "Cannot create directory [$dir_to_create]" "CRITICAL"
|
||||||
if [ -f $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID ]; then
|
if [ -f $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID ]; then
|
||||||
@ -509,7 +509,7 @@ function _CreateDirectoryRemote {
|
|||||||
|
|
||||||
CheckConnectivity3rdPartyHosts
|
CheckConnectivity3rdPartyHosts
|
||||||
CheckConnectivityRemoteHost
|
CheckConnectivityRemoteHost
|
||||||
cmd=$SSH_CMD' "if ! [ -d \"'$dir_to_create'\" ]; then '$COMMAND_SUDO' mkdir --parents \"'$dir_to_create'\"; fi" > '$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID' 2>&1'
|
cmd=$SSH_CMD' "if ! [ -d \"'$dir_to_create'\" ]; then '$COMMAND_SUDO' mkdir -p \"'$dir_to_create'\"; fi" > '$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID' 2>&1'
|
||||||
Logger "cmd: $cmd" "DEBUG"
|
Logger "cmd: $cmd" "DEBUG"
|
||||||
eval "$cmd" &
|
eval "$cmd" &
|
||||||
WaitForTaskCompletion $! 720 1800 ${FUNCNAME[0]}
|
WaitForTaskCompletion $! 720 1800 ${FUNCNAME[0]}
|
||||||
|
31
obackup.sh
31
obackup.sh
@ -5,7 +5,7 @@ PROGRAM="obackup"
|
|||||||
AUTHOR="(C) 2013-2016 by Orsiris de Jong"
|
AUTHOR="(C) 2013-2016 by Orsiris de Jong"
|
||||||
CONTACT="http://www.netpower.fr/obackup - ozy@netpower.fr"
|
CONTACT="http://www.netpower.fr/obackup - ozy@netpower.fr"
|
||||||
PROGRAM_VERSION=2.0-RC1
|
PROGRAM_VERSION=2.0-RC1
|
||||||
PROGRAM_BUILD=2016041201
|
PROGRAM_BUILD=2016052601
|
||||||
IS_STABLE=yes
|
IS_STABLE=yes
|
||||||
|
|
||||||
## FUNC_BUILD=2016052502
|
## FUNC_BUILD=2016052502
|
||||||
@ -88,6 +88,7 @@ function Dummy {
|
|||||||
sleep .1
|
sleep .1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Sub function of Logger
|
||||||
function _Logger {
|
function _Logger {
|
||||||
local svalue="${1}" # What to log to stdout
|
local svalue="${1}" # What to log to stdout
|
||||||
local lvalue="${2:-$svalue}" # What to log to logfile, defaults to screen value
|
local lvalue="${2:-$svalue}" # What to log to logfile, defaults to screen value
|
||||||
@ -102,6 +103,7 @@ function _Logger {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# General log function with log levels
|
||||||
function Logger {
|
function Logger {
|
||||||
local value="${1}" # Sentence to log (in double quotes)
|
local value="${1}" # Sentence to log (in double quotes)
|
||||||
local level="${2}" # Log level: PARANOIA_DEBUG, DEBUG, NOTICE, WARN, ERROR, CRITIAL
|
local level="${2}" # Log level: PARANOIA_DEBUG, DEBUG, NOTICE, WARN, ERROR, CRITIAL
|
||||||
@ -140,6 +142,29 @@ function Logger {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# QuickLogger subfunction, can be called directly
|
||||||
|
function _QuickLogger {
|
||||||
|
local value="${1}"
|
||||||
|
local destination="${2}" # Destination: stdout, log, both
|
||||||
|
|
||||||
|
if ([ "$destination" == "log" ] || [ "$destination" == "both" ]); then
|
||||||
|
echo -e "$(date) - $value" >> "$LOG_FILE"
|
||||||
|
elif ([ "$destination" == "stdout" ] || [ "$destination" == "both" ]); then
|
||||||
|
echo -e "$value"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Generic quick logging function
|
||||||
|
function QuickLogger {
|
||||||
|
local value="${1}"
|
||||||
|
|
||||||
|
if [ "$_SILENT" -eq 1 ]; then
|
||||||
|
_QuickLogger "$value" "log"
|
||||||
|
else
|
||||||
|
_QuickLogger "$value" "stdout"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# Portable child (and grandchild) kill function tester under Linux, BSD and MacOS X
|
# Portable child (and grandchild) kill function tester under Linux, BSD and MacOS X
|
||||||
function KillChilds {
|
function KillChilds {
|
||||||
local pid="${1}"
|
local pid="${1}"
|
||||||
@ -1596,7 +1621,7 @@ function _CreateDirectoryLocal {
|
|||||||
|
|
||||||
if [ ! -d "$dir_to_create" ]; then
|
if [ ! -d "$dir_to_create" ]; then
|
||||||
# No sudo, you should have all necessary rights
|
# No sudo, you should have all necessary rights
|
||||||
mkdir --parents "$dir_to_create" > $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID 2>&1
|
mkdir -p "$dir_to_create" > $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID 2>&1
|
||||||
if [ $? != 0 ]; then
|
if [ $? != 0 ]; then
|
||||||
Logger "Cannot create directory [$dir_to_create]" "CRITICAL"
|
Logger "Cannot create directory [$dir_to_create]" "CRITICAL"
|
||||||
if [ -f $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID ]; then
|
if [ -f $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID ]; then
|
||||||
@ -1614,7 +1639,7 @@ function _CreateDirectoryRemote {
|
|||||||
|
|
||||||
CheckConnectivity3rdPartyHosts
|
CheckConnectivity3rdPartyHosts
|
||||||
CheckConnectivityRemoteHost
|
CheckConnectivityRemoteHost
|
||||||
cmd=$SSH_CMD' "if ! [ -d \"'$dir_to_create'\" ]; then '$COMMAND_SUDO' mkdir --parents \"'$dir_to_create'\"; fi" > '$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID' 2>&1'
|
cmd=$SSH_CMD' "if ! [ -d \"'$dir_to_create'\" ]; then '$COMMAND_SUDO' mkdir -p \"'$dir_to_create'\"; fi" > '$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID' 2>&1'
|
||||||
Logger "cmd: $cmd" "DEBUG"
|
Logger "cmd: $cmd" "DEBUG"
|
||||||
eval "$cmd" &
|
eval "$cmd" &
|
||||||
WaitForTaskCompletion $! 720 1800 ${FUNCNAME[0]}
|
WaitForTaskCompletion $! 720 1800 ${FUNCNAME[0]}
|
||||||
|
Loading…
Reference in New Issue
Block a user