mirror of
https://git.valherun.com/valherun/pxe_boot_alma.git
synced 2026-10-16 00:42:03 -04:00
71 lines
1.8 KiB
Bash
Executable File
71 lines
1.8 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
set -euo pipefail
|
|
|
|
REPO_BASE="${REPO_BASE:-/usr/local/valherun}"
|
|
KICKSTART_REPO_URL="${KICKSTART_REPO_URL:-https://git.valherun.com/valherun/kickstart.git}"
|
|
TOOLS_REPO_URL="${TOOLS_REPO_URL:-https://git.valherun.com/valherun/tools.git}"
|
|
INSTALL_VALHERUN="${INSTALL_VALHERUN:-true}"
|
|
INSTALL_CODEX="${INSTALL_CODEX:-true}"
|
|
UPDATE_SSHD="${UPDATE_SSHD:-true}"
|
|
DEPLOY_BASH_PROFILES="${DEPLOY_BASH_PROFILES:-true}"
|
|
|
|
ensure_pkg() {
|
|
if command -v dnf >/dev/null 2>&1; then
|
|
dnf install -y "$@"
|
|
elif command -v yum >/dev/null 2>&1; then
|
|
yum install -y "$@"
|
|
elif command -v apt-get >/dev/null 2>&1; then
|
|
apt-get update
|
|
apt-get install -y "$@"
|
|
else
|
|
echo "Unsupported package manager" >&2
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
clone_or_update() {
|
|
local url="$1"
|
|
local dest="$2"
|
|
|
|
if [[ -d "$dest/.git" ]]; then
|
|
git -C "$dest" pull --ff-only
|
|
return
|
|
fi
|
|
|
|
mkdir -p "$(dirname "$dest")"
|
|
git clone "$url" "$dest"
|
|
}
|
|
|
|
if [[ $EUID -ne 0 ]]; then
|
|
echo "This script must run as root." >&2
|
|
exit 1
|
|
fi
|
|
|
|
ensure_pkg git curl sudo wget bash-completion
|
|
|
|
clone_or_update "$KICKSTART_REPO_URL" "$REPO_BASE/kickstart"
|
|
clone_or_update "$TOOLS_REPO_URL" "$REPO_BASE/tools"
|
|
|
|
if [[ "$INSTALL_VALHERUN" == "true" ]]; then
|
|
bash "$REPO_BASE/kickstart/bin/create_valherun.sh" valherun || true
|
|
fi
|
|
|
|
if [[ "$DEPLOY_BASH_PROFILES" == "true" ]]; then
|
|
if id -u valherun >/dev/null 2>&1; then
|
|
bash "$REPO_BASE/kickstart/bash_profiles.sh" --adduser
|
|
else
|
|
bash "$REPO_BASE/kickstart/bash_profiles.sh"
|
|
fi
|
|
fi
|
|
|
|
if [[ "$INSTALL_CODEX" == "true" ]]; then
|
|
bash "$REPO_BASE/tools/bin/install_codex_access.sh"
|
|
fi
|
|
|
|
if [[ "$UPDATE_SSHD" == "true" ]]; then
|
|
bash "$REPO_BASE/tools/bin/update_sshd_config.sh"
|
|
fi
|
|
|
|
echo "Post-install bootstrap complete."
|