From 4b9cac76279767960507f2d01ff1ebd27c2eed96 Mon Sep 17 00:00:00 2001 From: Storm Dragon Date: Mon, 14 Jul 2025 08:46:48 -0400 Subject: [PATCH] cleanup and update scripts added. --- root/live-update.sh | 16 ++++++++++ root/sanitize.sh | 75 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 91 insertions(+) create mode 100644 root/live-update.sh create mode 100644 root/sanitize.sh diff --git a/root/live-update.sh b/root/live-update.sh new file mode 100644 index 0000000..5f6c156 --- /dev/null +++ b/root/live-update.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash + +gitUrl="https://git.stormux.org/storm/gaming-image-files" +gitPath="${gitUrl##*/}" +pushd /tmp +sudo -u stormux git clone "${gitUrl}" +pushd "${gitPath}" +# Handle home directory files (preserve user ownership) +find . -path './.git' -prune -o -path './home/stormux/*' -type f -exec bash -c 'for i ; do cp -av "${i}" "/${i#./}";done' _ {} \; +# Handle system files (will be root-owned) +find . -path './.git' -prune -o -path './home' -prune -o -type f -exec bash -c 'for i ; do cp -v "${i}" "/${i#./}";done' _ {} \; +popd +rm -rf "${gitPath}" +popd + +exit 0 diff --git a/root/sanitize.sh b/root/sanitize.sh new file mode 100644 index 0000000..3dd7e9f --- /dev/null +++ b/root/sanitize.sh @@ -0,0 +1,75 @@ +#!/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 + +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 + +echo "Cleanup complete. Ready for imaging." +exit 0