aboutsummaryrefslogtreecommitdiff
path: root/lib/main.bash
diff options
context:
space:
mode:
Diffstat (limited to 'lib/main.bash')
-rw-r--r--lib/main.bash37
1 files changed, 32 insertions, 5 deletions
diff --git a/lib/main.bash b/lib/main.bash
index bbfd602..821c2d2 100644
--- a/lib/main.bash
+++ b/lib/main.bash
@@ -1,6 +1,6 @@
#!/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
@@ -34,6 +34,7 @@ main() {
# Declare some global variables
declare -A BASHTARD_PLATFORM
+ declare -A BASHTARD_PLAYBOOK_VARS
# Figure out system details
debug "$BASHTARD_NAME/main" "Discovering system information"
@@ -41,6 +42,7 @@ main() {
# Export BASHTARD_ variables
export BASHTARD_PLATFORM
+ export BASHTARD_PLAYBOOK_VARS
# Source the file defining the subcommand.
debug "$BASHTARD_NAME/main" "Sourcing $subcommand_src"
@@ -77,30 +79,44 @@ Usage:
$BASHTARD_NAME -h
$BASHTARD_NAME add <playbook>
$BASHTARD_NAME del <playbook>
+ $BASHTARD_NAME diff
$BASHTARD_NAME init [repository]
$BASHTARD_NAME pkg <install|uninstall> <name>
+ $BASHTARD_NAME pull
$BASHTARD_NAME ssh <command>
$BASHTARD_NAME sync [playbook]
$BASHTARD_NAME sysinfo
+ $BASHTARD_NAME top
$BASHTARD_NAME var [-p <playbook>] <key>
$BASHTARD_NAME var [-s] <key> <value>
+ $BASHTARD_NAME zap <playbook>
Perform maintenance on your infra.
Commands:
add Add a configuration playbook to this machine.
+ del Remove a configuration playbook from this machine.
+ diff Show a diff of all uncommitted changes.
init Initialize the $BASHTARD_NAME configuration system.
pkg Interface into the pkg abstraction used by $BASHTARD_NAME.
- del Remove a configuration playbook from this machine.
+ pull Pull the latest changes through git.
ssh Run a given command on all known hosts.
sync Pull latest changes through git, and synchronize all added
playbooks.
sysinfo Show gathered information about this system.
+ top Show resource information about all known hosts.
var Show or set the value of a given configuration key.
-
-Playbooks:
+ zap Remove a playbook from the registry without attempting to run
+ the delete step from the playbook.
EOF
+ if [[ ! -d "$BASHTARD_ETCDIR/playbooks.d" ]]
+ then
+ return 0
+ fi
+
+ printf "\nPlaybooks:\n"
+
# Find all playbooks
mapfile -t playbooks < <(find \
"$BASHTARD_ETCDIR/playbooks.d"/* \
@@ -122,9 +138,19 @@ EOF
# Render playbook descriptions
for playbook in "${playbooks[@]}"
do
+ local description=""
+
+ if [[ -f "$playbook/description.txt" ]]
+ then
+ description="$(cat "$playbook/description.txt")"
+ elif [[ -f "$playbook/description" ]]
+ then
+ description="$(cat "$playbook/description")"
+ fi
+
printf "\t%-${playbook_longest}s %s\n" \
"$(basename "$playbook")" \
- "$(cat "$playbook/description.txt")"
+ "$description"
done
}
@@ -210,6 +236,7 @@ discover_system_init() {
discover_system_key() {
local key
+ # shellcheck disable=SC2031
key+="${BASHTARD_PLATFORM[os]}"
if [[ ${BASHTARD_PLATFORM[distro]} ]]