5
0
Fork 0
mirror of https://codeberg.org/Computertruhe/Setup-Skripte.git synced 2024-06-06 18:46:25 +02:00

Add EXIT trap, ensure non-interactive upgrade

This commit is contained in:
ml 2020-01-12 05:59:51 +01:00
parent 59fa5b04c0
commit effef41345

View file

@ -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