grub-btrfsd: Check if all dirs exist

Signed-off-by: Pascal Jäger <pascal.jaeger@leimstift.de>
This commit is contained in:
Pascal Jäger
2023-04-05 17:26:58 +02:00
parent 35429e02a4
commit dd96f22888
2 changed files with 12 additions and 9 deletions

2
config
View File

@@ -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"

View File

@@ -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
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..."