azvyagintsev | 9a1737f | 2019-03-11 15:44:54 +0200 | [diff] [blame] | 1 | #!/bin/bash -xe |
| 2 | |
| 3 | apt-get -y remove --purge unattended-upgrades || true |
| 4 | apt-get -y autoremove --purge |
| 5 | apt-get -y clean |
| 6 | |
| 7 | rm -rf /var/lib/apt/lists/* || true |
| 8 | rm -rv /etc/apt/sources.list.d/* || true |
| 9 | rm -rv /etc/apt/preferences.d/* || true |
| 10 | echo > /etc/apt/sources.list || true |
| 11 | rm -vf /usr/sbin/policy-rc.d || true |
| 12 | |
| 13 | echo "cleaning up hostname" |
| 14 | sed -i "/.*ubuntu.*/d" /etc/hosts |
| 15 | sed -i "/.*salt.*/d" /etc/hosts |
| 16 | |
| 17 | echo "cleaning up dhcp leases" |
| 18 | rm -rf /var/lib/dhcp/* || true |
| 19 | rm -rfv /var/lib/ntp/ntp.conf.dhcp || true |
| 20 | |
| 21 | echo "cleaning up udev rules" |
| 22 | rm -fv /etc/udev/rules.d/70-persistent-net.rules || true |
| 23 | rm -rf /dev/.udev/ || true |
| 24 | rm -fv /lib/udev/rules.d/75-persistent-net-generator.rules || true |
| 25 | |
| 26 | echo "cleaning up minion_id for salt" |
| 27 | rm -vf /etc/salt/minion_id || true |
| 28 | |
| 29 | echo "cleaning up /var/cache/{apt,salt}/*" |
| 30 | rm -rf /var/cache/{apt,salt}/* || true |
| 31 | |
| 32 | rm -rf /root/.cache || true |
| 33 | rm -rf /root/.ssh/known_hosts || true |
| 34 | |
| 35 | # Remove flags |
| 36 | rm -v /done_ubuntu_base || true |
| 37 | rm -v /done_ubuntu_salt_bootstrap || true |
| 38 | |
| 39 | # Force cleanup cloud-init data, if it was |
| 40 | if [[ -d '/var/lib/cloud/' ]] ; then |
| 41 | rm -rf /var/lib/cloud/* || true |
| 42 | cloud-init clean || true |
| 43 | echo > /var/log/cloud-init-output.log || true |
| 44 | echo > /var/log/cloud-init.log || true |
| 45 | fi |
| 46 | |
| 47 | # Clear\drop cache's |
| 48 | sync |
| 49 | echo 3 > /proc/sys/vm/drop_caches |