add compat for Debian 12 (bookworm)

This commit is contained in:
Matthew Saunders Brown 2024-06-14 10:54:49 -07:00
parent eb0ddc4db2
commit 05485d5128

View File

@ -14,10 +14,10 @@ if [ "${EUID}" -ne 0 ]; then
fi
# do some basic pre-install checks - these are *not* exhaustive
os_id=`lsb_release -is`
os_release=`lsb_release -rs`
if [ $os_id != Ubuntu ] || [ $os_release != 22.04 ]; then
echo "This installer only runs on Ubuntu 22.04, bailing out."
# check for Ubuntu 22.04 (jammy) or Debian 12 (bookworm)
os_codename=`lsb_release -cs`
if [ $os_codename != jammy ] && [ $os_codename != bookworm ]; then
echo "This installer only runs on Ubuntu 22.04 (jammy) or Debian 12 (Bookworm), bailing out."
exit 1
fi
@ -44,8 +44,10 @@ if [[ -f /etc/needrestart/needrestart.conf ]]; then
fi
# set system variables
echo "vm.swappiness = 10" >> /etc/sysctl.d/60-swappiness.conf
/sbin/sysctl --quiet --system
if [[ ! -f /etc/sysctl.d/60-swappiness.conf ]]; then
echo "vm.swappiness = 1" >> /etc/sysctl.d/60-swappiness.conf
/sbin/sysctl --quiet --system
fi
# update system
DEBIAN_FRONTEND=noninteractive apt-get -y update
@ -54,21 +56,30 @@ DEBIAN_FRONTEND=noninteractive apt-get -y -o Dpkg::Options::="--force-confdef" -
DEBIAN_FRONTEND=noninteractive apt-get -y dist-upgrade
# remove unwanted packages
DEBIAN_FRONTEND=noninteractive apt-get -y purge snapd cryptsetup ufw iptables landscape-common popularity-contest
DEBIAN_FRONTEND=noninteractive apt-get -y purge snapd ufw iptables landscape-common popularity-contest
DEBIAN_FRONTEND=noninteractive apt-get -y autoremove
systemctl daemon-reload
# disable motd
sed -i 's|ENABLED=1|ENABLED=0|g' /etc/default/motd-news
chmod 644 /etc/update-motd.d/10-help-text
if [[ -f /etc/default/motd-news ]]; then
sed -i 's|ENABLED=1|ENABLED=0|g' /etc/default/motd-news
fi
if [[ -f /etc/update-motd.d/10-help-text ]]; then
chmod 644 /etc/update-motd.d/10-help-text
fi
# disable apt news
/usr/bin/pro config set apt_news=false
if [[ -x /usr/bin/pro ]]; then
/usr/bin/pro config set apt_news=false
fi
# configure unattended upgrades with automatic reboots
DEBIAN_FRONTEND=noninteractive apt-get -y install unattended-upgrades
sed -i 's|^APT::Periodic::Update-Package-Lists.*|APT::Periodic::Update-Package-Lists "1";|g' /etc/apt/apt.conf.d/10periodic
sed -i 's|^APT::Periodic::Download-Upgradeable-Packages.*|APT::Periodic::Download-Upgradeable-Packages "1";|g' /etc/apt/apt.conf.d/10periodic
sed -i 's|^APT::Periodic::AutocleanInterval.*|APT::Periodic::AutocleanInterval "7";|g' /etc/apt/apt.conf.d/10periodic
DEBIAN_FRONTEND=noninteractive apt-get -y install unattended-upgrades apt-listchanges
# /etc/apt/apt.conf.d/10periodic is part of update-notifier-common, on Ubuntu only
if [[ -f /etc/apt/apt.conf.d/10periodic ]]; thenl
sed -i 's|^APT::Periodic::Update-Package-Lists.*|APT::Periodic::Update-Package-Lists "1";|g' /etc/apt/apt.conf.d/10periodic
sed -i 's|^APT::Periodic::Download-Upgradeable-Packages.*|APT::Periodic::Download-Upgradeable-Packages "1";|g' /etc/apt/apt.conf.d/10periodic
sed -i 's|^APT::Periodic::AutocleanInterval.*|APT::Periodic::AutocleanInterval "7";|g' /etc/apt/apt.conf.d/10periodic
fi
sed -i 's|^APT::Periodic::Update-Package-Lists.*|APT::Periodic::Update-Package-Lists "1";|g' /etc/apt/apt.conf.d/20auto-upgrades
sed -i 's|^APT::Periodic::Unattended-Upgrade.*|APT::Periodic::Unattended-Upgrade "1";|g' /etc/apt/apt.conf.d/20auto-upgrades
sed -i 's|// "${distro_id}:${distro_codename}-updates";| "${distro_id}:${distro_codename}-updates";|g' /etc/apt/apt.conf.d/50unattended-upgrades
@ -124,13 +135,16 @@ sed -i 's|.*RuntimeMaxFiles=.*|RuntimeMaxFiles=10|g' /etc/systemd/journald.conf
sed -i 's|.*MaxRetentionSec=.*|MaxRetentionSec=1week|g' /etc/systemd/journald.conf
systemctl restart systemd-journald.service
# adjust rsyslogd to log cron to it's own file, and to not include cron or mail in main syslog file
sed -i 's|^#cron\.\*|cron\.\*|' /etc/rsyslog.d/50-default.conf
sed -i 's|^\*\.\*;auth,authpriv\.none|\*\.\*;auth,authpriv\.none;mail\.none;cron\.none|' /etc/rsyslog.d/50-default.conf
systemctl restart rsyslog
# adjust rsyslogd to log cron to it's own file, and to not include cron or mail in main syslog file (Ubuntu only, not on Debian 12+)
if [[ -f /etc/rsyslog.d/50-default.conf ]]; then
sed -i 's|^#cron\.\*|cron\.\*|' /etc/rsyslog.d/50-default.conf
sed -i 's|^\*\.\*;auth,authpriv\.none|\*\.\*;auth,authpriv\.none;mail\.none;cron\.none|' /etc/rsyslog.d/50-default.conf
systemctl restart rsyslog
fi
# install some handy extra packages
DEBIAN_FRONTEND=noninteractive apt-get -y install gdu exa pwgen net-tools
DEBIAN_FRONTEND=noninteractive apt-get -y install gdu exa pwgen net-tools curl sudo
# exa will be changed to eza in future releases
# install
chmod 750 sbin/*