Vorläufige Aufteilung auf einzelne Scripts

This commit is contained in:
Hartmut Bauer committed 2025-03-21 00:38:55 +01:00
1 parent 0c78fbaa4f
commit 1fcdb5669a
7 files changed
+541

No files matched your search

Executable
+96
View File
@@ -0,0 +1,96 @@
#!/bin/bash
#
# entrypoint for all actions
#
HERE=$(dirname "$0")
. $HERE/main.inc.sh
show_help() {
echo "usage: $0 options"
echo " -a, --auto start nightly backup on local machine"
echo " --list list archives"
echo ' --content <archive> '
echo " show contents of archive"
echo ' -r, --restore <archive> <file(s)> '
echo " restore files from archive to pwd"
echo " -h, -?. --help show this help"
}
echo " ### main.sh"
# Initialize all the option variables.
# This ensures we are not contaminated by variables from the environment.
file=
archive=
while :; do
case $1 in
-h|-\?|--help)
show_help # Display a usage synopsis.
exit 0
;;
-a|--auto)
shift
. $HERE/$HOST_NAME.sh "$@" # >$LOGF 2>&1
break # exit kehrt nicht zu run.sh zurück
;;
--list)
. $HERE/$HOST_NAME.sh -l
break;
;;
--content)
if [ "$2" ]; then
. $HERE/$HOST_NAME.sh -c $2
else
echo 'ERROR: "--content" requires a non-empty option argument.'
fi
break
;;
-r|--restore)
if [ "$2" ]; then
echo "not yet implemented"
archive=$2
shift
#. $HERE/$HOST_NAME.sh -r $archive $@
else
echo 'ERROR: "--restore" requires a non-empty option argument.'
fi
break
;;
# --- example -> https://mywiki.wooledge.org/BashFAQ/035
-f|--file) # Takes an option argument; ensure it has been specified.
if [ "$2" ]; then
file=$2
shift
else
die 'ERROR: "--file" requires a non-empty option argument.'
fi
;;
--file=?*)
file=${1#*=} # Delete everything up to "=" and assign the remainder.
;;
--file=) # Handle the case of an empty --file=
die 'ERROR: "--file" requires a non-empty option argument.'
;;
--) # End of all options.
shift
break
;;
-?*)
echo "WARN: Unknown option (ignored): $1"
echo
show_help
exit
;;
*) # Default case: No more options, so break out of the loop.
break
esac
shift
done