From 6c2ea4595dd51f1b992e8eb20a60a8972fc4578b Mon Sep 17 00:00:00 2001 From: Tagada <36127788+Tagadda@users.noreply.github.com> Date: Sat, 30 Sep 2023 11:36:18 +0200 Subject: [PATCH] WIP post config with API --- scripts/_common.sh | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/scripts/_common.sh b/scripts/_common.sh index 944a65e..35ad7ea 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -8,6 +8,29 @@ # PERSONAL HELPERS #================================================= +# FIXME https://listmonk.app/docs/swagger/#/Settings/getSettings +_listmonk_configure_with_api () { + python -c """ +from urllib.request import urlopen, Request +with urlopen('http://localhost:$port/api/settings') as url: + data = json.load(url) + +data['data']['app.root_url'] = "https://$domain" +data['data']['app.from_email'] = "listmonk " +data['data']['smtp'][0]['host'] = "127.0.0.1" +data['data']['smtp'][0]['auth_protocol'] = "plain" +data['data']['smtp'][0]['username'] = "$app" +data['data']['smtp'][0]['password'] = "$mail_pwd" + +data_bytes = bytes(json.dumps(data), encoding='utf8') + +request = Request('http://localhost:$port/api/settings', method='PUT', data=data_bytes, headers={'Content-Type': 'application/json'}) + +with urlopen(request) as response: + print(response.read()) +""" +} + #================================================= # EXPERIMENTAL HELPERS #=================================================