mirror of
https://github.com/mail-in-a-box/mailinabox.git
synced 2024-11-26 02:57:04 +00:00
commit
a56a9dc6a1
@ -426,6 +426,20 @@ def backup_set_custom():
|
|||||||
request.form.get('min_age', '')
|
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
|
# MUNIN
|
||||||
|
|
||||||
@app.route('/munin/')
|
@app.route('/munin/')
|
||||||
|
@ -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 web_update import get_web_domains, get_default_www_redirects, get_domain_ssl_files
|
||||||
from mailconfig import get_mail_domains, get_mail_aliases
|
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):
|
def run_checks(rounded_values, env, output, pool):
|
||||||
# run systems checks
|
# run systems checks
|
||||||
@ -149,6 +149,7 @@ def check_service(i, service, env):
|
|||||||
def run_system_checks(rounded_values, env, output):
|
def run_system_checks(rounded_values, env, output):
|
||||||
check_ssh_password(env, output)
|
check_ssh_password(env, output)
|
||||||
check_software_updates(env, output)
|
check_software_updates(env, output)
|
||||||
|
check_miab_version(env, output)
|
||||||
check_system_aliases(env, output)
|
check_system_aliases(env, output)
|
||||||
check_free_disk_space(rounded_values, env, output)
|
check_free_disk_space(rounded_values, env, output)
|
||||||
|
|
||||||
@ -808,11 +809,11 @@ def list_apt_updates(apt_update=True):
|
|||||||
return pkgs
|
return pkgs
|
||||||
|
|
||||||
def what_version_is_this(env):
|
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,
|
# 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.
|
# so this function may raise all sorts of exceptions.
|
||||||
miab_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
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
|
return tag
|
||||||
|
|
||||||
def get_latest_miab_version():
|
def get_latest_miab_version():
|
||||||
@ -821,6 +822,20 @@ def get_latest_miab_version():
|
|||||||
import urllib.request
|
import urllib.request
|
||||||
return re.search(b'TAG=(.*)', urllib.request.urlopen("https://mailinabox.email/bootstrap.sh?ping=1").read()).group(1).decode("utf8")
|
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):
|
def run_and_output_changes(env, pool, send_via_email):
|
||||||
import json
|
import json
|
||||||
from difflib import SequenceMatcher
|
from difflib import SequenceMatcher
|
||||||
|
@ -114,7 +114,6 @@
|
|||||||
</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>
|
||||||
@ -168,10 +167,6 @@
|
|||||||
{% include "ssl.html" %}
|
{% include "ssl.html" %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="panel_version" class="admin_panel">
|
|
||||||
{% include "version.html" %}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<hr>
|
<hr>
|
||||||
|
|
||||||
<footer>
|
<footer>
|
||||||
|
@ -34,8 +34,20 @@
|
|||||||
font-family: monospace;
|
font-family: monospace;
|
||||||
white-space: pre-wrap;
|
white-space: pre-wrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#system-privacy-setting {
|
||||||
|
float: right;
|
||||||
|
max-width: 20em;
|
||||||
|
margin-bottom: 1em;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
<div id="system-privacy-setting" style="display: none">
|
||||||
|
<div><a onclick="return enable_privacy(!current_privacy_setting)" href="#"><span>Enable/Disable</span> New-Version Check</a></div>
|
||||||
|
<p style="line-height: 125%"><small>(When enabled, status checks phone-home to check for a new release of Mail-in-a-Box.)</small></p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<table id="system-checks" class="table" style="max-width: 60em">
|
<table id="system-checks" class="table" style="max-width: 60em">
|
||||||
<thead>
|
<thead>
|
||||||
</thead>
|
</thead>
|
||||||
@ -46,6 +58,18 @@
|
|||||||
<script>
|
<script>
|
||||||
function show_system_status() {
|
function show_system_status() {
|
||||||
$('#system-checks tbody').html("<tr><td colspan='2' class='text-muted'>Loading...</td></tr>")
|
$('#system-checks tbody').html("<tr><td colspan='2' class='text-muted'>Loading...</td></tr>")
|
||||||
|
|
||||||
|
api(
|
||||||
|
"/system/privacy",
|
||||||
|
"GET",
|
||||||
|
{ },
|
||||||
|
function(r) {
|
||||||
|
current_privacy_setting = r;
|
||||||
|
$('#system-privacy-setting').show();
|
||||||
|
$('#system-privacy-setting a span').text(r ? "Enable" : "Disable");
|
||||||
|
$('#system-privacy-setting p').toggle(r);
|
||||||
|
});
|
||||||
|
|
||||||
api(
|
api(
|
||||||
"/system/status",
|
"/system/status",
|
||||||
"POST",
|
"POST",
|
||||||
@ -82,5 +106,20 @@ function show_system_status() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
var current_privacy_setting = null;
|
||||||
|
function enable_privacy(status) {
|
||||||
|
api(
|
||||||
|
"/system/privacy",
|
||||||
|
"POST",
|
||||||
|
{
|
||||||
|
value: (status ? "private" : "off")
|
||||||
|
},
|
||||||
|
function(res) {
|
||||||
|
show_system_status();
|
||||||
|
});
|
||||||
|
return false; // disable link
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
@ -1,36 +0,0 @@
|
|||||||
<style>
|
|
||||||
</style>
|
|
||||||
|
|
||||||
<h2>Mail-in-a-Box Version</h2>
|
|
||||||
|
|
||||||
<p>You are running Mail-in-a-Box version <span id="miab-version" style="font-weight: bold">...</span>.</p>
|
|
||||||
|
|
||||||
<p>The latest version of Mail-in-a-Box is <button id="miab-get-latest-upstream" onclick="check_latest_version()">Check</button>.</p>
|
|
||||||
|
|
||||||
<p>To find the latest version and for upgrade instructions, see <a href="https://mailinabox.email/">https://mailinabox.email/</a>, <a href="https://github.com/mail-in-a-box/mailinabox/blob/master/CHANGELOG.md">release notes</a>, and <a href="https://mailinabox.email/maintenance.html#updating-mail-in-a-box">upgrade instructions</a>.</p>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
function show_version() {
|
|
||||||
$('#miab-version').text('loading...');
|
|
||||||
api(
|
|
||||||
"/system/version",
|
|
||||||
"GET",
|
|
||||||
{
|
|
||||||
},
|
|
||||||
function(version) {
|
|
||||||
$('#miab-version').text(version);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function check_latest_version() {
|
|
||||||
$('#miab-get-latest-upstream').text('loading...');
|
|
||||||
api(
|
|
||||||
"/system/latest-upstream-version",
|
|
||||||
"POST",
|
|
||||||
{
|
|
||||||
},
|
|
||||||
function(version) {
|
|
||||||
$('#miab-get-latest-upstream').text(version);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
</script>
|
|
@ -1,6 +1,7 @@
|
|||||||
import os.path
|
import os.path
|
||||||
|
import rtyaml
|
||||||
|
|
||||||
CONF_DIR = os.path.join(os.path.dirname(__file__), "../conf")
|
# THE ENVIRONMENT FILE AT /etc/mailinabox.conf
|
||||||
|
|
||||||
def load_environment():
|
def load_environment():
|
||||||
# Load settings from /etc/mailinabox.conf.
|
# Load settings from /etc/mailinabox.conf.
|
||||||
@ -18,6 +19,24 @@ def save_environment(env):
|
|||||||
for k, v in env.items():
|
for k, v in env.items():
|
||||||
f.write("%s=%s\n" % (k, v))
|
f.write("%s=%s\n" % (k, v))
|
||||||
|
|
||||||
|
# THE SETTINGS FILE AT STORAGE_ROOT/settings.yaml.
|
||||||
|
|
||||||
|
def write_settings(config, env):
|
||||||
|
fn = os.path.join(env['STORAGE_ROOT'], 'settings.yaml')
|
||||||
|
with open(fn, "w") as f:
|
||||||
|
f.write(rtyaml.dump(config))
|
||||||
|
|
||||||
|
def load_settings(env):
|
||||||
|
fn = os.path.join(env['STORAGE_ROOT'], 'settings.yaml')
|
||||||
|
try:
|
||||||
|
config = rtyaml.load(open(fn, "r"))
|
||||||
|
if not isinstance(config, dict): raise ValueError() # caught below
|
||||||
|
return config
|
||||||
|
except:
|
||||||
|
return { }
|
||||||
|
|
||||||
|
# UTILITIES
|
||||||
|
|
||||||
def safe_domain_name(name):
|
def safe_domain_name(name):
|
||||||
# Sanitize a domain name so it is safe to use as a file name on disk.
|
# Sanitize a domain name so it is safe to use as a file name on disk.
|
||||||
import urllib.parse
|
import urllib.parse
|
||||||
|
Loading…
Reference in New Issue
Block a user