ssh protocol added
This commit is contained in:
parent
537a4baa2f
commit
9c94ebca1f
33
backup.sh
33
backup.sh
@ -48,16 +48,11 @@ function mount_smb() {
|
|||||||
|
|
||||||
function mount_ssh() {
|
function mount_ssh() {
|
||||||
if mkdir /mnt/${PID}; then
|
if mkdir /mnt/${PID}; then
|
||||||
if ssh -q -o BatchMode=yes -o ConnectTimeout=10 ${USER}@${HOST} exit; then
|
if ssh -q -o BatchMode=yes -o ConnectTimeout=10 ${USER}@${HOST} exit; then
|
||||||
if ssh ${USER}@${HOST} ls -l ${DIR} 2> /dev/null; then
|
if sshfs -o ro ${USER}@${HOST}:${SHARE} /mnt/${PID}; then
|
||||||
if sshfs -o ro ${USER}@${HOST}:${SOURCE} /mnt/${PID}; then
|
return 0
|
||||||
return 0
|
|
||||||
else
|
|
||||||
log "[FAIL] mount ${USER}@${HOST}:${SOURCE} to /mnt/${SRC}"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
else
|
else
|
||||||
log "[FAIL] remote dir ${DIR} not found"
|
log "[FAIL] mount ${USER}@${HOST}:${SHARE} to /mnt/${SRC}"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
@ -226,10 +221,14 @@ function statistics_usb() {
|
|||||||
log "USB DISK Free : ${USBFREE}"
|
log "USB DISK Free : ${USBFREE}"
|
||||||
}
|
}
|
||||||
|
|
||||||
function mount_only() {
|
function debug_mount() {
|
||||||
if find_luks; then
|
if get_luks_password; then
|
||||||
if get_luks_password; then
|
if find_luks; then
|
||||||
mount_usb
|
if mount_luks $LUKS_PASS $USB_DEV; then
|
||||||
|
if mount_usb; then
|
||||||
|
ls -l /mnt/usb
|
||||||
|
fi
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
exit
|
exit
|
||||||
@ -304,10 +303,10 @@ do
|
|||||||
usage
|
usage
|
||||||
;;
|
;;
|
||||||
--mount)
|
--mount)
|
||||||
mount_only
|
debug_mount
|
||||||
;;
|
;;
|
||||||
--umount)
|
--umount)
|
||||||
umount_x
|
umount_usb && luks_close
|
||||||
;;
|
;;
|
||||||
--format=*)
|
--format=*)
|
||||||
FORMAT="${i#*=}"
|
FORMAT="${i#*=}"
|
||||||
@ -342,12 +341,12 @@ if [[ -n "$CONFIG" ]]; then
|
|||||||
|
|
||||||
[ -z "$PROTO" ] && usage "config \e[92m'PROTO'\e[39m is missing"
|
[ -z "$PROTO" ] && usage "config \e[92m'PROTO'\e[39m is missing"
|
||||||
[ -z "$SHARE" ] && usage "config \e[92m'SHARE'\e[39m is missing"
|
[ -z "$SHARE" ] && usage "config \e[92m'SHARE'\e[39m is missing"
|
||||||
[ -z "$USER" ] && usage "config \e[92m'USER'\e[39m is missing"
|
|
||||||
[ -z "$PASS" ] && usage "config \e[92m'PASS'\e[39m is missing"
|
|
||||||
[ -z "$SOURCE" ] && usage "config \e[92m'SOURCE'\e[39m is missing"
|
[ -z "$SOURCE" ] && usage "config \e[92m'SOURCE'\e[39m is missing"
|
||||||
[ -z "$DESTINATION" ] && usage "config \e[92m'DESTINATION'\e[39m is missing"
|
[ -z "$DESTINATION" ] && usage "config \e[92m'DESTINATION'\e[39m is missing"
|
||||||
|
|
||||||
if [ "$PROTO" = "smb" ]; then
|
if [ "$PROTO" = "smb" ]; then
|
||||||
|
[ -z "$USER" ] && usage "config \e[92m'USER'\e[39m is missing"
|
||||||
|
[ -z "$PASS" ] && usage "config \e[92m'PASS'\e[39m is missing"
|
||||||
if mount_smb; then
|
if mount_smb; then
|
||||||
main
|
main
|
||||||
fi
|
fi
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user