Advertisement
Guest User

Untitled

a guest
Dec 21st, 2014
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. #!/bin/bash
  2. # Unmount project
  3. umount /vagrant
  4. # Tell installer to keep en_US
  5. echo en_US > /etc/locale.gen
  6. # Install localepurge - NO dpkg
  7. apt-get install -y localepurge
  8. localepurge
  9.  
  10. apt-get remove -y pollinate overlayroot fonts-ubuntu-font-family-console cloud-init python-apport landscape-client juju chef open-vm-tools localepurge
  11.  
  12. # Remove APT cache
  13. apt-get clean -y
  14. apt-get autoclean -y
  15. # Remove APT files
  16. find /var/lib/apt -type f | xargs rm -f
  17. # Clear cache
  18. find /var/cache -type f -exec rm -rf {} \;
  19. # Clear docs
  20. # Leave virtualbox* - otherwise /vagrant won’t mount
  21. shopt -s extglob
  22. rm -rf /usr/share/doc/!(virtual*)
  23. rm -rf /usr/share/doc-base/*
  24. # Remove Virtualbox specific files
  25. rm -rf /usr/src/vboxguest* /usr/src/virtualbox-ose-guest*
  26. # Remove Linux headers
  27. rm -rf /usr/src/linux-headers*
  28. # Remove bash history
  29. unset HISTFILE
  30. rm -f /root/.bash_history
  31. rm -f /home/vagrant/.bash_history
  32. # Cleanup log files
  33. find /var/log -type f | while read f; do echo -ne '' > $f; done;
  34. # Zero free space to aid VM compression
  35. dd if=/dev/zero of=/EMPTY bs=1M
  36. rm -f /EMPTY
  37. dd if=/dev/zero of=/run/EMPTY bs=1M
  38. rm -f /run/EMPTY
  39. dd if=/dev/zero of=/run/lock/EMPTY bs=1M
  40. rm -f /run/lock/EMPTY
  41. dd if=/dev/zero of=/run/shm/EMPTY bs=1M
  42. rm -f /run/shm/EMPTY
  43. dd if=/dev/zero of=/run/user/EMPTY bs=1M
  44. rm -f /run/user/EMPTY
  45. dd if=/dev/zero of=/dev/EMPTY bs=1M
  46. rm -f /dev/EMPTY
  47. dd if=/dev/zero of=/sys/fs/cgroup/EMPTY bs=1M
  48. rm -f /sys/fs/cgroup/EMPTY
  49.  
  50. echo finished running clean script.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement