From 7b338a517562b07eb59d5d3fd85e803bca4a9686 Mon Sep 17 00:00:00 2001 From: James Barnett Date: Mon, 7 Nov 2016 12:17:03 -0600 Subject: [PATCH] allow configurations to be selected via command line (#3, #4) --- bin/snap-sync | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/bin/snap-sync b/bin/snap-sync index c8b0131..e7218a9 100755 --- a/bin/snap-sync +++ b/bin/snap-sync @@ -16,6 +16,10 @@ while [[ $# -gt 0 ]]; do description="$2" shift ;; + -c|--config) + selected_configs="$2" + shift + ;; -u|--UUID) uuid_cmdline="$2" shift @@ -89,7 +93,6 @@ fi selected_uuid="${UUIDS_ARRAY[$((disk-1))]}" selected_mnt="${TARGETS_ARRAY[$((disk-1))]}" printf "You selected the disk with UUID %s.\n" "$selected_uuid" -exit 0 if [[ -f /etc/conf.d/snapper ]]; then source /etc/conf.d/snapper @@ -98,9 +101,17 @@ else exit 1 fi -for x in $SNAPPER_CONFIGS; do +selected_configs=${selected_configs:-$SNAPPER_CONFIGS} +echo $selected_configs - source /etc/snapper/configs/$x +for x in $selected_configs; do + + if [[ -d "/etc/snapper/configs/$x" ]]; then + source /etc/snapper/configs/$x + else + printf "Error: Selected snapper configuration $x does not exist." + exit 1 + fi printf "At '%s' configuration\n" "$x"