Skip to content

Instantly share code, notes, and snippets.

@stephennancekivell
Created June 1, 2013 07:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save stephennancekivell/5689547 to your computer and use it in GitHub Desktop.
Save stephennancekivell/5689547 to your computer and use it in GitHub Desktop.
Email notifications and one click install for Ubuntu package updates. http://stephennancekivell.blogspot.com/2013/06/server-updates-automate-it-part-2.html
#!/bin/bash
MSG=`sudo apt-get --yes dist-upgrade`
MSG_HEADING='sudo apt-get --yes dist-upgrade'
GmailSend.py -u bla@gmail.com -p bla -t bla@gmail.com -s "server update" -b "$MSG_HEADING \n\n $MSG"
#!/bin/bash
sudo apt-get update > /dev/null
M=`sudo apt-get --download-only --yes dist-upgrade`
MSG_HEADING='sudo apt-get --download-only --yes dist-upgrade'
LINK='http://myserver.com/bla/doTheUpgrade/dontGuessMe'
if echo $M | grep 'The following packages will be upgraded' > /dev/null
then
# these is upgrade
GmailSend.py -u bla@gmail.com -p bla -t bla@gmail.com -s "server update" -b "$MSG_HEADING \n\n $M \n\n $LINK"
fi
#!/usr/bin/env python
from flask import Flask
import os
app = Flask(__name__)
@app.route("/doTheUpgrade/dontGuessMe")
def hello():
os.system("sh ./do_update.sh")
return "performing update"
if __name__ == "__main__":
app.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment