Files
config-chezmoi/run_once_after_00-install-mise.sh.tmpl
T
xavierandClaude Opus 5.5 e7d9189de4 fix(chezmoi): Skip system packages tasks without sudo rights
mise bootstrap installs apt packages through sudo: for an account without
sudo (devenv sandbox agent), it failed and stopped chezmoi apply, thus the
image build. The bootstrap and the APT section of update are now skipped
unless the account is root, has passwordless sudo, or belongs to a sudo
group with a terminal to type the password.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 21:37:42 +01:00

46 lines
1.6 KiB
Cheetah

#!/usr/bin/env bash
# Droits d'administration : root, sudo sans mot de passe, ou membre d'un
# groupe sudo avec un terminal pour saisir le mot de passe
can_sudo() {
(( EUID == 0 )) || sudo -n true 2>/dev/null \
|| { [ -t 0 ] && id -nG | grep -qwE 'sudo|admin|wheel'; }
}
# 1. Installer Mise s'il n'est pas présent
if ! command -v mise &>/dev/null; then
echo "📦 Installation de Mise..."
curl https://mise.run | sh
# S'assurer que mise est immédiatement accessible dans la session du script
export PATH="${HOME}/.local/bin:$PATH"
fi
# 2. Lancer le bootstrap (paquets système : droits sudo requis)
if command -v mise &>/dev/null; then
if can_sudo; then
echo "🚀 Mise bootstrap..."
mise bootstrap --yes
else
echo "⚠️ Pas de droits sudo : mise bootstrap ignoré (paquets système non installés)."
fi
fi
# 3. Installer tous les outils déclarés dans ~/.config/mise/config.toml et ~/.config/mise/conf.d/*.toml
if command -v mise &>/dev/null; then
echo "⚡ Installation des outils via Mise (dont chezmoi si désiré)..."
mise install --yes
fi
# 4. Nettoyage du binaire chezmoi (maintenant géré par mise)
CURRENT_CHEZMOI="$CHEZMOI_EXECUTABLE" # Chezmoi expose la variable $CHEZMOI_EXECUTABLE pointant vers le binaire en cours d'exécution
MISE_CHEZMOI_BIN="$(mise where chezmoi)/chezmoi"
if [ "$CURRENT_CHEZMOI" != "$MISE_CHEZMOI_BIN" ]; then
echo "🧹 Nettoyage du binaire chezmoi temporaire ($CURRENT_CHEZMOI)..."
rm -fv "$CURRENT_CHEZMOI"
echo "✅ Désormais, seul le chezmoi de mise est actif."
else
echo "✅ La commande chezmoi est déjà gérée par mise."
fi