mirror of
https://codeberg.org/B3rtl/Ubuntu-Setup-Skripte
synced 2025-06-28 11:26:08 +02:00
Add EXIT trap, ensure non-interactive upgrade
This commit is contained in:
parent
59fa5b04c0
commit
effef41345
1 changed files with 16 additions and 1 deletions
|
@ -4,6 +4,7 @@
|
||||||
# Set variables
|
# Set variables
|
||||||
###
|
###
|
||||||
export DEBIAN_FRONTEND=noninteractive
|
export DEBIAN_FRONTEND=noninteractive
|
||||||
|
DPKG_CFG_FRAGMENT=/etc/dpkg/dpkg.cfg.d/non-interactive
|
||||||
|
|
||||||
# Color of prefix (>>>) to distinguish user and root echos
|
# Color of prefix (>>>) to distinguish user and root echos
|
||||||
color_prefix=32 # green
|
color_prefix=32 # green
|
||||||
|
@ -102,10 +103,18 @@ handle_signal() {
|
||||||
e "Ausführung abgebrochen! Script wird beendet..."
|
e "Ausführung abgebrochen! Script wird beendet..."
|
||||||
exit 1
|
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_signal SIGINT SIGTERM
|
||||||
|
trap handle_exit EXIT
|
||||||
|
|
||||||
pkg() {
|
pkg() {
|
||||||
apt install "$@" --quiet --yes
|
apt install "$@" --yes --quiet
|
||||||
}
|
}
|
||||||
|
|
||||||
###
|
###
|
||||||
|
@ -119,6 +128,12 @@ if is_root; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
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 ..."
|
e "Automatische Installation empfohlener Pakete aktivieren ..."
|
||||||
sed -i 's/false/true/g' /etc/apt/apt.conf.d/00recommends
|
sed -i 's/false/true/g' /etc/apt/apt.conf.d/00recommends
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue