aboutsummaryrefslogtreecommitdiff
path: root/lib/subcommands/del.bash
diff options
context:
space:
mode:
Diffstat (limited to 'lib/subcommands/del.bash')
-rw-r--r--lib/subcommands/del.bash18
1 files changed, 10 insertions, 8 deletions
diff --git a/lib/subcommands/del.bash b/lib/subcommands/del.bash
index f5204d8..293e401 100644
--- a/lib/subcommands/del.bash
+++ b/lib/subcommands/del.bash
@@ -1,12 +1,14 @@
#!/usr/bin/env bash
-# SPDX-FileCopyrightText: 2022 Patrick Spek <p.spek@tyil.nl>
+# SPDX-FileCopyrightText: 2023 Patrick Spek <p.spek@tyil.nl>
#
# SPDX-License-Identifier: AGPL-3.0-or-later
subcommand()
{
local buffer
+ local playbook_base
+ local playbook_registry
export BASHTARD_PLAYBOOK="$1" ; shift
@@ -16,13 +18,13 @@ subcommand()
return
fi
- local playbook_base="$BASHTARD_ETCDIR/playbooks.d/$BASHTARD_PLAYBOOK"
- local playbook_registry="$BASHTARD_ETCDIR/registry.d/${BASHTARD_PLATFORM[fqdn]}"
+ playbook_base="$(playbook_path "base")"
+ playbook_registry="$BASHTARD_ETCDIR/registry.d/${BASHTARD_PLATFORM[fqdn]}"
# Make sure we only run add if the playbook is not in the registry yet
if ! grep -Fqx "$BASHTARD_PLAYBOOK" "$playbook_registry"
then
- crit "bashtard/add" "'$BASHTARD_PLAYBOOK' is not registered for ${BASHTARD_PLATFORM[fqdn]}"
+ crit "bashtard/del" "'$BASHTARD_PLAYBOOK' is not registered for ${BASHTARD_PLATFORM[fqdn]}"
return 3
fi
@@ -30,17 +32,17 @@ subcommand()
if [[ ! -d "$playbook_base" ]]
then
- emerg "bashtard/sync" "No such directory: $playbook_base"
+ emerg "bashtard/del" "No such directory: $playbook_base"
return 1
fi
if [[ ! -f "$playbook_base/playbook.bash" ]]
then
- emerg "bashtard/sync" "No such file: $playbook_base/playbook.bash"
+ emerg "bashtard/del" "No such file: $playbook_base/playbook.bash"
return 1
fi
- # shellcheck disable=SC1090
+ # shellcheck disable=SC1090,SC1091
. "$playbook_base/playbook.bash"
if ! playbook_del
@@ -53,6 +55,6 @@ subcommand()
# Remove the playbook from the registry
cp -- "$playbook_registry" "$buffer"
- grep -Fqvx "$BASHTARD_PLAYBOOK" "$buffer" \
+ grep -Fvx "$BASHTARD_PLAYBOOK" "$buffer" \
| sort > "$playbook_registry"
}