Created
February 12, 2015 22:28
-
-
Save spuder/e30ce6388cffbae89fad to your computer and use it in GitHub Desktop.
Clean Ubuntu machines for provisioning
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Remove items used for building, since they aren't needed anymore | |
#https://github.com/riywo/packer-example/blob/master/scripts/cleanup.sh | |
set -x | |
#Stop Logging | |
service rsyslog stop | |
# Clean Logging | |
logrotate –f /etc/logrotate.conf | |
rm –f /var/log/*-???????? /var/log/*.gz | |
rm -f /var/log/dmesg.old | |
rm -rf /var/log/anaconda | |
cat /dev/null > /var/log/auth.log | |
cat /dev/null > /var/log/wtmp | |
cat /dev/null > /var/log/lastlog | |
# Remove Headers | |
#apt-get -y remove linux-headers-$(uname -r) build-essential | |
apt-get -y autoremove | |
apt-get -y clean | |
#Clean up tmp | |
rm -rf /tmp/* | |
rm -rf /var/tmp/* | |
#Clean SSH | |
rm -f /etc/ssh/*key* | |
dpkg-reconfigure openssh-server | |
#Clean root user | |
rm -f ~root/.bash_history | |
rm -rf ~root/.ssh/ | |
rm -f ~root/anaconda-ks.cfg | |
unset HISTFILE | |
# Removing leftover leases and persistent rules | |
echo "cleaning up dhcp leases" | |
if [ -d "/var/lib/dhcp" ]; then | |
# Remove leftover leases and persistent rules | |
echo "cleaning up dhcp leases" | |
rm /var/lib/dhcp/* | |
fi | |
# Make sure Udev doesn't block our network | |
# http://6.ptmc.org/?p=164 | |
echo "cleaning up udev rules" | |
rm -rf /etc/udev/rules.d/70-persistent-net.rules/* | |
rm -rf /dev/.udev/ | |
rm /lib/udev/rules.d/75-persistent-net-generator.rules | |
echo "Adding a 2 sec delay to the interface up, to make the dhclient happy" | |
echo "pre-up sleep 2" >> /etc/network/interfaces | |
exit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment