Skip to content

Commit d5674a2

Browse files
committed
some minor hackery for ubuntu 24
* fix deprecation warnings in ssl_certificates.py * version check allows git versions * rejigger systemctl usage for u24
1 parent 3efd425 commit d5674a2

File tree

5 files changed

+9
-9
lines changed

5 files changed

+9
-9
lines changed

management/ssl_certificates.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,13 @@ def get_file_list():
9393

9494
# Sort the certificates to prefer good ones.
9595
import datetime
96-
now = datetime.datetime.utcnow()
96+
now = datetime.datetime.now(datetime.UTC)
9797
ret = { }
9898
for domain, cert_list in domains.items():
9999
#for c in cert_list: print(domain, c.not_valid_before, c.not_valid_after, "("+str(now)+")", c.issuer, c.subject, c._filename)
100100
cert_list.sort(key = lambda cert : (
101101
# must be valid NOW
102-
cert["cert"].not_valid_before <= now <= cert["cert"].not_valid_after,
102+
cert["cert"].not_valid_before.astimezone(datetime.UTC) <= now <= cert["cert"].not_valid_after.astimezone(datetime.UTC),
103103

104104
# prefer one that is not self-signed
105105
cert["cert"].issuer != cert["cert"].subject,
@@ -567,8 +567,8 @@ def check_certificate(domain, ssl_certificate, ssl_private_key, warn_if_expiring
567567
# Check that the certificate hasn't expired. The datetimes returned by the
568568
# certificate are 'naive' and in UTC. We need to get the current time in UTC.
569569
import datetime
570-
now = datetime.datetime.utcnow()
571-
if not(cert.not_valid_before <= now <= cert.not_valid_after):
570+
now = datetime.datetime.now(datetime.UTC)
571+
if not(cert.not_valid_before.astimezone(datetime.UTC) <= now <= cert.not_valid_after.astimezone(datetime.UTC)):
572572
return (f"The certificate has expired or is not yet valid. It is valid from {cert.not_valid_before} to {cert.not_valid_after}.", None)
573573

574574
# Next validate that the certificate is valid. This checks whether the certificate
@@ -604,7 +604,7 @@ def check_certificate(domain, ssl_certificate, ssl_private_key, warn_if_expiring
604604

605605
# But is it expiring soon?
606606
cert_expiration_date = cert.not_valid_after
607-
ndays = (cert_expiration_date-now).days
607+
ndays = (cert_expiration_date.astimezone(datetime.UTC)-now).days
608608
if not rounded_time or ndays <= 10:
609609
# Yikes better renew soon!
610610
expiry_info = "The certificate expires in %d days on %s." % (ndays, cert_expiration_date.date().isoformat())

management/status_checks.py

+2
Original file line numberDiff line numberDiff line change
@@ -968,6 +968,8 @@ def check_miab_version(env, output):
968968
output.print_ok("Mail-in-a-Box is up to date. You are running version %s." % this_ver)
969969
elif latest_ver is None:
970970
output.print_error("Latest Mail-in-a-Box version could not be determined. You are running version %s." % this_ver)
971+
elif re.match(r'[A-F,0-9]{40}', this_ver, re.I):
972+
output.print_ok("This version appears to be a git checkout (%s). Good luck!" % this_ver[0:7])
971973
else:
972974
output.print_error(f"A new version of Mail-in-a-Box is available. You are running version {this_ver}. The latest version is {latest_ver}. For upgrade instructions, see https://mailinabox.email. ")
973975

setup/management.sh

-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ exec gunicorn -b localhost:10222 -w 1 --timeout 630 wsgi:app
105105
EOF
106106
chmod +x $inst_dir/start
107107
cp --remove-destination conf/mailinabox.service /lib/systemd/system/mailinabox.service # target was previously a symlink so remove it first
108-
hide_output systemctl link -f /lib/systemd/system/mailinabox.service
109108
hide_output systemctl daemon-reload
110109
hide_output systemctl enable mailinabox.service
111110

setup/munin.sh

-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ mkdir -p /var/lib/munin-node/plugin-state/
6565
ln -sf "$PWD/management/munin_start.sh" /usr/local/lib/mailinabox/munin_start.sh
6666
chmod 0744 /usr/local/lib/mailinabox/munin_start.sh
6767
cp --remove-destination conf/munin.service /lib/systemd/system/munin.service # target was previously a symlink so remove first
68-
hide_output systemctl link -f /lib/systemd/system/munin.service
6968
hide_output systemctl daemon-reload
7069
hide_output systemctl unmask munin.service
7170
hide_output systemctl enable munin.service

setup/preflight.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ fi
1212
# Pull in the variables defined in /etc/os-release but in a
1313
# namespace to avoid polluting our variables.
1414
source <(cat /etc/os-release | sed s/^/OS_RELEASE_/)
15-
if [ "${OS_RELEASE_ID:-}" != "ubuntu" ] || [ "${OS_RELEASE_VERSION_ID:-}" != "22.04" ]; then
16-
echo "Mail-in-a-Box only supports being installed on Ubuntu 22.04, sorry. You are running:"
15+
if [ "${OS_RELEASE_ID:-}" != "ubuntu" ] || [ "${OS_RELEASE_VERSION_ID:-}" != "24.04" ]; then
16+
echo "Mail-in-a-Box only supports being installed on Ubuntu 24.04, sorry. You are running:"
1717
echo
1818
echo "${OS_RELEASE_ID:-"Unknown linux distribution"} ${OS_RELEASE_VERSION_ID:-}"
1919
echo

0 commit comments

Comments
 (0)