From 72c62b83cc2d4689ae042ad63923886ada6215f6 Mon Sep 17 00:00:00 2001 From: Reid Sunderland Date: Wed, 18 Oct 2023 17:19:09 +0000 Subject: [PATCH] Require --dangerWillRobinson for removing >1 config --- bin/sr3_action_remove | 3 +++ bin/sr3d | 5 +++++ completion/sr3_tools_completion.bash | 1 + 3 files changed, 9 insertions(+) diff --git a/bin/sr3_action_remove b/bin/sr3_action_remove index b66ad3c..c0d1503 100755 --- a/bin/sr3_action_remove +++ b/bin/sr3_action_remove @@ -21,6 +21,9 @@ for argu in "$@"; do if [[ "$argu" == "remove" ]] ; then continue fi + if [[ "$argu" == "--dangerWillRobinson" ]] ; then + continue + fi files_to_remove+=("${pump_path}${argu}.conf") done diff --git a/bin/sr3d b/bin/sr3d index 46cf237..ca087e6 100755 --- a/bin/sr3d +++ b/bin/sr3d @@ -13,5 +13,10 @@ sr3r "sr3 $*" # Special cases for certain actions AFTER running on nodes if [[ "$action" == "remove" ]] ; then + # Removing more than one config at a time requires --dangerWillRobinson + if [[ "$*" != *"--dangerWillRobinson"* ]] && [[ $# -gt 2 ]]; then + echo "[ERROR] --dangerWillRobinson is required to remove more than one config." + exit 1 + fi sr3_action_remove "$@" fi diff --git a/completion/sr3_tools_completion.bash b/completion/sr3_tools_completion.bash index 27de48a..d51fee3 100644 --- a/completion/sr3_tools_completion.bash +++ b/completion/sr3_tools_completion.bash @@ -83,6 +83,7 @@ component_config() # sr3d syntax is the same as sr3: # sr3d action [component/config] # except some actions (edit, foreground, etc.) don't make sense on a cluster +# TODO: support --dangerWillRobinson as 1st arg (before action) or 2nd arg (after action) ### _sr3d() {