Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # Cleanup local log and cache files
- /usr/bin/find /var/lib/AccountsService/users/ -type f -delete
- /usr/bin/find /var/lib/AccountsService/icons/ -type f -delete
- /usr/bin/find /var/log/journal/ -type d -delete
- /usr/bin/find /var/backups/ -type d -delete
- /usr/bin/find /var/cache/ -type d -delete
- # Cleanup local machine information
- /usr/bin/find /etc/ssh/ -path '/etc/ssh/ssh_host_*' -delete
- /usr/bin/find /etc/udev/rules.d/ -path '/etc/udev/rules.d/*.rules' -delete
- > /etc/hostname
- > /etc/machine-id
- > /etc/salt/minion_id
- # Cleanup hosts localhost info
- /usr/bin/augtool -s <<-'EOF'
- set /files/etc/hosts/*[ipaddr = '127.0.0.1']/canonical localhost
- set /files/etc/hosts/*[ipaddr = '127.0.0.1']/alias[1] localhost.localdomain
- set /files/etc/hosts/*[ipaddr = '127.0.0.1']/alias[2] localhost4
- set /files/etc/hosts/*[ipaddr = '127.0.0.1']/alias[3] localhost4.localdomain4
- EOF
- # Cleanup root home and tmp directories
- /usr/bin/find /home/ -path '/home/?*' -delete
- /usr/bin/find /tmp/ -path '/tmp/?*' -delete
- /usr/bin/find /root/ -maxdepth 1 -type f -not -name ".*" -delete
- /usr/bin/rm -f /root/.bash_history
- /usr/bin/rm -f /root/.ssh/known_hosts
- # Cleanup Network Settings
- /usr/bin/rm -f /etc/network/interfaces
- # Rebuild initramfs after cleanup actions
- /usr/sbin/dracut -f
- cat /dev/null > ~/.bash_history
- /usr/sbin/history -c
Add Comment
Please, Sign In to add comment