Cleanup and update Ubuntu and Debian scripts
Some checks reported errors
continuous-integration/drone/push Build was killed

This commit is contained in:
2023-06-04 03:20:35 -04:00
parent 8e70eabfb3
commit 64a5f39b75
10 changed files with 251 additions and 119 deletions

View File

@ -10,14 +10,14 @@ echo "remove specific Linux kernels, such as linux-image-3.11.0-15-generic but k
dpkg --list \
| awk '{ print $2 }' \
| grep 'linux-image-.*-generic' \
| grep -v `uname -r` \
| grep -v "$(uname -r)" \
| xargs apt-get -y purge;
echo "remove old kernel modules packages"
dpkg --list \
| awk '{ print $2 }' \
| grep 'linux-modules-.*-generic' \
| grep -v `uname -r` \
| grep -v "$(uname -r)" \
| xargs apt-get -y purge;
echo "remove linux-source package"
@ -42,22 +42,26 @@ echo "remove X11 libraries"
apt-get -y purge libx11-data xauth libxmuu1 libxcb1 libx11-6 libxext6;
echo "remove obsolete networking packages"
apt-get -y purge ppp pppconfig pppoeconf;
apt-get -y purge ppp pppconfig pppoeconf || true;
echo "remove packages we don't need"
apt-get -y purge popularity-contest command-not-found friendly-recovery bash-completion laptop-detect motd-news-config usbutils grub-legacy-ec2
# 22.04+ don't have this
echo "remove the fonts-ubuntu-font-family-console"
apt-get -y purge fonts-ubuntu-font-family-console || true;
# 21.04+ don't have this
echo "remove the installation-report"
apt-get -y purge popularity-contest installation-report || true;
echo "remove the console font"
apt-get -y purge fonts-ubuntu-console || true;
echo "removing command-not-found-data"
# 19.10+ don't have this package so fail gracefully
apt-get -y purge command-not-found-data || true;
echo "remove unnecessary packages via snap/apt"
snap remove lxd || true;
# Exclude the files we don't need w/o uninstalling linux-firmware
echo "Setup dpkg excludes for linux-firmware"
cat <<_EOF_ | cat >> /etc/dpkg/dpkg.cfg.d/excludes
@ -86,6 +90,10 @@ find /var/log -type f -exec truncate --size=0 {} \;
echo "blank netplan machine-id (DUID) so machines get unique ID generated on boot"
truncate -s 0 /etc/machine-id
if test -f /var/lib/dbus/machine-id
then
truncate -s 0 /var/lib/dbus/machine-id # if not symlinked to "/etc/machine-id"
fi
echo "remove the contents of /tmp and /var/tmp"
rm -rf /tmp/* /var/tmp/*
@ -95,4 +103,4 @@ rm -f /var/lib/systemd/random-seed
echo "clear the history so our install isn't there"
rm -f /root/.wget-hsts
export HISTSIZE=0
export HISTSIZE=0

View File

@ -1,23 +0,0 @@
#!/bin/sh -eux
ubuntu_version="`lsb_release -r | awk '{print $2}'`";
major_version="`echo $ubuntu_version | awk -F. '{print $1}'`";
if [ "$major_version" -ge "18" ]; then
echo "Create netplan config for eth0"
cat <<EOF >/etc/netplan/01-netcfg.yaml;
network:
version: 2
ethernets:
eth0:
dhcp4: true
EOF
else
# Adding a 2 sec delay to the interface up, to make the dhclient happy
echo "pre-up sleep 2" >> /etc/network/interfaces;
fi
# Disable Predictable Network Interface names and use eth0
[ -e /etc/network/interfaces ] && sed -i 's/en[[:alnum:]]*/eth0/g' /etc/network/interfaces;
sed -i 's/GRUB_CMDLINE_LINUX="\(.*\)"/GRUB_CMDLINE_LINUX="net.ifnames=0 biosdevname=0 \1"/g' /etc/default/grub;
update-grub;

View File

@ -32,4 +32,4 @@ apt-get -y update;
echo "upgrade all installed packages incl. kernel and kernel headers"
apt-get -y dist-upgrade -o Dpkg::Options::="--force-confnew";
reboot
reboot