feat(installer): install via managed manifest with non-interactive params (Bash)

Bash equivalent of the PowerShell installer change: delegates to
sync_managed_destination, adds --client/--platform for non-interactive
runs (falling back to the existing interactive prompts when omitted), and
requires --update-plugins to update already-installed plugins instead of
doing so by default.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Julian lechner
2026-09-11 15:43:04 +02:00
co-authored by Claude Sonnet 5
parent f72af0ee39
commit e617a2477a
+43 -38
View File
@@ -2,71 +2,76 @@
set -euo pipefail
dry_run=false
for argument in "$@"; do
[ "$argument" != "--dry-run" ] || dry_run=true
client=""
platform=""
update_plugins=false
while [ $# -gt 0 ]; do
case "$1" in
--dry-run) dry_run=true; shift ;;
--update-plugins) update_plugins=true; shift ;;
--client) client=${2:?--client requires a value}; shift 2 ;;
--platform) platform=${2:?--platform requires a value}; shift 2 ;;
*) printf 'Unknown argument: %s\n' "$1" >&2; exit 1 ;;
esac
done
root=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." && pwd)
. "$root/scripts/lib/plugins.sh"
. "$root/scripts/lib/manifest.sh"
bash "$root/scripts/build.sh"
generated="$root/generated"
[ -d "$generated" ] || { printf 'Generated output is missing after a successful build.\n' >&2; exit 1; }
if [ -z "$platform" ]; then
printf 'Select target platform:\n1) Windows\n2) Linux\n'
while :; do
read -r -p 'Selection [1-2] ' platform_selection
case "$platform_selection" in 1) platform=windows; break;; 2) platform=linux; break;; esac
done
else
case "$platform" in
windows|Windows) platform=windows ;;
linux|Linux) platform=linux ;;
*) printf 'Unknown --platform value: %s (expected windows or linux)\n' "$platform" >&2; exit 1 ;;
esac
fi
if [ -z "$client" ]; then
printf 'Select installation target:\n1) Codex\n2) Claude\n3) Both\n'
while :; do
read -r -p 'Selection [1-3] ' selection
case "$selection" in 1|2|3) break;; esac
case "$selection" in 1) client=codex; break;; 2) client=claude; break;; 3) client=both; break;; esac
done
else
case "$client" in
codex|Codex) client=codex ;;
claude|Claude) client=claude ;;
both|Both) client=both ;;
*) printf 'Unknown --client value: %s (expected codex, claude, or both)\n' "$client" >&2; exit 1 ;;
esac
fi
stamp=$(date +%Y%m%d-%H%M%S)
home_path=${HOME:?HOME is required}
shell_command=bash
windows_shell_command='powershell -NoProfile -ExecutionPolicy Bypass -File'
targets=()
case "$selection" in
1|3) targets+=("$generated/codex-$platform|$home_path/.codex" "$generated/codex-$platform/skills|$home_path/.agents/skills");;
case "$client" in
codex|both) targets+=("$generated/codex-$platform|$home_path/.codex" "$generated/codex-$platform/skills|$home_path/.agents/skills");;
esac
case "$selection" in
2|3) targets+=("$generated/claude-$platform|$home_path/.claude");;
case "$client" in
claude|both) targets+=("$generated/claude-$platform|$home_path/.claude");;
esac
for target_pair in "${targets[@]}"; do
source=${target_pair%%|*}
destination=${target_pair#*|}
while IFS= read -r -d '' source_file; do
relative=${source_file#"$source/"}
target="$destination/$relative"
if "$dry_run"; then printf 'DRYRUN %s -> %s\n' "$source_file" "$target"; continue; fi
if [ -f "$target" ]; then
backup="$destination/backups/$relative.$stamp"
mkdir -p "$(dirname -- "$backup")"
cp "$target" "$backup"
fi
mkdir -p "$(dirname -- "$target")"
content=$(<"$source_file")
if [[ "$content" == *'__AI_CONFIG_ROOT__'* || "$content" == *'__HOOK_COMMAND__'* || "$content" == *'__WINDOWS_HOOK_COMMAND__'* ]]; then
replacement=$destination
if command -v cygpath >/dev/null; then replacement=$(cygpath -m "$destination"); fi
content=${content//__AI_CONFIG_ROOT__/$replacement}
content=${content//__HOOK_COMMAND__/bash}
content=${content//__WINDOWS_HOOK_COMMAND__/bash}
content=${content//__HOOK_SCRIPT__/flashbang.sh}
content=${content//__WINDOWS_HOOK_SCRIPT__/flashbang.sh}
printf '%s' "$content" > "$target"
else
cp "$source_file" "$target"
fi
printf 'INSTALL %s\n' "$target"
done < <(find "$source" -type f -print0)
ai_config_root=$destination
command -v cygpath >/dev/null && ai_config_root=$(cygpath -m "$destination")
sync_managed_destination "$source" "$destination" "$stamp" "$ai_config_root" "$shell_command" "$windows_shell_command" "$dry_run"
done
client_selection=both
case "$selection" in
1) client_selection=codex;;
2) client_selection=claude;;
esac
install_configured_plugins "$root" "$client_selection" "$dry_run" true
install_configured_plugins "$root" "$client" "$dry_run" "$update_plugins"
if "$dry_run"; then printf 'PASS install dry-run\n'; else printf 'PASS install\n'; fi