From 13237120eb9e35f5cddfe6c8cc5e1425eb55b374 Mon Sep 17 00:00:00 2001 From: Elias Fierke Date: Thu, 5 Feb 2026 16:32:58 +0100 Subject: [PATCH] implemented basic structure and check() --- src/sub/transfer.sh | 88 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 87 insertions(+), 1 deletion(-) diff --git a/src/sub/transfer.sh b/src/sub/transfer.sh index 7c904d9..4e3e9b0 100644 --- a/src/sub/transfer.sh +++ b/src/sub/transfer.sh @@ -1,3 +1,89 @@ #!/bin/bash -echo "unimplemented" \ No newline at end of file +check(){ + if command -v rsync &>/dev/null + then + echo "rsync is installed. Check passed. Bye." + exit 0; + else + echo "Please install rsync." + while [[ -z "$HAD_BEST_SUCCESS" ]]; do + read -p "Install now? [y/N] " QUESTION + if [[ -z "$QUESTION" ]] || [[ "$QUESTION" = "n" ]] || [[ "$QUESTION" = "N" ]]; then + echo "Alright, bye." + exit 0; + fi + if [[ "$QUESTION" = "y" ]] || [[ "$QUESTION" = "Y" ]]; then + HAD_BEST_SUCCESS="true" + echo "Trying to install rsync..." + if command -v apt &>/dev/null + then + sudo apt update + sudo apt install rsync -y + echo "Attempted to install rsync. Please execute the check again. Bye." + exit 0; + fi + + if command -v dnf &>/dev/null + then + sudo dnf update + sudo dnf install rsync -y + echo "Attempted to install rsync. Please execute the check again. Bye." + exit 0; + fi + + if command -v pacman &>/dev/null + then + sudo pacman -S rsync + echo "Attempted to install rsync. Please execute the check again. Bye." + exit 0; + fi + fi + done + + + + fi +} + +backup(){ + exit 0; +} + +transfer(){ + exit 0; +} + + +show_help(){ + echo "-- HELP --" + echo " -y | Answer all questions with yes" + echo " -s SOURCE | Source path (e.g. /srv/fileshare/main/)" + echo " -d DESTINATION | Destination path (e.g. using ssh)" + echo " -b | Transfer as backup" + echo " -e | encrypt destination using a key" + echo " -h | Show this help text" + echo " -v | Get Version Info" + echo " -c | Check the usability of this tool" + exit 0 +} + +while getopts ":s:d:Bvhyc" opt; do + case $opt in + s) SOURCE="$OPTARG";; + d) DESTINATION="$OPTARG";; + v) exit 0 ;; + c) check ;; + e) ENCRYPT="1" ;; + b) backup ;; + h) show_help ;; + y) ALWAYS_YES="1" ;; + \?) echo "Unknown option: -$OPTARG" >&2; exit 1 ;; + :) echo "Option -$OPTARG needs an argument" >&2; exit 1 ;; + esac +done + +transfer + +echo "Nothing to do." +exit 0 \ No newline at end of file