aboutsummaryrefslogtreecommitdiff
path: root/boxconf
diff options
context:
space:
mode:
authorCullum Smith <cullum@sacredheartsc.com>2024-07-11 10:55:45 -0400
committerCullum Smith <cullum@sacredheartsc.com>2024-07-11 10:55:45 -0400
commit85007db580ccf662a45cf2aaeb83518ad2ddb85a (patch)
treed692c5bdbaf33c5b9791d538982b17ab4dd808ee /boxconf
parentde8305223b6079d14ac854ee067ffd069cb38ec7 (diff)
downloadinfrastructure-85007db580ccf662a45cf2aaeb83518ad2ddb85a.tar.gz
initial boxconf scaffolding
Diffstat (limited to 'boxconf')
-rwxr-xr-xboxconf40
1 files changed, 40 insertions, 0 deletions
diff --git a/boxconf b/boxconf
new file mode 100755
index 0000000..52d8500
--- /dev/null
+++ b/boxconf
@@ -0,0 +1,40 @@
+#!/bin/sh
+#
+# Shell-based configuration management framework for unix-like systems.
+
+set -eu
+
+PROGNAME=boxconf
+USAGE="${PROGNAME} [-d] [-e VAR=VALUE]... [-o HOSTNAME] TARGET"
+BOXCONF_ROOT=$(dirname "$(readlink -f "$0")")
+
+usage(){
+ [ $# -gt 0 ] && printf '%s\n' "$1" 2>&1
+ printf 'usage: %s\n' "$USAGE" 2>&1
+ exit 2
+}
+
+while getopts :hde:o:X _bc_opt; do
+ case $_bc_opt in
+ h) usage ;;
+ d) set -x ;;
+ e) eval "$OPTARG" ;;
+ o) BOXCONF_HOSTNAME=$OPTARG ;;
+ X) _bc_run=1 ;;
+ :) usage "missing option value: -${OPTARG}" ;;
+ ?) usage "unknown option: -${OPTARG}" ;;
+ esac
+done
+
+shift $((OPTIND - 1))
+[ $# -eq 1 ] || usage
+
+for _bc_lib in "${BOXCONF_ROOT}/lib"/*; do
+ . "$_bc_lib"
+done
+
+if [ -n "${_bc_run:-}" ]; then
+ _boxconf_run
+else
+ _boxconf_deploy "$1" "${BOXCONF_HOSTNAME:-$1}" "$@"
+fi