mirror of
https://github.com/deajan/obackup.git
synced 2024-12-25 15:03:41 +01:00
Updated ofunctions
This commit is contained in:
parent
64c32bca07
commit
fbd5317010
@ -2,8 +2,8 @@
|
|||||||
#### OFUNCTIONS FULL SUBSET ####
|
#### OFUNCTIONS FULL SUBSET ####
|
||||||
#### OFUNCTIONS MINI SUBSET ####
|
#### OFUNCTIONS MINI SUBSET ####
|
||||||
|
|
||||||
_OFUNCTIONS_VERSION=2.1.1
|
_OFUNCTIONS_VERSION=2.1.4-dev
|
||||||
_OFUNCTIONS_BUILD=2017041101
|
_OFUNCTIONS_BUILD=2017052201
|
||||||
#### _OFUNCTIONS_BOOTSTRAP SUBSET ####
|
#### _OFUNCTIONS_BOOTSTRAP SUBSET ####
|
||||||
_OFUNCTIONS_BOOTSTRAP=true
|
_OFUNCTIONS_BOOTSTRAP=true
|
||||||
#### _OFUNCTIONS_BOOTSTRAP SUBSET END ####
|
#### _OFUNCTIONS_BOOTSTRAP SUBSET END ####
|
||||||
@ -637,6 +637,22 @@ function Spinner {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function _PerfProfiler { #__WITH_PARANOIA_DEBUG
|
||||||
|
local perfString #__WITH_PARANOIA_DEBUG
|
||||||
|
#__WITH_PARANOIA_DEBUG
|
||||||
|
perfString=$(ps -p $$ -o args,pid,ppid,%cpu,%mem,time,etime,state,wchan) #__WITH_PARANOIA_DEBUG
|
||||||
|
#__WITH_PARANOIA_DEBUG
|
||||||
|
for i in $(pgrep -P $$); do #__WITH_PARANOIA_DEBUG
|
||||||
|
perfString="$perfString\n"$(ps -p $i -o args,pid,ppid,%cpu,%mem,time,etime,state,wchan | tail -1) #__WITH_PARANOIA_DEBUG
|
||||||
|
done #__WITH_PARANOIA_DEBUG
|
||||||
|
#__WITH_PARANOIA_DEBUG
|
||||||
|
if type iostat > /dev/null 2>&1; then #__WITH_PARANOIA_DEBUG
|
||||||
|
perfString="$perfString\n"$(iostat) #__WITH_PARANOIA_DEBUG
|
||||||
|
fi #__WITH_PARANOIA_DEBUG
|
||||||
|
#__WITH_PARANOIA_DEBUG
|
||||||
|
Logger "PerfProfiler:\n$perfString" "PARANOIA_DEBUG" #__WITH_PARANOIA_DEBUG
|
||||||
|
} #__WITH_PARANOIA_DEBUG
|
||||||
|
|
||||||
|
|
||||||
# Time control function for background processes, suitable for multiple synchronous processes
|
# Time control function for background processes, suitable for multiple synchronous processes
|
||||||
# Fills a global variable called WAIT_FOR_TASK_COMPLETION_$callerName that contains list of failed pids in format pid1:result1;pid2:result2
|
# Fills a global variable called WAIT_FOR_TASK_COMPLETION_$callerName that contains list of failed pids in format pid1:result1;pid2:result2
|
||||||
@ -769,6 +785,11 @@ function WaitForTaskCompletion {
|
|||||||
pidsArray=("${newPidsArray[@]}")
|
pidsArray=("${newPidsArray[@]}")
|
||||||
# Trivial wait time for bash to not eat up all CPU
|
# Trivial wait time for bash to not eat up all CPU
|
||||||
sleep $sleepTime
|
sleep $sleepTime
|
||||||
|
|
||||||
|
if [ "$_PERF_PROFILER" == "yes" ]; then ##__WITH_PARANOIA_DEBUG
|
||||||
|
_PerfProfiler ##__WITH_PARANOIA_DEBUG
|
||||||
|
fi ##__WITH_PARANOIA_DEBUG
|
||||||
|
|
||||||
done
|
done
|
||||||
|
|
||||||
Logger "${FUNCNAME[0]} ended for [$callerName] using [$pidCount] subprocesses with [$errorcount] errors." "PARANOIA_DEBUG" #__WITH_PARANOIA_DEBUG
|
Logger "${FUNCNAME[0]} ended for [$callerName] using [$pidCount] subprocesses with [$errorcount] errors." "PARANOIA_DEBUG" #__WITH_PARANOIA_DEBUG
|
||||||
@ -934,6 +955,10 @@ function ParallelExec {
|
|||||||
|
|
||||||
# Trivial wait time for bash to not eat up all CPU
|
# Trivial wait time for bash to not eat up all CPU
|
||||||
sleep $sleepTime
|
sleep $sleepTime
|
||||||
|
|
||||||
|
if [ "$_PERF_PROFILER" == "yes" ]; then ##__WITH_PARANOIA_DEBUG
|
||||||
|
_PerfProfiler ##__WITH_PARANOIA_DEBUG
|
||||||
|
fi ##__WITH_PARANOIA_DEBUG
|
||||||
done
|
done
|
||||||
|
|
||||||
return $errorCount
|
return $errorCount
|
||||||
@ -1154,9 +1179,6 @@ function GetLocalOS {
|
|||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
if [ "$_OFUNCTIONS_VERSION" != "" ]; then
|
|
||||||
Logger "Local OS: [$localOsVar]." "DEBUG"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Get linux versions
|
# Get linux versions
|
||||||
if [ -f "/etc/os-release" ]; then
|
if [ -f "/etc/os-release" ]; then
|
||||||
@ -1166,6 +1188,10 @@ function GetLocalOS {
|
|||||||
|
|
||||||
# Add a global variable for statistics in installer
|
# Add a global variable for statistics in installer
|
||||||
LOCAL_OS_FULL="$localOsVar ($localOsName $localOsVer)"
|
LOCAL_OS_FULL="$localOsVar ($localOsName $localOsVer)"
|
||||||
|
|
||||||
|
if [ "$_OFUNCTIONS_VERSION" != "" ]; then
|
||||||
|
Logger "Local OS: [$LOCAL_OS_FULL]." "DEBUG"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
#### GetLocalOS SUBSET END ####
|
#### GetLocalOS SUBSET END ####
|
||||||
|
|
||||||
@ -1238,11 +1264,14 @@ function GetRemoteOS {
|
|||||||
|
|
||||||
$SSH_CMD env _REMOTE_TOKEN="$_REMOTE_TOKEN" bash -s << 'ENDSSH' >> "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP" 2>&1
|
$SSH_CMD env _REMOTE_TOKEN="$_REMOTE_TOKEN" bash -s << 'ENDSSH' >> "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP" 2>&1
|
||||||
|
|
||||||
|
|
||||||
function GetOs {
|
function GetOs {
|
||||||
local localOsVar
|
local localOsVar
|
||||||
local localOsName
|
local localOsName
|
||||||
local localOsVer
|
local localOsVer
|
||||||
|
|
||||||
|
local osInfo="/etc/os-release"
|
||||||
|
|
||||||
# There's no good way to tell if currently running in BusyBox shell. Using sluggish way.
|
# There's no good way to tell if currently running in BusyBox shell. Using sluggish way.
|
||||||
if ls --help 2>&1 | grep -i "BusyBox" > /dev/null; then
|
if ls --help 2>&1 | grep -i "BusyBox" > /dev/null; then
|
||||||
localOsVar="BusyBox"
|
localOsVar="BusyBox"
|
||||||
@ -1261,9 +1290,11 @@ function GetOs {
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
# Get linux versions
|
# Get linux versions
|
||||||
if [ -f "/etc/os-release" ]; then
|
if [ -f "$osInfo" ]; then
|
||||||
localOsName=$(GetConfFileValue "/etc/os-release" "NAME")
|
localOsName=$(grep "^NAME=" "$osInfo")
|
||||||
localOsVer=$(GetConfFileValue "/etc/os-release" "VERSION")
|
localOsName="${localOsName##*=}"
|
||||||
|
localOsVer=$(grep "^VERSION=" "$osInfo")
|
||||||
|
localOsVer="${localOsVer##*=}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "$localOsVar ($localOsName $localOsVer)"
|
echo "$localOsVar ($localOsName $localOsVer)"
|
||||||
@ -1611,13 +1642,13 @@ function PostInit {
|
|||||||
|
|
||||||
# Define remote commands
|
# Define remote commands
|
||||||
if [ -f "$SSH_RSA_PRIVATE_KEY" ]; then
|
if [ -f "$SSH_RSA_PRIVATE_KEY" ]; then
|
||||||
SSH_CMD="$(type -p ssh) $SSH_COMP -i $SSH_RSA_PRIVATE_KEY $SSH_OPTS $REMOTE_USER@$REMOTE_HOST -p $REMOTE_PORT"
|
SSH_CMD="$(type -p ssh) $SSH_COMP -q -i $SSH_RSA_PRIVATE_KEY $SSH_OPTS $REMOTE_USER@$REMOTE_HOST -p $REMOTE_PORT"
|
||||||
SCP_CMD="$(type -p scp) $SSH_COMP -i $SSH_RSA_PRIVATE_KEY -P $REMOTE_PORT"
|
SCP_CMD="$(type -p scp) $SSH_COMP -q -i $SSH_RSA_PRIVATE_KEY -P $REMOTE_PORT"
|
||||||
RSYNC_SSH_CMD="$(type -p ssh) $SSH_COMP -i $SSH_RSA_PRIVATE_KEY $SSH_OPTS -p $REMOTE_PORT"
|
RSYNC_SSH_CMD="$(type -p ssh) $SSH_COMP -q -i $SSH_RSA_PRIVATE_KEY $SSH_OPTS -p $REMOTE_PORT"
|
||||||
elif [ -f "$SSH_PASSWORD_FILE" ]; then
|
elif [ -f "$SSH_PASSWORD_FILE" ]; then
|
||||||
SSH_CMD="$(type -p sshpass) -f $SSH_PASSWORD_FILE $(type -p ssh) $SSH_COMP $SSH_OPTS $REMOTE_USER@$REMOTE_HOST -p $REMOTE_PORT"
|
SSH_CMD="$(type -p sshpass) -f $SSH_PASSWORD_FILE $(type -p ssh) $SSH_COMP -q $SSH_OPTS $REMOTE_USER@$REMOTE_HOST -p $REMOTE_PORT"
|
||||||
SCP_CMD="$(type -p sshpass) -f $SSH_PASSWORD_FILE $(type -p scp) $SSH_COMP -P $REMOTE_PORT"
|
SCP_CMD="$(type -p sshpass) -f $SSH_PASSWORD_FILE $(type -p scp) $SSH_COMP -q -P $REMOTE_PORT"
|
||||||
RSYNC_SSH_CMD="$(type -p sshpass) -f $SSH_PASSWORD_FILE $(type -p ssh) $SSH_COMP $SSH_OPTS -p $REMOTE_PORT"
|
RSYNC_SSH_CMD="$(type -p sshpass) -f $SSH_PASSWORD_FILE $(type -p ssh) $SSH_COMP -q $SSH_OPTS -p $REMOTE_PORT"
|
||||||
else
|
else
|
||||||
SSH_PASSWORD=""
|
SSH_PASSWORD=""
|
||||||
SSH_CMD=""
|
SSH_CMD=""
|
||||||
|
Loading…
Reference in New Issue
Block a user