blob: 8f49d30eb100c84f2e6445d284ea60560997ed82 [file] [log] [blame]
Richard Felkld59c5652018-02-08 13:14:05 +01001#!/bin/bash -xe
azvyagintsev4053eb22018-03-29 16:21:51 +03002
azvyagintseve142e752018-10-18 13:53:04 +03003apt-get -y remove --purge unattended-upgrades || true
Richard Felkld59c5652018-02-08 13:14:05 +01004apt-get -y autoremove --purge
5apt-get -y clean
Richard Felkld59c5652018-02-08 13:14:05 +01006
azvyagintsev29410ee2018-07-12 20:02:30 +03007rm -rf /var/lib/apt/lists/*
8rm -rv /etc/apt/sources.list.d/* || true
azvyagintsev4b5603e2018-09-14 16:33:14 +03009rm -rv /etc/apt/preferences.d/* || true
azvyagintsev29410ee2018-07-12 20:02:30 +030010echo > /etc/apt/sources.list || true
11rm -vf /usr/sbin/policy-rc.d || true
Richard Felkld59c5652018-02-08 13:14:05 +010012
13echo "cleaning up hostname"
azvyagintsevc86fbaf2018-03-02 18:57:03 +020014sed -i "/.*ubuntu.*/d" /etc/hosts
15sed -i "/.*salt.*/d" /etc/hosts
Richard Felkld59c5652018-02-08 13:14:05 +010016
17echo "cleaning up guest additions"
18rm -rf VBoxGuestAdditions_*.iso VBoxGuestAdditions_*.iso.? || true
19
20echo "cleaning up dhcp leases"
21rm -rf /var/lib/dhcp/* || true
azvyagintsev29410ee2018-07-12 20:02:30 +030022rm -rfv /var/lib/ntp/ntp.conf.dhcp || true
Richard Felkld59c5652018-02-08 13:14:05 +010023
24echo "cleaning up udev rules"
azvyagintsev29410ee2018-07-12 20:02:30 +030025rm -fv /etc/udev/rules.d/70-persistent-net.rules || true
Richard Felkld59c5652018-02-08 13:14:05 +010026rm -rf /dev/.udev/ || true
azvyagintsev29410ee2018-07-12 20:02:30 +030027rm -fv /lib/udev/rules.d/75-persistent-net-generator.rules || true
Richard Felkld59c5652018-02-08 13:14:05 +010028
29echo "cleaning up minion_id for salt"
azvyagintsev29410ee2018-07-12 20:02:30 +030030rm -vf /etc/salt/minion_id || true
Richard Felkld59c5652018-02-08 13:14:05 +010031
Richard Felkl47757902018-03-02 22:44:43 +010032echo "cleaning up resolvconf"
azvyagintsev4053eb22018-03-29 16:21:51 +030033sed -i '/172\.18\.208\.44/d' /etc/resolvconf/resolv.conf.d/base
34
Petr Ruzicka24be3102018-08-15 13:39:15 +020035echo "cleaning up /var/cache/{apt,salt}/*"
36rm -rf /var/cache/{apt,salt}/* || true
37
azvyagintsev29410ee2018-07-12 20:02:30 +030038# Remove flags
39rm -v /done_ubuntu_base || true
40rm -v /done_ubuntu_salt_bootstrap || true
41
azvyagintsevcb4c35d2018-07-18 19:31:35 +030042# Force cleanup cloud-init data, if it was
43if [[ -d '/var/lib/cloud/' ]] ; then
44 rm -rf /var/lib/cloud/* || true
azvyagintsevbadeb372018-07-19 20:01:53 +030045 cloud-init clean || true
azvyagintsevcb4c35d2018-07-18 19:31:35 +030046 echo > /var/log/cloud-init-output.log || true
47 echo > /var/log/cloud-init.log || true
48fi
49
Ivan Berezovskiy22172462018-09-18 15:41:39 +040050cat << EOF > /etc/network/interfaces
Ivan Berezovskiy3242a9a2018-09-17 19:04:19 +040051# This file describes the network interfaces available on your system
52# and how to activate them. For more information, see interfaces(5).
53
54# The loopback network interface
55auto lo
56iface lo inet loopback
57
58# Source interfaces
59# Please check /etc/network/interfaces.d before changing this file
60# as interfaces may have been defined in /etc/network/interfaces.d
61# See LP: #1262951
62source /etc/network/interfaces.d/*.cfg
63EOF
64
azvyagintsev4053eb22018-03-29 16:21:51 +030065# Clear\drop cache's
66sync
67echo 3 > /proc/sys/vm/drop_caches