blob: 63a7586023fb1c3dceb5057d16db37f0c8aa87a2 [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
azvyagintsevbfd61702018-10-26 14:18:33 +03007rm -rf /var/lib/apt/lists/* || true
azvyagintsev29410ee2018-07-12 20:02:30 +03008rm -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
azvyagintsevbfd61702018-10-26 14:18:33 +030038rm -rf /root/.cache || true
39rm -rf /root/.ssh/known_hosts || true
40
azvyagintsev29410ee2018-07-12 20:02:30 +030041# Remove flags
42rm -v /done_ubuntu_base || true
43rm -v /done_ubuntu_salt_bootstrap || true
44
azvyagintsevcb4c35d2018-07-18 19:31:35 +030045# Force cleanup cloud-init data, if it was
46if [[ -d '/var/lib/cloud/' ]] ; then
47 rm -rf /var/lib/cloud/* || true
azvyagintsevbadeb372018-07-19 20:01:53 +030048 cloud-init clean || true
azvyagintsevcb4c35d2018-07-18 19:31:35 +030049 echo > /var/log/cloud-init-output.log || true
50 echo > /var/log/cloud-init.log || true
51fi
52
Ivan Berezovskiy22172462018-09-18 15:41:39 +040053cat << EOF > /etc/network/interfaces
Ivan Berezovskiy3242a9a2018-09-17 19:04:19 +040054# 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
58auto lo
59iface 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
65source /etc/network/interfaces.d/*.cfg
66EOF
67
azvyagintsev4053eb22018-03-29 16:21:51 +030068# Clear\drop cache's
69sync
70echo 3 > /proc/sys/vm/drop_caches