add management comments for checking for updated Ubuntu packages and applying updates

This commit is contained in:
Joshua Tauberer 2014-06-05 20:57:25 +00:00
parent cab7321dbb
commit 6194c63f76
1 changed files with 15 additions and 1 deletions

View File

@ -1,6 +1,6 @@
#!/usr/bin/python3
import os, os.path
import os, os.path, subprocess
from flask import Flask, request, render_template
app = Flask(__name__)
@ -55,6 +55,20 @@ def dns_update():
from dns_update import do_dns_update
return do_dns_update(env)
# System
@app.route('/system/updates')
def show_updates():
subprocess.check_call("apt-get -qq update", shell=True)
return subprocess.check_output(
r"""apt-get -qq -s upgrade | grep -v ^Conf | sed "s/^Inst /Updated Package Available: /" | sed "s/\[\(.*\)\] (\(\S*\).*/\(\1 => \2\)/" """,
shell=True)
@app.route('/system/update-packages', methods=["POST"])
def do_updates():
subprocess.check_call("apt-get -qq update", shell=True)
return subprocess.check_output("DEBIAN_FRONTEND=noninteractive apt-get -y upgrade", shell=True)
# APP
if __name__ == '__main__':