mirror of
https://github.com/mail-in-a-box/mailinabox.git
synced 2024-12-24 07:37:04 +00:00
Initial work on dialog screen for options
This commit is contained in:
parent
36101208fe
commit
a7f62f281b
60
setup/options-dialog.py
Normal file
60
setup/options-dialog.py
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
# encoding: utf-8
|
||||||
|
|
||||||
|
import npyscreen
|
||||||
|
import sys
|
||||||
|
import os
|
||||||
|
|
||||||
|
|
||||||
|
class TestApp(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(
|
||||||
|
npyscreen.TitleFixedText,
|
||||||
|
name="POSTGREY",
|
||||||
|
value="Should Postgrey be used to greylist messages?",
|
||||||
|
editable=False
|
||||||
|
)
|
||||||
|
form.add(npyscreen.FixedText)
|
||||||
|
|
||||||
|
postgrey_text = form.add(
|
||||||
|
npyscreen.MultiLineEditable,
|
||||||
|
name="POSTSRSD",
|
||||||
|
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)
|
||||||
|
|
||||||
|
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))
|
||||||
|
],
|
||||||
|
name="Options",
|
||||||
|
values= ["POSTGREY","POSTSRSD","POLICY_SPF"],
|
||||||
|
scroll_exit=True
|
||||||
|
)
|
||||||
|
|
||||||
|
# This lets the user interact with the Form.
|
||||||
|
form.edit()
|
||||||
|
|
||||||
|
with open('_options.sh', 'w') as output:
|
||||||
|
print('POSTGREY=%i' % (1 if 0 in options.value else 0), file=output)
|
||||||
|
print('POSTSRSD=%i' % (1 if 1 in options.value else 0), file=output)
|
||||||
|
print('POLICY_SPF=%i' % (1 if 2 in options.value else 0), file=output)
|
||||||
|
# print(npyscreen.ThemeManager.default_colors, file=output)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
App = TestApp()
|
||||||
|
App.run()
|
@ -16,6 +16,7 @@ if [ -z "${NONINTERACTIVE:-}" ]; then
|
|||||||
# we install it inside a virtualenv. In this script, we don't have the virtualenv yet
|
# we install it inside a virtualenv. In this script, we don't have the virtualenv yet
|
||||||
# so we install the python package globally.
|
# so we install the python package globally.
|
||||||
hide_output pip3 install "email_validator>=1.0.0" || exit 1
|
hide_output pip3 install "email_validator>=1.0.0" || exit 1
|
||||||
|
hide_output pip3 install npyscreen || exit 1
|
||||||
|
|
||||||
message_box "Mail-in-a-Box Installation" \
|
message_box "Mail-in-a-Box Installation" \
|
||||||
"Hello and thanks for deploying a Mail-in-a-Box!
|
"Hello and thanks for deploying a Mail-in-a-Box!
|
||||||
@ -193,6 +194,8 @@ if [ -z "${STORAGE_ROOT:-}" ]; then
|
|||||||
STORAGE_ROOT=$([[ -z "${DEFAULT_STORAGE_ROOT:-}" ]] && echo "/home/$STORAGE_USER" || echo "$DEFAULT_STORAGE_ROOT")
|
STORAGE_ROOT=$([[ -z "${DEFAULT_STORAGE_ROOT:-}" ]] && echo "/home/$STORAGE_USER" || echo "$DEFAULT_STORAGE_ROOT")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
python3 setup/options-dialog.py
|
||||||
|
|
||||||
# Show the configuration, since the user may have not entered it manually.
|
# Show the configuration, since the user may have not entered it manually.
|
||||||
echo
|
echo
|
||||||
echo "Primary Hostname: $PRIMARY_HOSTNAME"
|
echo "Primary Hostname: $PRIMARY_HOSTNAME"
|
||||||
|
Loading…
Reference in New Issue
Block a user