diff --git a/delayed-admin.sudoers b/delayed-admin.sudoers index 3dea715..fe4ecac 100644 --- a/delayed-admin.sudoers +++ b/delayed-admin.sudoers @@ -1 +1 @@ -%delayed-admin ALL = /usr/local/bin/delayed +%delayed-admin ALL = NOPASSWD: /usr/local/bin/delayed diff --git a/lib/linux.sh b/lib/linux.sh index 507a09e..5b512d8 100644 --- a/lib/linux.sh +++ b/lib/linux.sh @@ -8,16 +8,43 @@ function distro_id() { echo $ID } function admin_group() { - case $(distro_id) in - ubuntu|debian) + local id + id=$(distro_id) + case $id in + ubuntu|kubuntu|debian|linuxmint|pop|neon|elementary|zorin) echo "sudo" ;; - centos|fedora|rhel|arch|manjaro|endeavouros) + centos|fedora|rhel|arch|manjaro|endeavouros|opensuse*|sles) echo "wheel" ;; + *) + # Fallback: use ID_LIKE from /etc/os-release + local id_like + id_like=$(grep '^ID_LIKE=' /etc/os-release 2>/dev/null | cut -d= -f2- | tr -d '"') + case "$id_like" in + *ubuntu*|*debian*) + echo "sudo" + ;; + *rhel*|*fedora*|*centos*|*suse*) + echo "wheel" + ;; + *) + # Last resort: check which admin group actually exists on this system. + # If neither exists, admin_group() returns empty and the check below will abort. + if getent group sudo > /dev/null 2>&1; then + echo "sudo" + elif getent group wheel > /dev/null 2>&1; then + echo "wheel" + fi + ;; + esac + ;; esac } readonly ADMIN_GROUP=$(admin_group) +if [ -z "$ADMIN_GROUP" ]; then + die "Could not determine the admin group for this OS (ID=$(distro_id)). Please file a bug report." +fi #TODO Implement these function check_atd_is_running { true; } function start_atd { true; }