blob: ba69e3c53f3e5cfbc4880f9f535b9c64b9c10ffd [file] [log] [blame]
Richard Felkld59c5652018-02-08 13:14:05 +01001#!/bin/bash -xe
azvyagintsev4053eb22018-03-29 16:21:51 +03002
Richard Felkld59c5652018-02-08 13:14:05 +01003apt-get -y autoremove --purge
4apt-get -y clean
Richard Felkld59c5652018-02-08 13:14:05 +01005
azvyagintsev29410ee2018-07-12 20:02:30 +03006rm -rf /var/lib/apt/lists/*
7rm -rv /etc/apt/sources.list.d/* || true
8echo > /etc/apt/sources.list || true
9rm -vf /usr/sbin/policy-rc.d || true
Richard Felkld59c5652018-02-08 13:14:05 +010010
11echo "cleaning up hostname"
azvyagintsevc86fbaf2018-03-02 18:57:03 +020012sed -i "/.*ubuntu.*/d" /etc/hosts
13sed -i "/.*salt.*/d" /etc/hosts
Richard Felkld59c5652018-02-08 13:14:05 +010014
15echo "cleaning up guest additions"
16rm -rf VBoxGuestAdditions_*.iso VBoxGuestAdditions_*.iso.? || true
17
18echo "cleaning up dhcp leases"
19rm -rf /var/lib/dhcp/* || true
azvyagintsev29410ee2018-07-12 20:02:30 +030020rm -rfv /var/lib/ntp/ntp.conf.dhcp || true
Richard Felkld59c5652018-02-08 13:14:05 +010021
22echo "cleaning up udev rules"
azvyagintsev29410ee2018-07-12 20:02:30 +030023rm -fv /etc/udev/rules.d/70-persistent-net.rules || true
Richard Felkld59c5652018-02-08 13:14:05 +010024rm -rf /dev/.udev/ || true
azvyagintsev29410ee2018-07-12 20:02:30 +030025rm -fv /lib/udev/rules.d/75-persistent-net-generator.rules || true
Richard Felkld59c5652018-02-08 13:14:05 +010026
27echo "cleaning up minion_id for salt"
azvyagintsev29410ee2018-07-12 20:02:30 +030028rm -vf /etc/salt/minion_id || true
Richard Felkld59c5652018-02-08 13:14:05 +010029
Richard Felkl47757902018-03-02 22:44:43 +010030echo "cleaning up resolvconf"
azvyagintsev4053eb22018-03-29 16:21:51 +030031sed -i '/172\.18\.208\.44/d' /etc/resolvconf/resolv.conf.d/base
32
azvyagintsev29410ee2018-07-12 20:02:30 +030033# Remove flags
34rm -v /done_ubuntu_base || true
35rm -v /done_ubuntu_salt_bootstrap || true
36
azvyagintsevcb4c35d2018-07-18 19:31:35 +030037# Force cleanup cloud-init data, if it was
38if [[ -d '/var/lib/cloud/' ]] ; then
39 rm -rf /var/lib/cloud/* || true
azvyagintsevbadeb372018-07-19 20:01:53 +030040 cloud-init clean || true
azvyagintsevcb4c35d2018-07-18 19:31:35 +030041 echo > /var/log/cloud-init-output.log || true
42 echo > /var/log/cloud-init.log || true
43fi
44
azvyagintsev4053eb22018-03-29 16:21:51 +030045# Clear\drop cache's
46sync
47echo 3 > /proc/sys/vm/drop_caches