diff --git a/setup.sh b/setup.sh index 06bca69..8437f72 100755 --- a/setup.sh +++ b/setup.sh @@ -541,9 +541,10 @@ install_category_pkgs() { [[ "$item" == *libvirt* || "$item" == *virt-manager* || "$item" == *virt-install* ]] && wants_libvirt=true done if $wants_libvirt; then - info "Enabling libvirtd and adding $USER to the libvirt group..." + local real_user="${SUDO_USER:-$USER}" + info "Enabling libvirtd and adding $real_user to the libvirt group..." sudo systemctl enable --now libvirtd 2>/dev/null || true - sudo usermod -aG libvirt "$USER" || true + sudo usermod -aG libvirt "$real_user" || true warn "libvirt group membership applies after re-login." fi ;;