From 48f167876c772b6b3cc183a4d358de4b5ec20b7a Mon Sep 17 00:00:00 2001 From: John Supplee Date: Sat, 9 Mar 2019 12:29:37 +0200 Subject: [PATCH] Options dialog updates --- setup/options-dialog.py | 59 ++++++++++++++++++++++++++++++++--------- setup/questions.sh | 3 +++ 2 files changed, 49 insertions(+), 13 deletions(-) diff --git a/setup/options-dialog.py b/setup/options-dialog.py index 9c9bfc60..166ee455 100644 --- a/setup/options-dialog.py +++ b/setup/options-dialog.py @@ -6,40 +6,73 @@ import sys import os -class TestApp(npyscreen.NPSApp): +class OptionsApp(npyscreen.NPSApp): def main(self): # These lines create the form and populate it with widgets. # A fairly complex screen in only 8 or so lines of code - a line for each control. npyscreen.setTheme(npyscreen.Themes.BlackOnWhiteTheme) form = npyscreen.Form(name = "Mail-in-a-Box Options",) - postgrey_text = form.add( + form.add( npyscreen.TitleFixedText, name="POSTGREY", - value="Should Postgrey be used to greylist messages?", + value="", + editable=False + ) + form.add( + npyscreen.MultiLineEdit, + value="The Postgrey service greylists incoming messages from unknown senders.\n" + "It can be useful for fighting spam but often causes message delivery\n" + "delays of several minutes.", + max_height=4, editable=False ) - form.add(npyscreen.FixedText) - postgrey_text = form.add( - npyscreen.MultiLineEditable, + form.add( + npyscreen.TitleFixedText, name="POSTSRSD", + value="", + editable=False + ) + form.add( + npyscreen.MultiLineEdit, value="The PostSRSd daemon performs return path rewriting using the SRS protocol.\n" "Not that all messages, including locally delivered mail will have their return\n" "paths rewritten", max_height=4, editable=False ) - form.add(npyscreen.FixedText) + + form.add( + npyscreen.TitleFixedText, + name="POLICY_SPF", + value="", + editable=False + ) + form.add( + npyscreen.MultiLineEdit, + value="" + "The policy SPF service checks the SPF of incoming mails and rejects those\n" + "that do not qualify. This helps to prevent spoofing, but if valid mail does\n" + "not have SPF configured properly it will be rejected.", + max_height=4, + editable=False + ) + + init_values = [] + if int(os.getenv('POSTGREY', 1)) == 1: + init_values.append(0) + + if int(os.getenv('POSTSRSD', 0)) == 1: + init_values.append(1) + + if int(os.getenv('POLICY_SPF', 0)) == 1: + init_values.append(2) options = form.add( npyscreen.TitleMultiSelect, max_height=-2, - value = [ - int(os.getenv('POSTGREY', 1)), - int(os.getenv('POSTSRSD', 0)), - int(os.getenv('POLICY_SPF', 0)) - ], + value=init_values, name="Options", values= ["POSTGREY","POSTSRSD","POLICY_SPF"], scroll_exit=True @@ -56,5 +89,5 @@ class TestApp(npyscreen.NPSApp): if __name__ == "__main__": - App = TestApp() + App = OptionsApp() App.run() diff --git a/setup/questions.sh b/setup/questions.sh index 18b64f02..b9de2c68 100644 --- a/setup/questions.sh +++ b/setup/questions.sh @@ -195,6 +195,9 @@ if [ -z "${STORAGE_ROOT:-}" ]; then fi python3 setup/options-dialog.py +source ./_options.sh +rm _optoins.sh + # Show the configuration, since the user may have not entered it manually. echo