From dd96f22888001c7171e2d638f69ab58495707f07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pascal=20J=C3=A4ger?= Date: Wed, 5 Apr 2023 17:26:58 +0200 Subject: [PATCH] grub-btrfsd: Check if all dirs exist MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Pascal Jäger --- config | 2 +- grub-btrfsd | 19 +++++++++++-------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/config b/config index bdeacfe..6fe57ec 100644 --- a/config +++ b/config @@ -1,7 +1,7 @@ #!/usr/bin/env bash -GRUB_BTRFS_VERSION=4.12-master-2023-04-05T15:10:49+00:00 +GRUB_BTRFS_VERSION=4.12-master-2023-04-05T15:26:58+00:00 # Disable grub-btrfs. # Default: "false" diff --git a/grub-btrfsd b/grub-btrfsd index dc4ea99..295a679 100755 --- a/grub-btrfsd +++ b/grub-btrfsd @@ -7,7 +7,6 @@ timeshift_pid=-1 watchtime=0 logfile=0 -snapshots=-1 timeshift_auto=false timeshift_old=false verbose=false @@ -174,7 +173,7 @@ while getopts :l:ctvrsh-: opt; do done shift $(( OPTIND - 1 )) -snapshots="${1}" +snapdirs=( "${@}" ) # check if inotify exists, see issue #227 if ! command -v inotifywait >/dev/null 2>&1; then @@ -207,16 +206,21 @@ if [ ${timeshift_auto} = false ] && [ ${timeshift_old} = true ]; then fi vlog "Arguments:" -vlog "Snapshot directories: $snapshots" +vlog "Snapshot directories: ${snapdirs[*]}" vlog "Timestift autodetection: $timeshift_auto" vlog "Timeshift old: $timeshift_old" vlog "Logfile: $logfile" vlog "Recursive: $recursive" -if ! [ -d "$snapshots" ] && ! [ ${timeshift_auto} = true ]; then - err "[!] No directory found at ${snapshots}" "${RED}" >&2 - err "[!] Please specify a valid snapshot directory" "${RED}" >&2 - exit 1 +if ! [ ${timeshift_auto} = true ]; then + for snapdir in "${snapdirs[@]}" + do + if ! [ -d ${snapdir} ]; then + err "[!] No directory found at ${snapdir}" "${RED}" >&2 + err "[!] Please specify a valid snapshot directory" "${RED}" >&2 + exit 1 + fi + done fi if [ ${timeshift_auto} = true ]; then @@ -314,7 +318,6 @@ if [ ${timeshift_auto} = true ] ; then daemon_function & else # for all dirs that got passed to the script, start a new fork with that dir - snapdirs=( "${@}" ) for snapdir in "${snapdirs[@]}" do vlog "starting daemon watching $snapdir..."