ichadhr
11/10/2016 - 11:06 AM

Vagrant Box CleanUp

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