Formating, force outdated config check

This commit is contained in:
Spitap
2023-03-12 00:30:04 +01:00
parent 0b29f74e08
commit 6261066ccd
7 changed files with 61 additions and 53 deletions

39
run.py
View File

@@ -116,6 +116,15 @@ def backup_system(config, args):
scripts.backup(app, config, backup_path)
def config_file_update_complete(backup_location):
utils.printcolor("Update complete. It seems successful.",
utils.BLUE)
if backup_location is not None:
utils.printcolor("You will find your old config file "
f"here: {backup_location}",
utils.BLUE)
def main(input_args):
"""Install process."""
parser = argparse.ArgumentParser()
@@ -134,10 +143,6 @@ def main(input_args):
parser.add_argument(
"--stop-after-configfile-check", action="store_true", default=False,
help="Check configuration, generate it if needed and exit")
parser.add_argument(
"--update-configfile", action="store_true", default=False,
help="Attempt to update the config file. "
"Installer will stop after performing the update.")
parser.add_argument(
"--interactive", action="store_true", default=False,
help="Generate configuration file with user interaction")
@@ -184,18 +189,7 @@ def main(input_args):
utils.success("Welcome to Modoboa installer!\n")
# Update configfile
if args.update_configfile:
backup_location = utils.update_config(args.configfile)
utils.printcolor("Update complete. It seems successful.",
utils.BLUE)
if backup_location is not None:
utils.printcolor("You will find your old config file "
f"here: {backup_location}",
utils.BLUE)
return
is_config_file_available = utils.check_config_file(
is_config_file_available, outdate_config = utils.check_config_file(
args.configfile, args.interactive, args.upgrade, args.backup, is_restoring)
if not is_config_file_available and (
@@ -203,6 +197,19 @@ def main(input_args):
utils.error("No config file found.")
return
# Check if config is outdated and ask user if it needs to be updated
if is_config_file_available and outdate_config:
answer = utils.user_input("It seems that your config file is outdated. "
"Would you like to update it? (Y/n) ")
if answer.lower().startswith("y"):
config_file_update_complete(utils.update_config(args.configfile))
answer = utils.user_input("Would you like to stop to review the updated config? (Y/n)")
if answer.lower().startswith("y"):
return
else:
utils.error("You might encounter unexpected errors ! "
"Make sur to update your config before opening an issue!")
if args.stop_after_configfile_check:
return