Skip to content

Instantly share code, notes, and snippets.

@ichadhr
Last active November 10, 2016 11:20
Show Gist options
  • Save ichadhr/2b3fa77b5f9e56740003e539e4e53084 to your computer and use it in GitHub Desktop.
Save ichadhr/2b3fa77b5f9e56740003e539e4e53084 to your computer and use it in GitHub Desktop.
Vagrant Box CleanUp
#!/bin/bash
echo "Make user as root"
sudo -s -- <<EOF
echo "Clean system cache.."
apt-get clean
apt-get autoclean
apt-get autoremove
echo "Reducing final box"
dd if=/dev/zero of=/EMPTY bs=1M
rm -f /EMPTY
find /var/cache -type f -exec rm -rf {} \;
rm -f ~/.zsh_history
echo "Done. Switch to normal user"
EOF
echo "Get public keys"
wget --no-check-certificate https://raw.github.com/mitchellh/vagrant/master/keys/vagrant.pub -O /home/vagrant/.ssh/authorized_keys
echo "Shutdown VM.."
sudo -s -- <<EOF
rm /home/vagrant/.zsh_history
shutdown -h now
EOF
exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment