blob: 70b326bdb50127798907f2dc9a18a33babf394af [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
azvyagintsev4b5603e2018-09-14 16:33:14 +03008rm -rv /etc/apt/preferences.d/* || true
azvyagintsev29410ee2018-07-12 20:02:30 +03009echo > /etc/apt/sources.list || true
10rm -vf /usr/sbin/policy-rc.d || true
Richard Felkld59c5652018-02-08 13:14:05 +010011
12echo "cleaning up hostname"
azvyagintsevc86fbaf2018-03-02 18:57:03 +020013sed -i "/.*ubuntu.*/d" /etc/hosts
14sed -i "/.*salt.*/d" /etc/hosts
Richard Felkld59c5652018-02-08 13:14:05 +010015
16echo "cleaning up guest additions"
17rm -rf VBoxGuestAdditions_*.iso VBoxGuestAdditions_*.iso.? || true
18
19echo "cleaning up dhcp leases"
20rm -rf /var/lib/dhcp/* || true
azvyagintsev29410ee2018-07-12 20:02:30 +030021rm -rfv /var/lib/ntp/ntp.conf.dhcp || true
Richard Felkld59c5652018-02-08 13:14:05 +010022
23echo "cleaning up udev rules"
azvyagintsev29410ee2018-07-12 20:02:30 +030024rm -fv /etc/udev/rules.d/70-persistent-net.rules || true
Richard Felkld59c5652018-02-08 13:14:05 +010025rm -rf /dev/.udev/ || true
azvyagintsev29410ee2018-07-12 20:02:30 +030026rm -fv /lib/udev/rules.d/75-persistent-net-generator.rules || true
Richard Felkld59c5652018-02-08 13:14:05 +010027
28echo "cleaning up minion_id for salt"
azvyagintsev29410ee2018-07-12 20:02:30 +030029rm -vf /etc/salt/minion_id || true
Richard Felkld59c5652018-02-08 13:14:05 +010030
Richard Felkl47757902018-03-02 22:44:43 +010031echo "cleaning up resolvconf"
azvyagintsev4053eb22018-03-29 16:21:51 +030032sed -i '/172\.18\.208\.44/d' /etc/resolvconf/resolv.conf.d/base
33
Petr Ruzicka24be3102018-08-15 13:39:15 +020034echo "cleaning up /var/cache/{apt,salt}/*"
35rm -rf /var/cache/{apt,salt}/* || true
36
azvyagintsev29410ee2018-07-12 20:02:30 +030037# Remove flags
38rm -v /done_ubuntu_base || true
39rm -v /done_ubuntu_salt_bootstrap || true
40
azvyagintsevcb4c35d2018-07-18 19:31:35 +030041# Force cleanup cloud-init data, if it was
42if [[ -d '/var/lib/cloud/' ]] ; then
43 rm -rf /var/lib/cloud/* || true
azvyagintsevbadeb372018-07-19 20:01:53 +030044 cloud-init clean || true
azvyagintsevcb4c35d2018-07-18 19:31:35 +030045 echo > /var/log/cloud-init-output.log || true
46 echo > /var/log/cloud-init.log || true
47fi
48
Ivan Berezovskiy3242a9a2018-09-17 19:04:19 +040049cat << EOF >> /etc/network/interfaces
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
54auto lo
55iface 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
61source /etc/network/interfaces.d/*.cfg
62EOF
63
azvyagintsev4053eb22018-03-29 16:21:51 +030064# Clear\drop cache's
65sync
66echo 3 > /proc/sys/vm/drop_caches