rig major updates
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
# Install the addons the active profile asked for, in the order listed.
|
||||
# One idempotent script per addon in ctrl/addons/.
|
||||
# Install the addons the configuration asks for (ADDONS), in the order listed.
|
||||
# One idempotent script per addon: the overlay's addons/<name>.sh first, then rig's ctrl/addons/.
|
||||
# Usage: addons.sh install | list
|
||||
# Notes: docs/notes/addons.md
|
||||
set -euo pipefail
|
||||
@@ -9,26 +9,51 @@ cd "$(dirname "$0")"
|
||||
source ./lib/config.sh
|
||||
load_config
|
||||
|
||||
# Every addon runs from here, wherever its file lives, so it can source ./lib/config.sh.
|
||||
export RIG_CTRL="$PWD"
|
||||
|
||||
# The script for one addon name: the overlay's, else rig's; empty if neither.
|
||||
addon_path() {
|
||||
local ov=""
|
||||
if [ -n "$OVERLAY_DIR" ]; then ov="$(_from_ctrl "$OVERLAY_DIR")/addons/$1.sh"; fi
|
||||
if [ -n "$ov" ] && [ -f "$ov" ]; then
|
||||
echo "$ov"
|
||||
elif [ -f "addons/$1.sh" ]; then
|
||||
echo "addons/$1.sh"
|
||||
fi
|
||||
}
|
||||
|
||||
install() {
|
||||
if [ -z "${ADDONS// /}" ]; then
|
||||
echo "no addons in profile '$PROFILE_NAME'"
|
||||
echo "no addons asked for (ADDONS is empty)"
|
||||
return
|
||||
fi
|
||||
local a
|
||||
local a p
|
||||
for a in $ADDONS; do
|
||||
if [ ! -f "addons/${a}.sh" ]; then
|
||||
echo "no such addon: addons/${a}.sh" >&2
|
||||
p=$(addon_path "$a")
|
||||
if [ -z "$p" ]; then
|
||||
echo "no such addon: $a (looked in the overlay's addons/ and ctrl/addons/)" >&2
|
||||
exit 1
|
||||
fi
|
||||
echo "addon: $a"
|
||||
bash "addons/${a}.sh"
|
||||
bash "$p"
|
||||
done
|
||||
}
|
||||
|
||||
list() {
|
||||
echo "profile '$PROFILE_NAME' wants: ${ADDONS:-none}"
|
||||
echo "wanted: ${ADDONS:-none}"
|
||||
echo "available:"
|
||||
ls addons/*.sh 2>/dev/null | xargs -n1 basename | sed 's/\.sh$//' | sed 's/^/ /'
|
||||
local f
|
||||
if [ -n "$OVERLAY_DIR" ]; then
|
||||
for f in "$(_from_ctrl "$OVERLAY_DIR")"/addons/*.sh; do
|
||||
[ -e "$f" ] || continue
|
||||
printf ' %-16s overlay\n' "$(basename "$f" .sh)"
|
||||
done
|
||||
fi
|
||||
for f in addons/*.sh; do
|
||||
[ -e "$f" ] || continue
|
||||
printf ' %-16s rig\n' "$(basename "$f" .sh)"
|
||||
done
|
||||
}
|
||||
|
||||
case "${1:-list}" in
|
||||
|
||||
Reference in New Issue
Block a user