Skip to content

Commit

Permalink
Add script to clear out machine information
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorific committed Jun 24, 2024
1 parent 29c5bb2 commit 33d30a2
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
24 changes: 24 additions & 0 deletions ubuntu/cloud/scripts/clear-machine-information.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash

echo "==> Autoremove packages and clear the package cache"
apt-get --assume-yes autoremove
apt-get --assume-yes clean

echo "==> Reset machine ID"
truncate -s 0 /etc/machine-id
[ -f /var/lib/dbus/machine-id ] && truncate -s 0 /var/lib/dbus/machine-id

echo "==> Remove SSH host keys (will be regenerated on first boot)"
rm --force /etc/ssh/ssh_host_*

echo "==> Remove the random seed file (will be regenerated on first boot)"
systemctl --quiet is-active systemd-random-seed.service && systemctl stop systemd-random-seed.service
[ -f /var/lib/systemd/random-seed ] && rm --force /var/lib/systemd/random-seed

echo "==> Clear log files"
find /var/log -type f -delete

echo "==> Clear the bash history"
export HISTSIZE=0
truncate -s 0 ~/.bash_history
unset HISTFILE
4 changes: 2 additions & 2 deletions ubuntu/cloud/x86_64/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,8 @@ enp1s0 UP 192.168.107.79/24 fda2:8d37:bed8:93ee:5054:ff:fe
```

```
$ virsh shutdown ubuntu-server-2004
$ virsh undefine ubuntu-server-2004 --nvram --remove-all-storage
$ virsh shutdown ubuntu-server-2204
$ virsh undefine ubuntu-server-2204 --nvram --remove-all-storage
```

## Ubuntu 22.04 BIOS virtual firmware
Expand Down
1 change: 1 addition & 0 deletions ubuntu/cloud/x86_64/ubuntu.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ build {
scripts = [
"../scripts/disable-updates.sh",
"../scripts/qemu.sh",
"../scripts/clear-machine-information.sh"
]
}
}

0 comments on commit 33d30a2

Please sign in to comment.