Dateien nach "/" hochladen

This commit is contained in:
2025-12-30 18:38:02 +01:00
parent c45da891d7
commit 8f8f50a036
4 changed files with 254 additions and 0 deletions

50
06_logs.sh Normal file
View File

@@ -0,0 +1,50 @@
#!/usr/bin/env bash
set -Eeuo pipefail
SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
LOG_FILE="$SCRIPT_DIR/raspi-backup.log"
usage() {
echo "Usage:"
echo " ./06_logs.sh # letzte 200 Zeilen"
echo " ./06_logs.sh -f # live folgen (tail -f)"
echo " ./06_logs.sh -n 500 # letzte N Zeilen"
echo " ./06_logs.sh --all # komplettes Log (less, falls vorhanden)"
}
if [[ ! -f "$LOG_FILE" ]]; then
echo "Kein Log gefunden: $LOG_FILE"
exit 0
fi
mode="tail"
lines=200
case "${1:-}" in
"" ) ;;
-f|--follow) mode="follow" ;;
-n|--lines)
[[ -n "${2:-}" ]] || { usage; exit 2; }
lines="$2"
;;
--all) mode="all" ;;
-h|--help) usage; exit 0 ;;
*) usage; exit 2 ;;
esac
case "$mode" in
follow)
echo "Folge Log live: $LOG_FILE"
tail -f "$LOG_FILE"
;;
all)
if command -v less >/dev/null 2>&1; then
less "$LOG_FILE"
else
cat "$LOG_FILE"
fi
;;
tail)
tail -n "$lines" "$LOG_FILE"
;;
esac