Skip to content

Commit 1be0f3b

Browse files
authored
Remove deprecated environment script and improve variable access consistency (#163)
Refs NethServer/dev#7690
1 parent 5734a6e commit 1be0f3b

File tree

3 files changed

+37
-30
lines changed

3 files changed

+37
-30
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/usr/bin/env python3
2+
3+
#
4+
# Copyright (C) 2025 Nethesis S.r.l.
5+
# SPDX-License-Identifier: GPL-3.0-or-later
6+
#
7+
8+
import os
9+
import agent
10+
11+
defaults = {
12+
'WEBTOP_TIMEZONE': '-',
13+
'WEBTOP_LOCALE': 'en_US',
14+
'WEBDAV_DEBUG': 'False',
15+
'WEBDAV_LOG_LEVEL': 'ERROR',
16+
'Z_PUSH_LOG_LEVEL': 'ERROR',
17+
'Z_PUSH_IMAP_SERVER': '10.5.4.1',
18+
'Z_PUSH_SMTP_SERVER': '10.5.4.1',
19+
'Z_PUSH_SMTP_PORT': '25',
20+
'Z_PUSH_USE_LEGACY_FOLDER_IDS': 'false',
21+
'WEBAPP_JS_DEBUG': 'False',
22+
'WEBAPP_MIN_MEMORY': '512',
23+
'WEBAPP_MAX_MEMORY': '1024',
24+
'EJABBERD_MODULE': '',
25+
}
26+
27+
for key, value in defaults.items():
28+
if key not in os.environ:
29+
agent.set_env(key, value)

imageroot/actions/create-module/10env

Lines changed: 0 additions & 22 deletions
This file was deleted.

imageroot/actions/get-configuration/20readconfig

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,23 @@ import agent
1313
config={
1414
"hostname": os.getenv("WEBTOP_HOSTNAME", ""),
1515
"request_https_certificate": agent.get_route(os.environ['MODULE_ID']).get('lets_encrypt', False),
16-
"locale": os.environ["WEBTOP_LOCALE"],
17-
"timezone": os.environ["WEBTOP_TIMEZONE"],
16+
"locale": os.getenv("WEBTOP_LOCALE", "en_US"),
17+
"timezone": os.getenv("WEBTOP_TIMEZONE", "-"),
1818
"mail_module": os.getenv("MAIL_MODULE", ""),
1919
"mail_domain": os.getenv("MAIL_DOMAIN", ""),
2020
"ejabberd_module": os.getenv("EJABBERD_MODULE", ""),
2121
"ejabberd_domain": os.getenv("EJABBERD_DOMAIN", ""),
2222
"webapp": {
23-
"debug": os.environ["WEBAPP_JS_DEBUG"].lower() in ('true', '1', 't'),
24-
"min_memory": int(os.environ["WEBAPP_MIN_MEMORY"]),
25-
"max_memory": int(os.environ["WEBAPP_MAX_MEMORY"]),
23+
"debug": os.getenv("WEBAPP_JS_DEBUG", 'False').lower() in ('true', '1', 't'),
24+
"min_memory": int(os.getenv("WEBAPP_MIN_MEMORY", "512")),
25+
"max_memory": int(os.getenv("WEBAPP_MAX_MEMORY", "1024")),
2626
},
2727
"webdav": {
28-
"debug": os.environ["WEBDAV_DEBUG"].lower() in ('true', '1', 't'),
29-
"loglevel": os.environ["WEBDAV_LOG_LEVEL"],
28+
"debug": os.getenv("WEBDAV_DEBUG", 'False').lower() in ('true', '1', 't'),
29+
"loglevel": os.getenv("WEBDAV_LOG_LEVEL", "ERROR"),
3030
},
3131
"zpush": {
32-
"loglevel": os.environ["Z_PUSH_LOG_LEVEL"],
32+
"loglevel": os.getenv("Z_PUSH_LOG_LEVEL", "ERROR"),
3333
},
3434
"pecbridge_admin_mail": os.getenv("PECBRIDGE_ADMIN_MAIL", ""),
3535
"pecbridge_from_address": os.getenv("PECBRIDGE_FROM_ADDRESS", ""),

0 commit comments

Comments
 (0)