agent: Arch support

This commit is contained in:
2025-08-23 17:38:36 +01:00
parent 3752e204be
commit d9e7317e2e
15 changed files with 188 additions and 49 deletions

View File

@@ -2,13 +2,36 @@
# -----------------------------------------------------------------------------
# Description:
# Print operating system information.
# Print operating system information and hint which installer path will run.
#
if [[ "$OSTYPE" == "darwin"* ]]; then
# macOS info
sw_vers
log_info "Detected macOS (OSTYPE=$OSTYPE)"
log_info "Package manager: Homebrew (brew)"
log_info "Code path: macOS-only brew scripts will run; Linux package scripts are skipped."
elif [[ "$OSTYPE" == "linux-gnu"* ]]; then
cat /etc/os-release
# Linux info
if [[ -r /etc/os-release ]]; then
cat /etc/os-release
# shellcheck source=/dev/null
. /etc/os-release
fi
log_info "Detected Linux (OSTYPE=$OSTYPE, ID=${ID:-unknown}, ID_LIKE=${ID_LIKE:-n/a}, NAME=${NAME:-n/a}, VERSION_ID=${VERSION_ID:-n/a})"
if command -v apt-get >/dev/null 2>&1; then
log_info "Package manager detected: apt-get"
export DOTS_PKG_MGR=apt
elif command -v pacman >/dev/null 2>&1; then
log_info "Package manager detected: pacman"
export DOTS_PKG_MGR=pacman
else
log_warn "No known package manager (apt-get/pacman) found on Linux."
fi
else
log_error "Unknown OS: $OSTYPE"
fi

View File

@@ -0,0 +1,25 @@
#!/usr/bin/env bash
# -----------------------------------------------------------------------------
# Description:
# (distros with pacman only) Install core pacman packages.
#
if command -v pacman &> /dev/null; then
pacman_packages=(
ca-certificates
curl
gnupg
wget
base-devel
)
sudo pacman -Sy --noconfirm
sudo pacman -S --noconfirm --needed "${pacman_packages[@]}"
unset pacman_packages
pacman --version
else
log_warn "Skipping: pacman not found"
fi

View File

@@ -7,7 +7,13 @@
if ! command -v git &> /dev/null; then
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
sudo apt-get install -qq git
if command -v apt-get >/dev/null 2>&1; then
sudo apt-get install -qq git
elif command -v pacman >/dev/null 2>&1; then
sudo pacman -S --noconfirm git
else
log_warn "Skipping git install: no supported package manager found"
fi
elif [[ "$OSTYPE" == "darwin"* ]]; then
brew install git
fi

View File

@@ -8,7 +8,13 @@
# install zsh
if ! command -v zsh &> /dev/null; then
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
sudo apt-get install -qq zsh
if command -v apt-get >/dev/null 2>&1; then
sudo apt-get install -qq zsh
elif command -v pacman >/dev/null 2>&1; then
sudo pacman -S --noconfirm zsh
else
log_warn "Skipping zsh install: no supported package manager found"
fi
elif [[ "$OSTYPE" == "darwin"* ]]; then
brew install zsh
fi

View File

@@ -7,7 +7,13 @@
if ! command -v stow &> /dev/null; then
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
sudo apt-get install -qq stow
if command -v apt-get >/dev/null 2>&1; then
sudo apt-get install -qq stow
elif command -v pacman >/dev/null 2>&1; then
sudo pacman -S --noconfirm stow
else
log_warn "Skipping stow install: no supported package manager found"
fi
elif [[ "$OSTYPE" == "darwin"* ]]; then
brew install stow
fi

View File

@@ -11,15 +11,25 @@ if ! echo "$PATH" | grep -q "$PYENV_ROOT"; then
fi
if ! command -v pyenv &>/dev/null; then
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
# https://github.com/pyenv/pyenv/wiki#suggested-build-environment
sudo apt-get install -qq build-essential libssl-dev zlib1g-dev \
libbz2-dev libreadline-dev libsqlite3-dev curl \
libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev
if command -v apt-get >/dev/null 2>&1; then
# https://github.com/pyenv/pyenv/wiki#suggested-build-environment
sudo apt-get install -qq build-essential libssl-dev zlib1g-dev \
libbz2-dev libreadline-dev libsqlite3-dev curl \
libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev
# see https://github.com/pyenv/pyenv-installer
bash -c "$(curl -fsSL https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer)"
unset pyenv_packages
# see https://github.com/pyenv/pyenv-installer
bash -c "$(curl -fsSL https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer)"
elif command -v pacman >/dev/null 2>&1; then
# Prefer native packages if available; otherwise install build deps then use installer
if ! sudo pacman -Qi pyenv >/dev/null 2>&1; then
sudo pacman -S --noconfirm --needed base-devel openssl zlib bzip2 readline sqlite xz tk libffi curl
bash -c "$(curl -fsSL https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer)"
else
sudo pacman -S --noconfirm --needed pyenv pyenv-virtualenv
fi
else
log_warn "Skipping pyenv install: no supported package manager found"
fi
elif [[ "$OSTYPE" == "darwin"* ]]; then
brew install pyenv
brew install pyenv-virtualenv

View File

@@ -40,7 +40,13 @@ unset local_bin_path
if ! command -v pipx &>/dev/null; then
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
sudo apt-get install -qq pipx
if command -v apt-get >/dev/null 2>&1; then
sudo apt-get install -qq pipx
elif command -v pacman >/dev/null 2>&1; then
sudo pacman -S --noconfirm python-pipx
else
log_warn "Skipping pipx install: no apt-get or pacman found"
fi
elif [[ "$OSTYPE" == "darwin"* ]]; then
brew install pipx
fi

View File

@@ -27,17 +27,23 @@ fi
if [[ -z "$SKIP_DOCKER_CONFIG" ]]; then
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
if ! command -v docker &> /dev/null; then
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc
if command -v apt-get >/dev/null 2>&1; then
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
elif command -v pacman >/dev/null 2>&1; then
sudo pacman -S --noconfirm --needed docker docker-buildx docker-compose
else
log_warn "Skipping Docker install: no supported package manager found"
fi
fi
readonly docker_group="docker"

View File

@@ -7,12 +7,18 @@
if ! command -v gh &>/dev/null; then
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
# https://github.com/cli/cli/blob/trunk/docs/install_linux.md#debian-ubuntu-linux-raspberry-pi-os-apt
sudo mkdir -p -m 755 /etc/apt/keyrings && wget -qO- https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo tee /etc/apt/keyrings/githubcli-archive-keyring.gpg >/dev/null &&
sudo chmod go+r /etc/apt/keyrings/githubcli-archive-keyring.gpg &&
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list >/dev/null &&
sudo apt-get update -qq &&
sudo apt-get install -qq gh
if command -v apt-get >/dev/null 2>&1; then
# https://github.com/cli/cli/blob/trunk/docs/install_linux.md#debian-ubuntu-linux-raspberry-pi-os-apt
sudo mkdir -p -m 755 /etc/apt/keyrings && wget -qO- https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo tee /etc/apt/keyrings/githubcli-archive-keyring.gpg >/dev/null &&
sudo chmod go+r /etc/apt/keyrings/githubcli-archive-keyring.gpg &&
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list >/dev/null &&
sudo apt-get update -qq &&
sudo apt-get install -qq gh
elif command -v pacman >/dev/null 2>&1; then
sudo pacman -S --noconfirm github-cli
else
log_warn "Skipping GitHub CLI install: no supported package manager found"
fi
elif [[ "$OSTYPE" == "darwin"* ]]; then
brew install gh
fi

View File

@@ -7,8 +7,18 @@
if ! command -v az &>/dev/null; then
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
# https://docs.microsoft.com/en-us/cli/azure/install-azure-cli-linux?pivots=apt
curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
if command -v apt-get >/dev/null 2>&1; then
# https://docs.microsoft.com/en-us/cli/azure/install-azure-cli-linux?pivots=apt
curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
elif command -v pacman >/dev/null 2>&1; then
if command -v yay >/dev/null 2>&1; then
yay -S --noconfirm azure-cli-bin || log_warn "AUR install failed for azure-cli-bin"
else
log_warn "Skipping Azure CLI: no AUR helper found"
fi
else
log_warn "Skipping Azure CLI install: no supported package manager found"
fi
elif [[ "$OSTYPE" == "darwin"* ]]; then
brew install azure-cli
fi

View File

@@ -7,15 +7,21 @@
if ! command -v terraform &>/dev/null; then
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
terraform_keyring_path="/usr/share/keyrings/hashicorp-archive-keyring.gpg"
if [[ ! -f "$terraform_keyring_path" ]]; then
curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o "$terraform_keyring_path"
if command -v apt-get >/dev/null 2>&1; then
terraform_keyring_path="/usr/share/keyrings/hashicorp-archive-keyring.gpg"
if [[ ! -f "$terraform_keyring_path" ]]; then
curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o "$terraform_keyring_path"
fi
echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] \
https://apt.releases.hashicorp.com $(lsb_release -cs) main" |
sudo tee /etc/apt/sources.list.d/hashicorp.list
sudo apt-get update -qq &&
sudo apt-get install -qq terraform
elif command -v pacman >/dev/null 2>&1; then
sudo pacman -S --noconfirm terraform
else
log_warn "Skipping Terraform install: no supported package manager found"
fi
echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] \
https://apt.releases.hashicorp.com $(lsb_release -cs) main" |
sudo tee /etc/apt/sources.list.d/hashicorp.list
sudo apt-get update -qq &&
sudo apt-get install -qq terraform
elif [[ "$OSTYPE" == "darwin"* ]]; then
brew tap hashicorp/tap
brew install hashicorp/tap/terraform

View File

@@ -7,13 +7,19 @@
if ! command -v redis-cli &>/dev/null; then
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
redis_keyring_path="/usr/share/keyrings/redis-archive-keyring.gpg"
if [[ ! -f "$redis_keyring_path" ]]; then
curl -fsSL https://packages.redis.io/gpg | sudo gpg --dearmor -o "$redis_keyring_path"
if command -v apt-get >/dev/null 2>&1; then
redis_keyring_path="/usr/share/keyrings/redis-archive-keyring.gpg"
if [[ ! -f "$redis_keyring_path" ]]; then
curl -fsSL https://packages.redis.io/gpg | sudo gpg --dearmor -o "$redis_keyring_path"
fi
echo "deb [signed-by=/usr/share/keyrings/redis-archive-keyring.gpg] https://packages.redis.io/deb $(lsb_release -cs) main" \
| sudo tee /etc/apt/sources.list.d/redis.list > /dev/null
sudo apt-get install -qq redis
elif command -v pacman >/dev/null 2>&1; then
sudo pacman -S --noconfirm redis
else
log_warn "Skipping Redis install: no supported package manager found"
fi
echo "deb [signed-by=/usr/share/keyrings/redis-archive-keyring.gpg] https://packages.redis.io/deb $(lsb_release -cs) main" \
| sudo tee /etc/apt/sources.list.d/redis.list > /dev/null
sudo apt-get install -qq redis
elif [[ "$OSTYPE" == "darwin"* ]]; then
brew install redis
fi

View File

@@ -7,7 +7,13 @@
if ! command -v neofetch &>/dev/null; then
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
sudo apt-get install -qq neofetch &>/dev/null
if command -v apt-get >/dev/null 2>&1; then
sudo apt-get install -qq neofetch &>/dev/null
elif command -v pacman >/dev/null 2>&1; then
sudo pacman -S --noconfirm neofetch &>/dev/null
else
log_warn "Skipping neofetch install: no supported package manager found"
fi
elif [[ "$OSTYPE" == "darwin"* ]]; then
brew install neofetch
fi

View File

@@ -14,7 +14,13 @@ fi
if [[ -z "$SKIP_CMATRIX_CONFIG" ]]; then
if ! command -v cmatrix &> /dev/null; then
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
sudo apt-get install -qq cmatrix &>/dev/null
if command -v apt-get >/dev/null 2>&1; then
sudo apt-get install -qq cmatrix &>/dev/null
elif command -v pacman >/dev/null 2>&1; then
sudo pacman -S --noconfirm cmatrix &>/dev/null
else
log_warn "Skipping cmatrix install: no supported package manager found"
fi
elif [[ "$OSTYPE" == "darwin"* ]]; then
brew install cmatrix
fi

View File

@@ -8,8 +8,19 @@
if [[ "$OSTYPE" == "darwin"* ]]; then
brew cleanup
elif [[ "$OSTYPE" == "linux-gnu"* ]]; then
sudo apt-get autoremove -qq
sudo apt-get clean -qq
if command -v apt-get >/dev/null 2>&1; then
sudo apt-get autoremove -qq
sudo apt-get clean -qq
elif command -v pacman >/dev/null 2>&1; then
# Remove orphans if any (ignore error if none)
if pacman -Qtdq >/dev/null 2>&1; then
sudo pacman -Rns --noconfirm $(pacman -Qtdq) || true
fi
# Clear package cache without interactive prompt
yes | sudo pacman -Scc >/dev/null 2>&1 || true
else
log_warn "Skipping cleanup: no supported package manager found"
fi
fi
log_pass "Cleanup completed successfully!"