Guest User

Untitled

a guest
Jul 23rd, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # Cleanup local log and cache files
  4. /usr/bin/find /var/lib/AccountsService/users/ -type f -delete
  5. /usr/bin/find /var/lib/AccountsService/icons/ -type f -delete
  6. /usr/bin/find /var/log/journal/ -type d -delete
  7. /usr/bin/find /var/backups/ -type d -delete
  8. /usr/bin/find /var/cache/ -type d -delete
  9.  
  10. # Cleanup local machine information
  11. /usr/bin/find /etc/ssh/ -path '/etc/ssh/ssh_host_*' -delete
  12. /usr/bin/find /etc/udev/rules.d/ -path '/etc/udev/rules.d/*.rules' -delete
  13.  
  14. > /etc/hostname
  15. > /etc/machine-id
  16. > /etc/salt/minion_id
  17.  
  18. # Cleanup hosts localhost info
  19. /usr/bin/augtool -s <<-'EOF'
  20. set /files/etc/hosts/*[ipaddr = '127.0.0.1']/canonical localhost
  21. set /files/etc/hosts/*[ipaddr = '127.0.0.1']/alias[1] localhost.localdomain
  22. set /files/etc/hosts/*[ipaddr = '127.0.0.1']/alias[2] localhost4
  23. set /files/etc/hosts/*[ipaddr = '127.0.0.1']/alias[3] localhost4.localdomain4
  24. EOF
  25.  
  26. # Cleanup root home and tmp directories
  27. /usr/bin/find /home/ -path '/home/?*' -delete
  28. /usr/bin/find /tmp/ -path '/tmp/?*' -delete
  29. /usr/bin/find /root/ -maxdepth 1 -type f -not -name ".*" -delete
  30. /usr/bin/rm -f /root/.bash_history
  31. /usr/bin/rm -f /root/.ssh/known_hosts
  32.  
  33. # Cleanup Network Settings
  34. /usr/bin/rm -f /etc/network/interfaces
  35.  
  36. # Rebuild initramfs after cleanup actions
  37. /usr/sbin/dracut -f
  38.  
  39. cat /dev/null > ~/.bash_history
  40.  
  41. /usr/sbin/history -c
Add Comment
Please, Sign In to add comment