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 fi
# do some basic pre-install checks - these are *not* exhaustive # do some basic pre-install checks - these are *not* exhaustive
os_id=`lsb_release -is` # check for Ubuntu 22.04 (jammy) or Debian 12 (bookworm)
os_release=`lsb_release -rs` os_codename=`lsb_release -cs`
if [ $os_id != Ubuntu ] || [ $os_release != 22.04 ]; then if [ $os_codename != jammy ] && [ $os_codename != bookworm ]; then
echo "This installer only runs on Ubuntu 22.04, bailing out." echo "This installer only runs on Ubuntu 22.04 (jammy) or Debian 12 (Bookworm), bailing out."
exit 1 exit 1
fi fi
@ -44,8 +44,10 @@ if [[ -f /etc/needrestart/needrestart.conf ]]; then
fi fi
# set system variables # set system variables
echo "vm.swappiness = 10" >> /etc/sysctl.d/60-swappiness.conf if [[ ! -f /etc/sysctl.d/60-swappiness.conf ]]; then
/sbin/sysctl --quiet --system echo "vm.swappiness = 1" >> /etc/sysctl.d/60-swappiness.conf
/sbin/sysctl --quiet --system
fi
# update system # update system
DEBIAN_FRONTEND=noninteractive apt-get -y update 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 DEBIAN_FRONTEND=noninteractive apt-get -y dist-upgrade
# remove unwanted packages # 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 DEBIAN_FRONTEND=noninteractive apt-get -y autoremove
systemctl daemon-reload systemctl daemon-reload
# disable motd # disable motd
sed -i 's|ENABLED=1|ENABLED=0|g' /etc/default/motd-news if [[ -f /etc/default/motd-news ]]; then
chmod 644 /etc/update-motd.d/10-help-text 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 # 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 # configure unattended upgrades with automatic reboots
DEBIAN_FRONTEND=noninteractive apt-get -y install unattended-upgrades DEBIAN_FRONTEND=noninteractive apt-get -y install unattended-upgrades apt-listchanges
sed -i 's|^APT::Periodic::Update-Package-Lists.*|APT::Periodic::Update-Package-Lists "1";|g' /etc/apt/apt.conf.d/10periodic # /etc/apt/apt.conf.d/10periodic is part of update-notifier-common, on Ubuntu only
sed -i 's|^APT::Periodic::Download-Upgradeable-Packages.*|APT::Periodic::Download-Upgradeable-Packages "1";|g' /etc/apt/apt.conf.d/10periodic if [[ -f /etc/apt/apt.conf.d/10periodic ]]; thenl
sed -i 's|^APT::Periodic::AutocleanInterval.*|APT::Periodic::AutocleanInterval "7";|g' /etc/apt/apt.conf.d/10periodic 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::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|^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 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 sed -i 's|.*MaxRetentionSec=.*|MaxRetentionSec=1week|g' /etc/systemd/journald.conf
systemctl restart systemd-journald.service 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 # 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+)
sed -i 's|^#cron\.\*|cron\.\*|' /etc/rsyslog.d/50-default.conf if [[ -f /etc/rsyslog.d/50-default.conf ]]; then
sed -i 's|^\*\.\*;auth,authpriv\.none|\*\.\*;auth,authpriv\.none;mail\.none;cron\.none|' /etc/rsyslog.d/50-default.conf sed -i 's|^#cron\.\*|cron\.\*|' /etc/rsyslog.d/50-default.conf
systemctl restart rsyslog 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 # 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 # install
chmod 750 sbin/* chmod 750 sbin/*