From aeff0194ccb415904b1e37039e86a19f038dc708 Mon Sep 17 00:00:00 2001
From: Patrick Spek
Date: Mon, 25 Apr 2022 13:23:44 +0200
Subject: Rename bootstrap to init
---
README.md | 18 +++++-----
lib/main.bash | 16 ++++-----
lib/subcommands/bootstrap.bash | 81 ------------------------------------------
lib/subcommands/init.bash | 81 ++++++++++++++++++++++++++++++++++++++++++
4 files changed, 98 insertions(+), 98 deletions(-)
delete mode 100644 lib/subcommands/bootstrap.bash
create mode 100644 lib/subcommands/init.bash
diff --git a/README.md b/README.md
index b45ad69..e6dee4a 100644
--- a/README.md
+++ b/README.md
@@ -14,26 +14,26 @@ provided `Makefile`.
make install
-### Bootstrapping
+### Initialization
-When Bashtard is installed, the next step is bootstrapping the system. The
-`bootstrap` subcommand will perform all necesary steps to create the desired
-structure in `/etc/bashtard`.
+When Bashtard is installed, the next step is initializing the system. The `init`
+subcommand will perform all necesary steps to create the desired structure in
+`/etc/bashtard`.
- bashtard bootstrap
+ bashtard init
It is recommended you create a `git` directory out of `/etc/bashtard` for
-synchronization purposes. This will allow you to bootstrap Bashtard on other
+synchronization purposes. This will allow you to initialize Bashtard on other
systems by giving it the URL of the git repository as additional argument.
- bashtard bootstrap https://git.tyil.nl/tyilnet.git
+ bashtard init https://git.tyil.nl/tyilnet.git
With the additional argument, it will clone the repository to `/etc/bashtard`,
-and then apply any additional steps for the machine you're bootstrapping.
+and then apply any additional steps for the machine you're initping.
## General Usage
-After bootstrapping, you can start using Bashtard. It has the concept of
+After initializing, you can start using Bashtard. It has the concept of
playbooks, which can either be local or cloned from a remote git repository.
### One-off updates
diff --git a/lib/main.bash b/lib/main.bash
index 9a2d676..b5d6cc3 100644
--- a/lib/main.bash
+++ b/lib/main.bash
@@ -76,8 +76,8 @@ usage() {
Usage:
$BASHTARD_NAME -h
$BASHTARD_NAME add
- $BASHTARD_NAME bootstrap [repository]
$BASHTARD_NAME del
+ $BASHTARD_NAME init [repository]
$BASHTARD_NAME ssh
$BASHTARD_NAME sync [playbook]
$BASHTARD_NAME sysinfo
@@ -85,13 +85,13 @@ Usage:
Perform maintenance on your infra.
Commands:
- add Add a configuration playbook to this machine.
- bootstrap Bootstrap the $BASHTARD_NAME configuration system.
- 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
- playbooks.
- sysinfo Show gathered information about this system.
+ add Add a configuration playbook to this machine.
+ init Initialize the $BASHTARD_NAME configuration system.
+ 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
+ playbooks.
+ sysinfo Show gathered information about this system.
Playbooks:
EOF
diff --git a/lib/subcommands/bootstrap.bash b/lib/subcommands/bootstrap.bash
deleted file mode 100644
index 5a0f4ae..0000000
--- a/lib/subcommands/bootstrap.bash
+++ /dev/null
@@ -1,81 +0,0 @@
-#!/usr/bin/env bash
-
-# SPDX-FileCopyrightText: 2022 Patrick Spek
-#
-# SPDX-License-Identifier: AGPL-3.0-or-later
-
-subcommand()
-{
- remote="$1" ; shift
-
- if [[ -z "$remote" ]]
- then
- info "bootstrap" "No remote given, bootstrapping from scratch"
- bootstrap_local
- return
- fi
-
- bootstrap_remote "$remote"
-}
-
-bootstrap_local()
-{
- local dirs=(
- "$BASHTARD_ETCDIR"
- "$BASHTARD_ETCDIR/conf.d"
- "$BASHTARD_ETCDIR/hosts.d"
- "$BASHTARD_ETCDIR/os.d"
- "$BASHTARD_ETCDIR/playbooks.d"
- "$BASHTARD_ETCDIR/registry.d"
- "$BASHTARD_ETCDIR/registry.d/${BASHTARD_PLATFORM[fqdn]}"
- )
-
- local files=(
- "$BASHTARD_ETCDIR/defaults"
- "$BASHTARD_ETCDIR/hosts.d/${BASHTARD_PLATFORM[fqdn]}"
- "$BASHTARD_ETCDIR/os.d/${BASHTARD_PLATFORM[key]}"
- "$BASHTARD_ETCDIR/playbooks.d/remotes"
- )
-
- for dir in "${dirs[@]}"
- do
- notice "bashtard/bootstrap" "Creating $dir"
- mkdir -p -- "$dir"
- done
-
- for file in "${files[@]}"
- do
- notice "bashtard/bootstrap" "Creating $file"
- touch -- "$file"
- done
-}
-
-bootstrap_remote()
-{
- local remote="$1" ; shift
-
- notice "bootstrap" "Cloning $remote to $BASHTARD_ETCDIR"
- git clone "$remote" "$BASHTARD_ETCDIR"
-
- local files=(
- "$BASHTARD_ETCDIR/hosts.d/${BASHTARD_PLATFORM[fqdn]}"
- "$BASHTARD_ETCDIR/os.d/${BASHTARD_PLATFORM[key]}"
- "$BASHTARD_ETCDIR/registry.d/${BASHTARD_PLATFORM[fqdn]}"
- )
-
- for file in "${files[@]}"
- do
- [[ -f "$file" ]] && continue
-
- notice "bashtard/bootstrap" "Creating $file"
- touch -- "$file"
- done
-
- while read -r playbook url _
- do
- notice "bashtard/bootstrap" "Cloning $playbook from $url"
- git clone "$url" "$BASHTARD_ETCDIR/playbooks.d/$playbook"
-
- # TODO: Clone appropriate branch
- done < "$BASHTARD_ETCDIR/playbooks.d/remotes"
-}
diff --git a/lib/subcommands/init.bash b/lib/subcommands/init.bash
new file mode 100644
index 0000000..9194076
--- /dev/null
+++ b/lib/subcommands/init.bash
@@ -0,0 +1,81 @@
+#!/usr/bin/env bash
+
+# SPDX-FileCopyrightText: 2022 Patrick Spek
+#
+# SPDX-License-Identifier: AGPL-3.0-or-later
+
+subcommand()
+{
+ remote="$1" ; shift
+
+ if [[ -z "$remote" ]]
+ then
+ info "init" "No remote given, initping from scratch"
+ init_local
+ return
+ fi
+
+ init_remote "$remote"
+}
+
+init_local()
+{
+ local dirs=(
+ "$BASHTARD_ETCDIR"
+ "$BASHTARD_ETCDIR/conf.d"
+ "$BASHTARD_ETCDIR/hosts.d"
+ "$BASHTARD_ETCDIR/os.d"
+ "$BASHTARD_ETCDIR/playbooks.d"
+ "$BASHTARD_ETCDIR/registry.d"
+ "$BASHTARD_ETCDIR/registry.d/${BASHTARD_PLATFORM[fqdn]}"
+ )
+
+ local files=(
+ "$BASHTARD_ETCDIR/defaults"
+ "$BASHTARD_ETCDIR/hosts.d/${BASHTARD_PLATFORM[fqdn]}"
+ "$BASHTARD_ETCDIR/os.d/${BASHTARD_PLATFORM[key]}"
+ "$BASHTARD_ETCDIR/playbooks.d/remotes"
+ )
+
+ for dir in "${dirs[@]}"
+ do
+ notice "bashtard/init" "Creating $dir"
+ mkdir -p -- "$dir"
+ done
+
+ for file in "${files[@]}"
+ do
+ notice "bashtard/init" "Creating $file"
+ touch -- "$file"
+ done
+}
+
+init_remote()
+{
+ local remote="$1" ; shift
+
+ notice "init" "Cloning $remote to $BASHTARD_ETCDIR"
+ git clone "$remote" "$BASHTARD_ETCDIR"
+
+ local files=(
+ "$BASHTARD_ETCDIR/hosts.d/${BASHTARD_PLATFORM[fqdn]}"
+ "$BASHTARD_ETCDIR/os.d/${BASHTARD_PLATFORM[key]}"
+ "$BASHTARD_ETCDIR/registry.d/${BASHTARD_PLATFORM[fqdn]}"
+ )
+
+ for file in "${files[@]}"
+ do
+ [[ -f "$file" ]] && continue
+
+ notice "bashtard/init" "Creating $file"
+ touch -- "$file"
+ done
+
+ while read -r playbook url _
+ do
+ notice "bashtard/init" "Cloning $playbook from $url"
+ git clone "$url" "$BASHTARD_ETCDIR/playbooks.d/$playbook"
+
+ # TODO: Clone appropriate branch
+ done < "$BASHTARD_ETCDIR/playbooks.d/remotes"
+}
--
cgit v1.1