Skip to content

Instantly share code, notes, and snippets.

@iconoclasthero
Last active March 11, 2023 18:08
Show Gist options
  • Save iconoclasthero/bf4052ef5e01ee135852c2b4c81f8d97 to your computer and use it in GitHub Desktop.
Save iconoclasthero/bf4052ef5e01ee135852c2b4c81f8d97 to your computer and use it in GitHub Desktop.
How to remove the fucking Canonical ESM messages upon Ubuntu terminal login:
#!/bin/bash
# see https://askubuntu.com/questions/1453749/inhibit-esm-messages-at-login
# for more reference
# worked on Ubuntu 22.x
scriptname="$(realpath $0)"
function removeesm(){
sudo sed -Ezi.orig \
-e 's/(def _output_esm_service_status.outstream, have_esm_service, service_type.:\n)/\1 return\n/' \
-e 's/(def _output_esm_package_alert.*?\n.*?\n.:\n)/\1 return\n/' \
/usr/lib/update-notifier/apt_check.py
}
function editscript(){
echo "scriptname: $scriptname"
if [[ "$1" == "edit" ]]; then
(/usr/bin/nano "$scriptname")
exit
fi
}
editscript "$1"
clear
printf "\nThis script will remove the informaiton about Canonical's ESM (Extended-Security Maintenance) program from the login MotD.\n\n\n"
while true; do
read -p "Do you wish to remove the ESM advetisment ? " yn
case $yn in
[Yy]* ) removeesm; break;;
[Nn]* ) exit;;
* ) echo "Please answer yes or no.";;
esac
done
clear
printf "\n\nTesting modification now:\n\n"
/usr/lib/update-notifier/apt_check.py --human-readable
while true; do
read -p "\nThe cashed MotD will be regenerated upon the next reboot or it can be done now. Do you wish to regenerate the MotD now ? " yn
case $yn in
[Yy]* ) sudo /usr/lib/update-notifier/update-motd-updates-available --force; break;;
[Nn]* ) exit;;
* ) echo "Please answer yes or no.";;
esac
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment