generated from NethServer/ns8-kickstart
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #75 from NethServer/fixTlsVerify
Add SMTP_TLS_VERIFY setting and SMTP server self-signed certificate verification NethServer/dev#6817
- Loading branch information
Showing
6 changed files
with
61 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/usr/bin/env python3 | ||
|
||
# | ||
# Copyright (C) 2023 Nethesis S.r.l. | ||
# SPDX-License-Identifier: GPL-3.0-or-later | ||
# | ||
|
||
import agent | ||
import subprocess | ||
|
||
def occ(args): | ||
cmd = ['podman', 'exec', '--user', 'www-data', 'nextcloud-app', 'php', './occ'] | ||
p = subprocess.run(cmd + args, capture_output=True) | ||
return (p.returncode, p.stdout) | ||
|
||
smarthost= agent.read_envfile("smarthost.env") | ||
# smarthost is configured | ||
if 'SMTP_HOST' in smarthost: | ||
# verify if smarthost verify tls certificate | ||
if smarthost.get('SMTP_SECURE') == 'none' or smarthost.get('SMTP_TLS_VERIFY') == 'False': | ||
occ(["config:system:set","mail_smtpstreamoptions","ssl","allow_self_signed","--value=true", "--type=boolean"]) | ||
occ(["config:system:set","mail_smtpstreamoptions","ssl","verify_peer","--value=false","--type=boolean"]) | ||
occ(["config:system:set","mail_smtpstreamoptions","ssl","verify_peer_name","--value=false","--type=boolean"]) | ||
else: | ||
occ(["config:system:delete","mail_smtpstreamoptions","ssl"]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/usr/bin/env python3 | ||
|
||
# | ||
# Copyright (C) 2023 Nethesis S.r.l. | ||
# SPDX-License-Identifier: GPL-3.0-or-later | ||
# | ||
|
||
import sys | ||
import json | ||
import time | ||
import subprocess | ||
|
||
def occ(args): | ||
cmd = ['podman', 'exec', '--user', 'www-data', 'nextcloud-app', 'php', './occ'] | ||
p = subprocess.run(cmd + args, capture_output=True) | ||
return (p.returncode, p.stdout) | ||
|
||
# wait after nextcloud-app is ready | ||
max_tries = 60 | ||
i = 0 | ||
while i < max_tries: | ||
i = i+1 | ||
try: | ||
ret, out = occ(["status", "--output", "json"]) | ||
status = json.loads(out) | ||
if status["installed"]: | ||
break | ||
print(f"wait-startup: waiting for nextcloud-app ({i})", file=sys.stderr) | ||
time.sleep(1) | ||
except Exception as e: | ||
continue |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters