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 | |
azvyagintsev | e142e75 | 2018-10-18 13:53:04 +0300 | [diff] [blame] | 3 | apt-get -y remove --purge unattended-upgrades || true |
Richard Felkl | d59c565 | 2018-02-08 13:14:05 +0100 | [diff] [blame] | 4 | apt-get -y autoremove --purge |
| 5 | apt-get -y clean |
Richard Felkl | d59c565 | 2018-02-08 13:14:05 +0100 | [diff] [blame] | 6 | |
azvyagintsev | bfd6170 | 2018-10-26 14:18:33 +0300 | [diff] [blame] | 7 | rm -rf /var/lib/apt/lists/* || true |
azvyagintsev | 29410ee | 2018-07-12 20:02:30 +0300 | [diff] [blame] | 8 | rm -rv /etc/apt/sources.list.d/* || true |
azvyagintsev | 4b5603e | 2018-09-14 16:33:14 +0300 | [diff] [blame] | 9 | rm -rv /etc/apt/preferences.d/* || true |
azvyagintsev | 29410ee | 2018-07-12 20:02:30 +0300 | [diff] [blame] | 10 | echo > /etc/apt/sources.list || true |
| 11 | rm -vf /usr/sbin/policy-rc.d || true |
Richard Felkl | d59c565 | 2018-02-08 13:14:05 +0100 | [diff] [blame] | 12 | |
| 13 | echo "cleaning up hostname" |
azvyagintsev | c86fbaf | 2018-03-02 18:57:03 +0200 | [diff] [blame] | 14 | sed -i "/.*ubuntu.*/d" /etc/hosts |
| 15 | sed -i "/.*salt.*/d" /etc/hosts |
Richard Felkl | d59c565 | 2018-02-08 13:14:05 +0100 | [diff] [blame] | 16 | |
| 17 | echo "cleaning up guest additions" |
| 18 | rm -rf VBoxGuestAdditions_*.iso VBoxGuestAdditions_*.iso.? || true |
| 19 | |
| 20 | echo "cleaning up dhcp leases" |
| 21 | rm -rf /var/lib/dhcp/* || true |
azvyagintsev | 29410ee | 2018-07-12 20:02:30 +0300 | [diff] [blame] | 22 | rm -rfv /var/lib/ntp/ntp.conf.dhcp || true |
Richard Felkl | d59c565 | 2018-02-08 13:14:05 +0100 | [diff] [blame] | 23 | |
| 24 | echo "cleaning up udev rules" |
azvyagintsev | 29410ee | 2018-07-12 20:02:30 +0300 | [diff] [blame] | 25 | rm -fv /etc/udev/rules.d/70-persistent-net.rules || true |
Richard Felkl | d59c565 | 2018-02-08 13:14:05 +0100 | [diff] [blame] | 26 | rm -rf /dev/.udev/ || true |
azvyagintsev | 29410ee | 2018-07-12 20:02:30 +0300 | [diff] [blame] | 27 | rm -fv /lib/udev/rules.d/75-persistent-net-generator.rules || true |
Richard Felkl | d59c565 | 2018-02-08 13:14:05 +0100 | [diff] [blame] | 28 | |
| 29 | echo "cleaning up minion_id for salt" |
azvyagintsev | 29410ee | 2018-07-12 20:02:30 +0300 | [diff] [blame] | 30 | rm -vf /etc/salt/minion_id || true |
Richard Felkl | d59c565 | 2018-02-08 13:14:05 +0100 | [diff] [blame] | 31 | |
Richard Felkl | 4775790 | 2018-03-02 22:44:43 +0100 | [diff] [blame] | 32 | echo "cleaning up resolvconf" |
azvyagintsev | 4053eb2 | 2018-03-29 16:21:51 +0300 | [diff] [blame] | 33 | sed -i '/172\.18\.208\.44/d' /etc/resolvconf/resolv.conf.d/base |
| 34 | |
Petr Ruzicka | 24be310 | 2018-08-15 13:39:15 +0200 | [diff] [blame] | 35 | echo "cleaning up /var/cache/{apt,salt}/*" |
| 36 | rm -rf /var/cache/{apt,salt}/* || true |
| 37 | |
azvyagintsev | bfd6170 | 2018-10-26 14:18:33 +0300 | [diff] [blame] | 38 | rm -rf /root/.cache || true |
| 39 | rm -rf /root/.ssh/known_hosts || true |
| 40 | |
azvyagintsev | 29410ee | 2018-07-12 20:02:30 +0300 | [diff] [blame] | 41 | # Remove flags |
| 42 | rm -v /done_ubuntu_base || true |
| 43 | rm -v /done_ubuntu_salt_bootstrap || true |
| 44 | |
azvyagintsev | cb4c35d | 2018-07-18 19:31:35 +0300 | [diff] [blame] | 45 | # Force cleanup cloud-init data, if it was |
| 46 | if [[ -d '/var/lib/cloud/' ]] ; then |
| 47 | rm -rf /var/lib/cloud/* || true |
azvyagintsev | badeb37 | 2018-07-19 20:01:53 +0300 | [diff] [blame] | 48 | cloud-init clean || true |
azvyagintsev | cb4c35d | 2018-07-18 19:31:35 +0300 | [diff] [blame] | 49 | echo > /var/log/cloud-init-output.log || true |
| 50 | echo > /var/log/cloud-init.log || true |
| 51 | fi |
| 52 | |
Ivan Berezovskiy | 2217246 | 2018-09-18 15:41:39 +0400 | [diff] [blame] | 53 | cat << EOF > /etc/network/interfaces |
Ivan Berezovskiy | 3242a9a | 2018-09-17 19:04:19 +0400 | [diff] [blame] | 54 | # This file describes the network interfaces available on your system |
| 55 | # and how to activate them. For more information, see interfaces(5). |
| 56 | |
| 57 | # The loopback network interface |
| 58 | auto lo |
| 59 | iface lo inet loopback |
| 60 | |
| 61 | # Source interfaces |
| 62 | # Please check /etc/network/interfaces.d before changing this file |
| 63 | # as interfaces may have been defined in /etc/network/interfaces.d |
| 64 | # See LP: #1262951 |
| 65 | source /etc/network/interfaces.d/*.cfg |
| 66 | EOF |
| 67 | |
azvyagintsev | 4053eb2 | 2018-03-29 16:21:51 +0300 | [diff] [blame] | 68 | # Clear\drop cache's |
| 69 | sync |
| 70 | echo 3 > /proc/sys/vm/drop_caches |