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