#!/bin/bash
#
echo "removing various cruft before saving sd card";
rm /home/pi/.jmri/log/*;
rm /home/pi/.bash_history;
rm /home/pi/JMRI_UserFiles/roster.xml;
rm -rf /home/pi/.cache/*;
rm -rf /home/pi/JMRI_UserFiles/roster/*;
rm -rf /home/pi/Downloads/*;
rm -rf /home/pi/.local/share/Trash/files/*;
rm -rf /home/pi/.local/share/Trash/info/*;
find /home/pi/.jmri -name "*.bak" -type f -delete;
sudo apt-get remove scratch scratch2 sonic-pi nodered vlc -y; 
sudo apt-get remove --purge wolfram-engine -y;
sudo apt autoremove -y;
sudo apt clean;
echo "setting empty space to zeros on the boot partition to improve compression. takes quite a while....";
sudo dd if=/dev/zero of=/boot/zero.file status=progress bs=512b iflag=fullblock;sync;sudo rm /boot/zero.file;
echo "setting empty space to zeros on the root partition to improve compression. takes even longer....";
sudo dd if=/dev/zero of=~/zero.file status=progress bs=512b iflag=fullblock;sync;sudo rm ~/zero.file;
echo "Completed";
