Richard Felkl | d59c565 | 2018-02-08 13:14:05 +0100 | [diff] [blame] | 1 | #!/bin/bash -xe |
azvyagintsev | 4053eb2 | 2018-03-29 16:21:51 +0300 | [diff] [blame] | 2 | |
Richard Felkl | d59c565 | 2018-02-08 13:14:05 +0100 | [diff] [blame] | 3 | apt-get -y autoremove --purge |
| 4 | apt-get -y clean |
Richard Felkl | d59c565 | 2018-02-08 13:14:05 +0100 | [diff] [blame] | 5 | |
azvyagintsev | 29410ee | 2018-07-12 20:02:30 +0300 | [diff] [blame] | 6 | rm -rf /var/lib/apt/lists/* |
| 7 | rm -rv /etc/apt/sources.list.d/* || true |
| 8 | echo > /etc/apt/sources.list || true |
| 9 | rm -vf /usr/sbin/policy-rc.d || true |
Richard Felkl | d59c565 | 2018-02-08 13:14:05 +0100 | [diff] [blame] | 10 | |
| 11 | echo "cleaning up hostname" |
azvyagintsev | c86fbaf | 2018-03-02 18:57:03 +0200 | [diff] [blame] | 12 | sed -i "/.*ubuntu.*/d" /etc/hosts |
| 13 | sed -i "/.*salt.*/d" /etc/hosts |
Richard Felkl | d59c565 | 2018-02-08 13:14:05 +0100 | [diff] [blame] | 14 | |
| 15 | echo "cleaning up guest additions" |
| 16 | rm -rf VBoxGuestAdditions_*.iso VBoxGuestAdditions_*.iso.? || true |
| 17 | |
| 18 | echo "cleaning up dhcp leases" |
| 19 | rm -rf /var/lib/dhcp/* || true |
azvyagintsev | 29410ee | 2018-07-12 20:02:30 +0300 | [diff] [blame] | 20 | rm -rfv /var/lib/ntp/ntp.conf.dhcp || true |
Richard Felkl | d59c565 | 2018-02-08 13:14:05 +0100 | [diff] [blame] | 21 | |
| 22 | echo "cleaning up udev rules" |
azvyagintsev | 29410ee | 2018-07-12 20:02:30 +0300 | [diff] [blame] | 23 | rm -fv /etc/udev/rules.d/70-persistent-net.rules || true |
Richard Felkl | d59c565 | 2018-02-08 13:14:05 +0100 | [diff] [blame] | 24 | rm -rf /dev/.udev/ || true |
azvyagintsev | 29410ee | 2018-07-12 20:02:30 +0300 | [diff] [blame] | 25 | rm -fv /lib/udev/rules.d/75-persistent-net-generator.rules || true |
Richard Felkl | d59c565 | 2018-02-08 13:14:05 +0100 | [diff] [blame] | 26 | |
| 27 | echo "cleaning up minion_id for salt" |
azvyagintsev | 29410ee | 2018-07-12 20:02:30 +0300 | [diff] [blame] | 28 | rm -vf /etc/salt/minion_id || true |
Richard Felkl | d59c565 | 2018-02-08 13:14:05 +0100 | [diff] [blame] | 29 | |
Richard Felkl | 4775790 | 2018-03-02 22:44:43 +0100 | [diff] [blame] | 30 | echo "cleaning up resolvconf" |
azvyagintsev | 4053eb2 | 2018-03-29 16:21:51 +0300 | [diff] [blame] | 31 | sed -i '/172\.18\.208\.44/d' /etc/resolvconf/resolv.conf.d/base |
| 32 | |
azvyagintsev | 29410ee | 2018-07-12 20:02:30 +0300 | [diff] [blame] | 33 | # Remove flags |
| 34 | rm -v /done_ubuntu_base || true |
| 35 | rm -v /done_ubuntu_salt_bootstrap || true |
| 36 | |
azvyagintsev | cb4c35d | 2018-07-18 19:31:35 +0300 | [diff] [blame] | 37 | # Force cleanup cloud-init data, if it was |
| 38 | if [[ -d '/var/lib/cloud/' ]] ; then |
| 39 | rm -rf /var/lib/cloud/* || true |
azvyagintsev | badeb37 | 2018-07-19 20:01:53 +0300 | [diff] [blame] | 40 | cloud-init clean || true |
azvyagintsev | cb4c35d | 2018-07-18 19:31:35 +0300 | [diff] [blame] | 41 | echo > /var/log/cloud-init-output.log || true |
| 42 | echo > /var/log/cloud-init.log || true |
| 43 | fi |
| 44 | |
azvyagintsev | 4053eb2 | 2018-03-29 16:21:51 +0300 | [diff] [blame] | 45 | # Clear\drop cache's |
| 46 | sync |
| 47 | echo 3 > /proc/sys/vm/drop_caches |