mirror of
https://github.com/deajan/obackup.git
synced 2024-12-26 07:23:41 +01:00
Implemented SSH_PASSWORD_FILE option
This commit is contained in:
parent
545a7e05f5
commit
e4e1273e5a
@ -9,7 +9,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.1-dev
|
PROGRAM_VERSION=2.1-dev
|
||||||
PROGRAM_BUILD=2016102301
|
PROGRAM_BUILD=2016102303
|
||||||
IS_STABLE=no
|
IS_STABLE=no
|
||||||
|
|
||||||
source "./ofunctions.sh"
|
source "./ofunctions.sh"
|
||||||
@ -94,6 +94,11 @@ function CheckEnvironment {
|
|||||||
CAN_BACKUP_SQL=false
|
CAN_BACKUP_SQL=false
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ "$SSH_PASSWORD_FILE" != "" ] && ! type sshpass > /dev/null 2>&1 ; then
|
||||||
|
Logger "sshpass not present. Cannot use password authentication." "CRITICAL"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$FILE_BACKUP" != "no" ]; then
|
if [ "$FILE_BACKUP" != "no" ]; then
|
||||||
@ -189,7 +194,10 @@ function CheckCurrentConfig {
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ "$REMOTE_OPERATION" == "yes" ] && ([ ! -f "$SSH_RSA_PRIVATE_KEY" ] && [ ! -f "$SSH_PASSWORD_FILE" ]); then
|
||||||
|
Logger "Cannot find rsa private key [$SSH_RSA_PRIVATE_KEY] nor password file [$SSH_PASSWORD_FILE]. No authentication method provided." "CRITICAL"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function CheckRunningInstances {
|
function CheckRunningInstances {
|
||||||
@ -482,7 +490,7 @@ function _GetDirectoriesSizeLocal {
|
|||||||
|
|
||||||
if [ -s "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID" ]; then
|
if [ -s "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID" ]; then
|
||||||
TOTAL_FILES_SIZE="$(cat $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID)"
|
TOTAL_FILES_SIZE="$(cat $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID)"
|
||||||
if [ $(IsNumeric $TOTAL_FILES_SIZE) -eq 0 ]; then
|
if [ $(IsInteger $TOTAL_FILES_SIZE) -eq 0 ]; then
|
||||||
TOTAL_FILES_SIZE="$(HumanToNumeric $TOTAL_FILES_SIZE)"
|
TOTAL_FILES_SIZE="$(HumanToNumeric $TOTAL_FILES_SIZE)"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
@ -515,7 +523,7 @@ function _GetDirectoriesSizeRemote {
|
|||||||
fi
|
fi
|
||||||
if [ -s "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID" ]; then
|
if [ -s "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID" ]; then
|
||||||
TOTAL_FILES_SIZE="$(cat $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID)"
|
TOTAL_FILES_SIZE="$(cat $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID)"
|
||||||
if [ $(IsNumeric $TOTAL_FILES_SIZE) -eq 0 ]; then
|
if [ $(IsInteger $TOTAL_FILES_SIZE) -eq 0 ]; then
|
||||||
TOTAL_FILES_SIZE="$(HumanToNumeric $TOTAL_FILES_SIZE)"
|
TOTAL_FILES_SIZE="$(HumanToNumeric $TOTAL_FILES_SIZE)"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
@ -636,7 +644,7 @@ function GetDiskSpaceLocal {
|
|||||||
else
|
else
|
||||||
DISK_SPACE=$(tail -1 "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID" | awk '{print $4}')
|
DISK_SPACE=$(tail -1 "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID" | awk '{print $4}')
|
||||||
DRIVE=$(tail -1 "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID" | awk '{print $1}')
|
DRIVE=$(tail -1 "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID" | awk '{print $1}')
|
||||||
if [ $(IsNumeric $DISK_SPACE) -eq 0 ]; then
|
if [ $(IsInteger $DISK_SPACE) -eq 0 ]; then
|
||||||
DISK_SPACE="$(HumanToNumeric $DISK_SPACE)"
|
DISK_SPACE="$(HumanToNumeric $DISK_SPACE)"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@ -665,7 +673,7 @@ function GetDiskSpaceRemote {
|
|||||||
else
|
else
|
||||||
DISK_SPACE=$(tail -1 "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID" | awk '{print $4}')
|
DISK_SPACE=$(tail -1 "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID" | awk '{print $4}')
|
||||||
DRIVE=$(tail -1 "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID" | awk '{print $1}')
|
DRIVE=$(tail -1 "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID" | awk '{print $1}')
|
||||||
if [ $(IsNumeric $DISK_SPACE) -eq 0 ]; then
|
if [ $(IsInteger $DISK_SPACE) -eq 0 ]; then
|
||||||
DISK_SPACE="$(HumanToNumeric $DISK_SPACE)"
|
DISK_SPACE="$(HumanToNumeric $DISK_SPACE)"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@ -1469,7 +1477,10 @@ function Init {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$SSH_RSA_PRIVATE_KEY" == "" ]; then
|
if [ "$SSH_RSA_PRIVATE_KEY" == "" ]; then
|
||||||
SSH_RSA_PRIVATE_KEY=~/.ssh/id_rsa
|
if [ ! -f "$SSH_PASSWORD_FILE" ]; then
|
||||||
|
# Assume that there might exist a standard rsa key
|
||||||
|
SSH_RSA_PRIVATE_KEY=~/.ssh/id_rsa
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# remove everything before '@'
|
# remove everything before '@'
|
||||||
@ -1522,6 +1533,7 @@ function Main {
|
|||||||
FILE_STORAGE="${FILE_STORAGE/#\~/$HOME}"
|
FILE_STORAGE="${FILE_STORAGE/#\~/$HOME}"
|
||||||
SQL_STORAGE="${SQL_STORAGE/#\~/$HOME}"
|
SQL_STORAGE="${SQL_STORAGE/#\~/$HOME}"
|
||||||
SSH_RSA_PRIVATE_KEY="${SSH_RSA_PRIVATE_KEY/#\~/$HOME}"
|
SSH_RSA_PRIVATE_KEY="${SSH_RSA_PRIVATE_KEY/#\~/$HOME}"
|
||||||
|
SSH_PASSWORD_FILE="${SSH_PASSWORD_FILE/#\~/$HOME}"
|
||||||
ENCRYPT_PUBKEY="${ENCRYPT_PUBKEY/#\~/$HOME}"
|
ENCRYPT_PUBKEY="${ENCRYPT_PUBKEY/#\~/$HOME}"
|
||||||
|
|
||||||
if [ "$CREATE_DIRS" != "no" ]; then
|
if [ "$CREATE_DIRS" != "no" ]; then
|
||||||
|
@ -37,7 +37,7 @@ SQL_WARN_MIN_SPACE
|
|||||||
FILE_WARN_MIN_SPACE
|
FILE_WARN_MIN_SPACE
|
||||||
REMOTE_SYSTEM_URI
|
REMOTE_SYSTEM_URI
|
||||||
SSH_RSA_PRIVATE_KEY
|
SSH_RSA_PRIVATE_KEY
|
||||||
SSH_PASSWORD
|
SSH_PASSWORD_FILE
|
||||||
SSH_COMPRESSION
|
SSH_COMPRESSION
|
||||||
SSH_IGNORE_KNOWN_HOSTS
|
SSH_IGNORE_KNOWN_HOSTS
|
||||||
RSYNC_REMOTE_PATH
|
RSYNC_REMOTE_PATH
|
||||||
|
Loading…
Reference in New Issue
Block a user