diff --git a/linux_mint.sh b/linux_mint.sh index a75ed3e..c647a49 100755 --- a/linux_mint.sh +++ b/linux_mint.sh @@ -4,6 +4,7 @@ # Set variables ### export DEBIAN_FRONTEND=noninteractive +DPKG_CFG_FRAGMENT=/etc/dpkg/dpkg.cfg.d/non-interactive # Color of prefix (>>>) to distinguish user and root echos color_prefix=32 # green @@ -102,10 +103,18 @@ handle_signal() { e "Ausführung abgebrochen! Script wird beendet..." exit 1 } + +# always executed on shell exit regardless of reason. for cleanup tasks +handle_exit() { + # Remove temporary dpkg cfg if root + is_root && rm -f "$DPKG_CFG_FRAGMENT" +} + trap handle_signal SIGINT SIGTERM +trap handle_exit EXIT pkg() { - apt install "$@" --quiet --yes + apt install "$@" --yes --quiet } ### @@ -119,6 +128,12 @@ if is_root; then exit 1 fi + # place temporary dpkg configurations to ensure non-interactive upgrade + cat <<'DPKG' >"$DPKG_CFG_FRAGMENT" +force-confold +force-confdef +DPKG + e "Automatische Installation empfohlener Pakete aktivieren ..." sed -i 's/false/true/g' /etc/apt/apt.conf.d/00recommends