Last active
July 26, 2026 03:13
-
-
Save alchemizt33/0670ac9ea3a09ed93f09a02430171ead to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| set -Eeuo pipefail | |
| CONFIG_DIR="${XDG_CONFIG_HOME:-$HOME/.config}/provisioner" | |
| CONFIG_FILE="$CONFIG_DIR/config.toml" | |
| mkdir -p "$CONFIG_DIR" | |
| if [[ ! -f "$CONFIG_FILE" ]]; then | |
| cat >"$CONFIG_FILE" <<'EOF' | |
| [bootstrap] | |
| setup_script = "https://gist.github.com/alchemizt33/884cd30f347900dd4e55ecdca85162a2#file-omakub-post-setup-sh" | |
| EOF | |
| echo "Created configuration:" | |
| echo " $CONFIG_FILE" | |
| fi | |
| echo "Using configuration:" | |
| echo " $CONFIG_FILE" | |
| SETUP_SCRIPT="$( | |
| python - "$CONFIG_FILE" <<'PY' | |
| import sys | |
| import tomllib | |
| from pathlib import Path | |
| config_file = Path(sys.argv[1]) | |
| try: | |
| with config_file.open("rb") as file: | |
| config = tomllib.load(file) | |
| except tomllib.TOMLDecodeError as error: | |
| print(f"Invalid TOML in {config_file}: {error}", file=sys.stderr) | |
| raise SystemExit(1) | |
| try: | |
| setup_script = config["bootstrap"]["setup_script"] | |
| except KeyError: | |
| print( | |
| f"Missing [bootstrap] setup_script in {config_file}", | |
| file=sys.stderr, | |
| ) | |
| raise SystemExit(1) | |
| if not isinstance(setup_script, str): | |
| print("bootstrap.setup_script must be a string", file=sys.stderr) | |
| raise SystemExit(1) | |
| print(setup_script) | |
| PY | |
| )" | |
| if [[ "$SETUP_SCRIPT" != https://* && "$SETUP_SCRIPT" != http://* ]]; then | |
| printf 'Invalid setup script URL: %s\n' "$SETUP_SCRIPT" >&2 | |
| exit 1 | |
| fi | |
| echo "Downloading setup script:" | |
| echo " $SETUP_SCRIPT" | |
| curl -fsSL "$SETUP_SCRIPT" | bash |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment