don't assume root partition; cleanup

This commit is contained in:
Kaiwan N Billimoria
2023-12-06 09:11:01 +05:30
parent 3401f2f57e
commit 5b5196c531

View File

@@ -25,14 +25,17 @@ runcmd()
{
[[ $# -eq 0 ]] && return
echo "$@"
eval "$@" || die "failed"
eval "$@" || echo "*** failed ***"
}
#--- 'main'
echo "$(date): beginning installation of required packages..."
# ASSUMPTION! root partition / is on /dev/sda1
spc1=$(df|grep sda1|awk '{print $3}')
echo "Disk space in use currently: ${spc1} KB"
# Get the root partition; we ASSUME you're using it...
ROOT_PART=$(df |grep -w "/"|awk '{print $1}')
[[ -z "${ROOT_PART}" ]] && die "Couldn't get root partition"
spc1=$(df|grep ${ROOT_PART}|awk '{print $3}')
[[ ! -z "${spc1}" ]] && echo "Disk space in use currently: ${spc1} KB"
runcmd sudo apt update
echo "-----------------------------------------------------------------------"
@@ -57,7 +60,7 @@ runcmd sudo apt install -y \
fakeroot flawfinder \
git gnome-system-monitor gnuplot hwloc indent kmod \
libnuma-dev linux-headers-$(uname -r) linux-tools-$(uname -r) \
man-db net-tools numactl openjdk-18-jre \
man-db net-tools numactl openjdk-22-jdk \
perf-tools-unstable procps psmisc python3-distutils \
rt-tests smem sparse stress stress-ng sysfsutils \
tldr-py trace-cmd tree tuna virt-what yad
@@ -72,12 +75,13 @@ echo "-----------------------------------------------------------------------"
# libelf-dev elfutils-libelf-devel
#---
# Add yourself to the vboxsf group (to gain access to VirtualBox shared folders);
# will require you to log out and back in (or even reboot) to take effect
# As an aside, lets add ourseleves to the vboxsf group (to gain access to
# VirtualBox shared folders); will require you to log out and back in
# (or even reboot) to take effect
groups |grep -q -w vboxsf || runcmd sudo usermod -G vboxsf -a ${USER}
spc2=$(df|grep sda1|awk '{print $3}')
echo "Difference : ($spc2 - $spc1) : $((spc2-spc1)) KB"
runcmd sudo apt autoremove
spc2=$(df|grep ${ROOT_PART}|awk '{print $3}')
[[ ! -z "${spc1}" && ! -z "${spc2}" ]] && echo "Disk space difference : ($spc2 - $spc1) : $((spc2-spc1)) KB"
exit 0