From 3bba15bac899d35a3440616e6fde815b29e2dab1 Mon Sep 17 00:00:00 2001 From: "flyingscorpio@arch-desktop" Date: Tue, 8 Sep 2020 14:40:55 +0200 Subject: [PATCH] Add root check --- arch-desktop_borg.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/arch-desktop_borg.sh b/arch-desktop_borg.sh index a00d03e..27326a8 100755 --- a/arch-desktop_borg.sh +++ b/arch-desktop_borg.sh @@ -27,15 +27,19 @@ stat_cache_file() { echo "The borg backup was already executed today" && exit 0 fi fi - touch "$cache_file" } if [ "$1" = '-h' ]; then print_help && exit 1 fi +if [ ! "$UID" -eq 0 ]; then + echo "You have to run this as root" && exit 1 +fi + [ "$1" = '-f' ] || stat_cache_file +touch "$cache_file" # Setting this so the repo does not need to be given on the command line: BORG_REPO=ssh://flyingscorpio@2px.info:22/~/"$(hostname)".borg export BORG_REPO