diff --git a/management/daemon.py b/management/daemon.py index 4846a67e..15db5e0b 100755 --- a/management/daemon.py +++ b/management/daemon.py @@ -426,6 +426,20 @@ def backup_set_custom(): request.form.get('min_age', '') )) +@app.route('/system/privacy', methods=["GET"]) +@authorized_personnel_only +def privacy_status_get(): + config = utils.load_settings(env) + return json_response(config.get("privacy", True)) + +@app.route('/system/privacy', methods=["POST"]) +@authorized_personnel_only +def privacy_status_set(): + config = utils.load_settings(env) + config["privacy"] = (request.form.get('value') == "private") + utils.write_settings(config, env) + return "OK" + # MUNIN @app.route('/munin/') diff --git a/management/status_checks.py b/management/status_checks.py index bf39bf9f..f67ffb5c 100755 --- a/management/status_checks.py +++ b/management/status_checks.py @@ -16,7 +16,7 @@ from dns_update import get_dns_zones, build_tlsa_record, get_custom_dns_config, from web_update import get_web_domains, get_default_www_redirects, get_domain_ssl_files from mailconfig import get_mail_domains, get_mail_aliases -from utils import shell, sort_domains, load_env_vars_from_file +from utils import shell, sort_domains, load_env_vars_from_file, load_settings def run_checks(rounded_values, env, output, pool): # run systems checks @@ -149,6 +149,7 @@ def check_service(i, service, env): def run_system_checks(rounded_values, env, output): check_ssh_password(env, output) check_software_updates(env, output) + check_miab_version(env, output) check_system_aliases(env, output) check_free_disk_space(rounded_values, env, output) @@ -808,11 +809,11 @@ def list_apt_updates(apt_update=True): return pkgs def what_version_is_this(env): - # This function runs `git describe` on the Mail-in-a-Box installation directory. + # This function runs `git describe --abbrev=0` 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() + tag = shell("check_output", ["/usr/bin/git", "describe", "--abbrev=0"], env={"GIT_DIR": os.path.join(miab_dir, '.git')}).strip() return tag def get_latest_miab_version(): @@ -821,6 +822,20 @@ def get_latest_miab_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 check_miab_version(env, output): + config = load_settings(env) + + if config.get("privacy", True): + output.print_warning("Mail-in-a-Box version check disabled by privacy setting.") + else: + this_ver = what_version_is_this(env) + latest_ver = get_latest_miab_version() + if this_ver == latest_ver: + output.print_ok("Mail-in-a-Box is up to date. You are running version %s." % this_ver) + else: + output.print_error("A new version of Mail-in-a-Box is available. You are running version %s. The latest version is %s. For upgrade instructions, see https://mailinabox.email. " + % (this_ver, latest_ver)) + def run_and_output_changes(env, pool, send_via_email): import json from difflib import SequenceMatcher diff --git a/management/templates/index.html b/management/templates/index.html index 6e970761..28a89113 100644 --- a/management/templates/index.html +++ b/management/templates/index.html @@ -114,7 +114,6 @@
  • Contacts/Calendar
  • Web
  • -
  • Version