Skip to content

Instantly share code, notes, and snippets.

@andrewfraley
Last active January 17, 2022 23:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrewfraley/e924e09b64def7dca1bde6de53cc22cf to your computer and use it in GitHub Desktop.
Save andrewfraley/e924e09b64def7dca1bde6de53cc22cf to your computer and use it in GitHub Desktop.
Used to do final cleanup on a Ubuntu 20.04 image template
# Apply updates and clear apt cache
echo "Applying updates and clearing apt cache"
apt update && apt -y upgrade && apt -y autoremove && apt clean
# Clear this to regen this file (you can't delete it). Otherwise DHCP will give the same IP to every system built with this
echo "Clearing /etc/machine-id"
truncate -s0 /etc/machine-id
echo "Running cloud-init clean"
cloud-init clean
echo "Shutting down!"
shutdown -h "now"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment