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>
This commit is contained in:
1 parent
ee405c937a
commit
e7d9189de4
3 files changed
+58
-23
No files matched your search
@@ -1,5 +1,12 @@
|
||||
#!/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..."
|
||||
@@ -9,10 +16,14 @@ if ! command -v mise &>/dev/null; then
|
||||
export PATH="${HOME}/.local/bin:$PATH"
|
||||
fi
|
||||
|
||||
# 2. Lancer le bootstrap
|
||||
# 2. Lancer le bootstrap (paquets système : droits sudo requis)
|
||||
if command -v mise &>/dev/null; then
|
||||
echo "🚀 Mise bootstrap..."
|
||||
mise bootstrap --yes
|
||||
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
|
||||
|
||||
Reference in new issue
Block a user