ssh protocol added

This commit is contained in:
Ste Vaidis 2023-01-10 00:17:52 +02:00
parent 537a4baa2f
commit 9c94ebca1f

View File

@ -49,15 +49,10 @@ function mount_smb() {
function mount_ssh() {
if mkdir /mnt/${PID}; 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}:${SOURCE} /mnt/${PID}; then
if sshfs -o ro ${USER}@${HOST}:${SHARE} /mnt/${PID}; then
return 0
else
log "[FAIL] mount ${USER}@${HOST}:${SOURCE} to /mnt/${SRC}"
return 1
fi
else
log "[FAIL] remote dir ${DIR} not found"
log "[FAIL] mount ${USER}@${HOST}:${SHARE} to /mnt/${SRC}"
return 1
fi
else
@ -226,10 +221,14 @@ function statistics_usb() {
log "USB DISK Free : ${USBFREE}"
}
function mount_only() {
if find_luks; then
function debug_mount() {
if get_luks_password; then
mount_usb
if find_luks; then
if mount_luks $LUKS_PASS $USB_DEV; then
if mount_usb; then
ls -l /mnt/usb
fi
fi
fi
fi
exit
@ -304,10 +303,10 @@ do
usage
;;
--mount)
mount_only
debug_mount
;;
--umount)
umount_x
umount_usb && luks_close
;;
--format=*)
FORMAT="${i#*=}"
@ -342,12 +341,12 @@ if [[ -n "$CONFIG" ]]; then
[ -z "$PROTO" ] && usage "config \e[92m'PROTO'\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 "$DESTINATION" ] && usage "config \e[92m'DESTINATION'\e[39m is missing"
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
main
fi