81 lines
2.2 KiB
Bash
81 lines
2.2 KiB
Bash
#!/usr/bin/env bash
|
|
|
|
echo "Starting system cleanup for image preparation..."
|
|
|
|
# Reset to headless screen driver
|
|
rm /etc/X11/xorg.conf.d/10-*.conf
|
|
cp /home/stormux/.local/files/10-headless.conf /etc/X11/xorg.conf.d/
|
|
|
|
find / -type d -name "__pycache__" -exec rm -rfv "{}" +
|
|
|
|
# Clear package caches
|
|
pacman -Scc --noconfirm
|
|
rm -rfv /home/stormux/.cache/yay
|
|
|
|
# Remove files but keep directory structure
|
|
find /home/stormux/Roms -type f -delete
|
|
|
|
# Remove All except parent directory
|
|
find /home/stormux/Downloads -mindepth 1 -delete
|
|
find /home/stormux/Music -mindepth 1 -delete
|
|
rm -fv /home/stormux/.config/stormux/*.conf
|
|
|
|
# Clean user caches and temp files
|
|
rm -rfv /home/stormux/.cache/*
|
|
|
|
# Clean browser data
|
|
rm -rfv /home/stormux/.config/BraveSoftware
|
|
|
|
# Clean bash history
|
|
rm -fv /home/stormux/.bash_histor*
|
|
rm -fv /root/.bash_histor*
|
|
|
|
# Reset machine
|
|
rm -fv /etc/NetworkManager/system-connections/*
|
|
rm -fv /etc/ssh/ssh_host_*
|
|
rm -rfv /tmp/*
|
|
rm -rfv /var/log/*
|
|
rm -fv /root/.ssh/known_hosts /home/*/.ssh/known_hosts
|
|
rm -fv /var/lib/dhcp/* /var/lib/NetworkManager/*lease*
|
|
rm -fv /etc/machine-id
|
|
|
|
|
|
# Remove minidlna data
|
|
rm -rfv /var/cache/private/minidlna
|
|
|
|
# Make sure we don't ship for-pay games or save files
|
|
rm -rfv /home/stormux/.local/games/periphery-synthetic-ep
|
|
rm -rfv /home/stormux/.local/games/SideParty
|
|
rm -rfv /home/stormux/.local/games/ToyMania
|
|
rm -fv /home/stormux/.local/games/Crazy-Party-beta82/save.bin
|
|
rm -rfv /home/stormux/.local/games/Upheaval
|
|
rm -rfv /home/stormux/.local/games/Warsim
|
|
rm -rfv "/home/stormux/.local/share/2MB Solutions/MineRacer"
|
|
|
|
# Disable services
|
|
systemctl disable bluetooth.service
|
|
systemctl disable fstrim.timer
|
|
systemctl disable sshd.service
|
|
|
|
# Restore defaults
|
|
cp /etc/speech-dispatcher/speechd.conf.bak /etc/speech-dispatcher/speechd.conf
|
|
touch /home/stormux.firstboot
|
|
|
|
if [[ "$1" == "-0" ]]; then
|
|
# Zero fill free space to improve compression
|
|
echo "Zero-filling free space (this may take a while)..."
|
|
sudo dd if=/dev/zero of=/zero.fill bs=1M status=progress || true
|
|
sudo rm -f /zero.fill
|
|
fi
|
|
|
|
# Sync to ensure all writes are committed to disk
|
|
echo "Syncing disks..."
|
|
sync
|
|
|
|
# Clear the journal
|
|
journalctl --rotate
|
|
journalctl --vacuum-time=1s
|
|
|
|
echo "Cleanup complete. Ready for imaging."
|
|
exit 0
|