mirror of
https://github.com/mail-in-a-box/mailinabox.git
synced 2024-11-24 02:37:05 +00:00
show the Mail-in-a-Box version in the control panel and a button to ping the MiaB website for the latest version
fixes #441
This commit is contained in:
parent
1367816b04
commit
7527b4dc27
@ -28,6 +28,7 @@ Control panel:
|
|||||||
* Resetting a user's password now forces them to log in again everywhere.
|
* Resetting a user's password now forces them to log in again everywhere.
|
||||||
* Status checks were not working if an ssh server was not installed.
|
* Status checks were not working if an ssh server was not installed.
|
||||||
* SSL certificate validation now uses the Python cryptography module in some places where openssl was used.
|
* SSL certificate validation now uses the Python cryptography module in some places where openssl was used.
|
||||||
|
* There is a new tab to show the installed version of Mail-in-a-Box and to fetch the latest released version.
|
||||||
|
|
||||||
System:
|
System:
|
||||||
* The munin system monitoring tool is now installed and accessible at /admin/munin.
|
* The munin system monitoring tool is now installed and accessible at /admin/munin.
|
||||||
|
@ -340,6 +340,24 @@ def web_update():
|
|||||||
|
|
||||||
# System
|
# System
|
||||||
|
|
||||||
|
@app.route('/system/version', methods=["GET"])
|
||||||
|
@authorized_personnel_only
|
||||||
|
def system_version():
|
||||||
|
from status_checks import what_version_is_this
|
||||||
|
try:
|
||||||
|
return what_version_is_this(env)
|
||||||
|
except Exception as e:
|
||||||
|
return (str(e), 500)
|
||||||
|
|
||||||
|
@app.route('/system/latest-upstream-version', methods=["POST"])
|
||||||
|
@authorized_personnel_only
|
||||||
|
def system_latest_upstream_version():
|
||||||
|
from status_checks import get_latest_miab_version
|
||||||
|
try:
|
||||||
|
return get_latest_miab_version()
|
||||||
|
except Exception as e:
|
||||||
|
return (str(e), 500)
|
||||||
|
|
||||||
@app.route('/system/status', methods=["POST"])
|
@app.route('/system/status', methods=["POST"])
|
||||||
@authorized_personnel_only
|
@authorized_personnel_only
|
||||||
def system_status():
|
def system_status():
|
||||||
|
@ -789,6 +789,20 @@ def list_apt_updates(apt_update=True):
|
|||||||
|
|
||||||
return pkgs
|
return pkgs
|
||||||
|
|
||||||
|
def what_version_is_this(env):
|
||||||
|
# This function runs `git describe` on the Mail-in-a-Box installation directory.
|
||||||
|
# Git may not be installed and Mail-in-a-Box may not have been cloned from github,
|
||||||
|
# so this function may raise all sorts of exceptions.
|
||||||
|
miab_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||||
|
tag = shell("check_output", ["/usr/bin/git", "describe"], env={"GIT_DIR": os.path.join(miab_dir, '.git')}).strip()
|
||||||
|
return tag
|
||||||
|
|
||||||
|
def get_latest_miab_version():
|
||||||
|
# This pings https://mailinabox.email/bootstrap.sh and extracts the tag named in
|
||||||
|
# the script to determine the current product version.
|
||||||
|
import urllib.request
|
||||||
|
return re.search(b'TAG=(.*)', urllib.request.urlopen("https://mailinabox.email/bootstrap.sh?ping=1").read()).group(1).decode("utf8")
|
||||||
|
|
||||||
def run_and_output_changes(env, pool, send_via_email):
|
def run_and_output_changes(env, pool, send_via_email):
|
||||||
import json
|
import json
|
||||||
from difflib import SequenceMatcher
|
from difflib import SequenceMatcher
|
||||||
@ -969,3 +983,6 @@ if __name__ == "__main__":
|
|||||||
if cert_status != "OK":
|
if cert_status != "OK":
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
|
elif sys.argv[1] == "--version":
|
||||||
|
print(what_version_is_this(env))
|
||||||
|
@ -114,6 +114,7 @@
|
|||||||
</li>
|
</li>
|
||||||
<li><a href="#sync_guide" onclick="return show_panel(this);">Contacts/Calendar</a></li>
|
<li><a href="#sync_guide" onclick="return show_panel(this);">Contacts/Calendar</a></li>
|
||||||
<li><a href="#web" onclick="return show_panel(this);">Web</a></li>
|
<li><a href="#web" onclick="return show_panel(this);">Web</a></li>
|
||||||
|
<li><a href="#version" onclick="return show_panel(this);">Version</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
<ul class="nav navbar-nav navbar-right">
|
<ul class="nav navbar-nav navbar-right">
|
||||||
<li><a href="#" onclick="do_logout(); return false;" style="color: white">Log out?</a></li>
|
<li><a href="#" onclick="do_logout(); return false;" style="color: white">Log out?</a></li>
|
||||||
@ -167,6 +168,10 @@
|
|||||||
{% include "ssl.html" %}
|
{% include "ssl.html" %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div id="panel_version" class="admin_panel">
|
||||||
|
{% include "version.html" %}
|
||||||
|
</div>
|
||||||
|
|
||||||
<hr>
|
<hr>
|
||||||
|
|
||||||
<footer>
|
<footer>
|
||||||
|
@ -25,6 +25,7 @@ for fn in glob.glob("/var/log/nginx/access.log*"):
|
|||||||
with f:
|
with f:
|
||||||
for line in f:
|
for line in f:
|
||||||
# Find lines that are GETs on /bootstrap.sh by either curl or wget.
|
# Find lines that are GETs on /bootstrap.sh by either curl or wget.
|
||||||
|
# (Note that we purposely skip ...?ping=1 requests which is the admin panel querying us for updates.)
|
||||||
m = re.match(rb"(?P<ip>\S+) - - \[(?P<date>.*?)\] \"GET /bootstrap.sh HTTP/.*\" 200 \d+ .* \"(?:curl|wget)", line, re.I)
|
m = re.match(rb"(?P<ip>\S+) - - \[(?P<date>.*?)\] \"GET /bootstrap.sh HTTP/.*\" 200 \d+ .* \"(?:curl|wget)", line, re.I)
|
||||||
if m:
|
if m:
|
||||||
date, time = m.group("date").decode("ascii").split(":", 1)
|
date, time = m.group("date").decode("ascii").split(":", 1)
|
||||||
|
Loading…
Reference in New Issue
Block a user