Skip to content

Instantly share code, notes, and snippets.

@andrew-stclair
Last active May 9, 2023 23:57
Show Gist options
  • Save andrew-stclair/04f3669889e23da486b83bf60591f14d to your computer and use it in GitHub Desktop.
Save andrew-stclair/04f3669889e23da486b83bf60591f14d to your computer and use it in GitHub Desktop.

Automating Ubuntu Pro

I dont garantee these will always work, nor are they a good way of achieving some level of automation for ubuntu pro, but they worked at time of writing.

Run commands when ubuntu pro is activated

Checks if the output of the pro status command contains the string "Valid until"

# If Ubuntu Pro is Activated
if pro status | grep -q "Valid until"; then
  # Do all the things
fi

Enable livepatch if it is not already enabled

Checks the output of pro status for lines containing "livepatch" then returns true if none of them have enabled in them

# Enable livepatch if not already enabled
if pro status | grep livepatch | grep -vq "enabled"; then sudo pro enable livepatch; fi

Enable Ubuntu Security Guide if it's not already enabled

Checks the output of pro status for lines containing "usg", then checks for lines containing "Security compliance" then returns true if none of them have enabled in them

# Enable Ubuntu Security Guide if not already enabled
if pro status | grep usg | grep "Security compliance" | grep -vq "enabled"; then sudo pro enable usg; fi

Configure certificates used for livepatch

This will configure the certificates that the livepatch service trusts, this helps if you are using a local mirror or are behind a firewall that decrypts and re-encrypts traffic (E.G. in an Educational or Corporate environment)

# Configure Livepatch to use BABL Certs
cat /usr/local/share/ca-certificates/[Cert Prefix]* > /tmp/certs.pem; sudo canonical-livepatch config ca-certs=@stdin < /tmp/certs.pem; rm -rf /tmp/certs.pem
sudo canonical-livepatch refresh
sudo canonical-livepatch status
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment