blob: e5db69150be64927ac3a00148f0b4b43da266bd1 [file] [log] [blame]
azvyagintsev9a1737f2019-03-11 15:44:54 +02001#!/bin/bash -xe
2
3apt-get -y remove --purge unattended-upgrades || true
4apt-get -y autoremove --purge
5apt-get -y clean
6
7rm -rf /var/lib/apt/lists/* || true
8rm -rv /etc/apt/sources.list.d/* || true
9rm -rv /etc/apt/preferences.d/* || true
10echo > /etc/apt/sources.list || true
11rm -vf /usr/sbin/policy-rc.d || true
12
13echo "cleaning up hostname"
14sed -i "/.*ubuntu.*/d" /etc/hosts
15sed -i "/.*salt.*/d" /etc/hosts
16
17echo "cleaning up dhcp leases"
18rm -rf /var/lib/dhcp/* || true
19rm -rfv /var/lib/ntp/ntp.conf.dhcp || true
20
21echo "cleaning up udev rules"
22rm -fv /etc/udev/rules.d/70-persistent-net.rules || true
23rm -rf /dev/.udev/ || true
24rm -fv /lib/udev/rules.d/75-persistent-net-generator.rules || true
25
26echo "cleaning up minion_id for salt"
27rm -vf /etc/salt/minion_id || true
28
29echo "cleaning up /var/cache/{apt,salt}/*"
30rm -rf /var/cache/{apt,salt}/* || true
31
32rm -rf /root/.cache || true
33rm -rf /root/.ssh/known_hosts || true
34
35# Remove flags
36rm -v /done_ubuntu_base || true
37rm -v /done_ubuntu_salt_bootstrap || true
38
39# Force cleanup cloud-init data, if it was
40if [[ -d '/var/lib/cloud/' ]] ; then
41 rm -rf /var/lib/cloud/* || true
42 cloud-init clean || true
43 echo > /var/log/cloud-init-output.log || true
44 echo > /var/log/cloud-init.log || true
45fi
46
47# Clear\drop cache's
48sync
49echo 3 > /proc/sys/vm/drop_caches