#!/bin/sh -e . /rebuild/re-build-bootstrap-utils dep_install() { if has_app dnf; then dnf install -y $* #cleaning to make image smaller dnf clean all elif has_app yum; then yum install -y $* #cleaning to make image smaller yum clean all elif has_app apt-get; then apt-get update apt-get install -y $* #cleaning to make image smaller apt-get clean elif has_app apk; then apk update apk add $* elif has_app zypper; then zypper install -y $* #cleaning to make image smaller zypper clean elif has_app urpmi; then urpmi sudo else echo Failed to install "$*", no supported package manager found exit 1 fi } configure_sudo() { echo "ALL ALL=(ALL:ALL) NOPASSWD: ALL" > /etc/sudoers } try_install_sudo() { if ! has_app sudo; then dep_install sudo fi return $(has_app sudo) } # Download may fail unpredictably so we try a few times try_install_sudo || try_install_sudo || try_install_sudo configure_sudo