From 7eac078e1049493d708097af69f6894d609ec6a8 Mon Sep 17 00:00:00 2001 From: Patrick Spek Date: Wed, 11 May 2022 13:30:22 +0200 Subject: Implement pkg subcommand --- CHANGELOG.md | 6 ++++-- lib/main.bash | 2 ++ lib/subcommands/pkg.bash | 16 ++++++++++++++++ share/doc/bashtard.1.scd | 7 +++++++ 4 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 lib/subcommands/pkg.bash diff --git a/CHANGELOG.md b/CHANGELOG.md index dcfa169..b589d75 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,11 +9,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added -- `var` subcommand is now referenced in `usage()`. +- The `var` subcommand is now referenced in `usage()`. +- A `pkg` subcommand has been added, to allow for direct interaction with the + `pkg_*()` utilities provided by Bashtard. ### Changed -- `ssh` subcommand should now only check for `ssh.host`, and show an appropriate +- The `ssh` subcommand should now only check for `ssh.host`, and show an appropriate warning if one is not set for a node. - `svc_enable()` now checks for the `rc.d` file to exist before running `grep` on it. diff --git a/lib/main.bash b/lib/main.bash index 385773f..cf3e069 100644 --- a/lib/main.bash +++ b/lib/main.bash @@ -78,6 +78,7 @@ Usage: $BASHTARD_NAME add $BASHTARD_NAME del $BASHTARD_NAME init [repository] + $BASHTARD_NAME pkg $BASHTARD_NAME ssh $BASHTARD_NAME sync [playbook] $BASHTARD_NAME sysinfo @@ -89,6 +90,7 @@ Perform maintenance on your infra. Commands: add Add a configuration playbook to this machine. 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. ssh Run a given command on all known hosts. sync Pull latest changes through git, and synchronize all added diff --git a/lib/subcommands/pkg.bash b/lib/subcommands/pkg.bash new file mode 100644 index 0000000..ff5e33f --- /dev/null +++ b/lib/subcommands/pkg.bash @@ -0,0 +1,16 @@ +#!/usr/bin/env bash + +# SPDX-FileCopyrightText: 2022 Patrick Spek +# +# SPDX-License-Identifier: AGPL-3.0-or-later + +subcommand() { + local action + + action="$1" ; shift + + for package in "$@" + do + pkg "$action" "$package" + done +} diff --git a/share/doc/bashtard.1.scd b/share/doc/bashtard.1.scd index ca8b248..1035b18 100644 --- a/share/doc/bashtard.1.scd +++ b/share/doc/bashtard.1.scd @@ -10,6 +10,7 @@ bashtard - A Bash-based configuration management utility *bashtard* add <_playbook_>++ *bashtard* del <_playbook_>++ *bashtard* init [_repository_]++ +*bashtard* pkg <_install_|_uninstall_> <_name_>++ *bashtard* ssh <_command_>++ *bashtard* sync [_playbook_]++ *bashtard* var [-p _playbook_] <_key_>++ @@ -46,6 +47,12 @@ If a repository URL has been provided, *bashtard* will attempt to use *git clone* to create the directory structure, and then add host-specific files to it afterwards. +## pkg + +Allows direct interaction with the *pkg_\*()* functions provided by the +*bashtard* utility library. This in turn makes allows a user to use a single +package management interface accross all their machines. + ## ssh Run a given command over SSH to all configured nodes. Every node needs to have -- cgit v1.1