mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-09-19 04:59:01 +00:00
Added option for plinth --setup
Now plinth --setup could take a list of modules to setup
This commit is contained in:
parent
1414db64bf
commit
60e808e9bb
@ -53,7 +53,7 @@ def parse_arguments():
|
|||||||
'--debug', action='store_true', default=cfg.debug,
|
'--debug', action='store_true', default=cfg.debug,
|
||||||
help='enable debugging and run server *insecurely*')
|
help='enable debugging and run server *insecurely*')
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--setup', action='store_true', default=False,
|
'--setup', default=False, nargs='*',
|
||||||
help='run setup tasks on all essential modules and exit')
|
help='run setup tasks on all essential modules and exit')
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--diagnose', action='store_true', default=False,
|
'--diagnose', action='store_true', default=False,
|
||||||
@ -248,11 +248,14 @@ def configure_django():
|
|||||||
os.chmod(cfg.store_file, stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP)
|
os.chmod(cfg.store_file, stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP)
|
||||||
|
|
||||||
|
|
||||||
def run_setup_and_exit():
|
def run_setup_and_exit(module_list):
|
||||||
"""Run setup on all essential modules and exit."""
|
"""Run setup on all essential modules and exit."""
|
||||||
error_code = 0
|
error_code = 0
|
||||||
try:
|
try:
|
||||||
setup.setup_all_modules(essential=True)
|
if not module_list:
|
||||||
|
setup.setup_modules(essential=True)
|
||||||
|
else:
|
||||||
|
setup.setup_modules(module_list)
|
||||||
except Exception as exception:
|
except Exception as exception:
|
||||||
logger.error('Error running setup - %s', exception)
|
logger.error('Error running setup - %s', exception)
|
||||||
error_code = 1
|
error_code = 1
|
||||||
@ -297,8 +300,8 @@ def main():
|
|||||||
|
|
||||||
module_loader.load_modules()
|
module_loader.load_modules()
|
||||||
|
|
||||||
if arguments.setup:
|
if arguments.setup is not None:
|
||||||
run_setup_and_exit()
|
run_setup_and_exit(arguments.setup)
|
||||||
|
|
||||||
if arguments.diagnose:
|
if arguments.diagnose:
|
||||||
run_diagnostics_and_exit()
|
run_diagnostics_and_exit()
|
||||||
|
|||||||
@ -150,11 +150,15 @@ def init(module_name, module):
|
|||||||
module.setup_helper = Helper(module_name, module)
|
module.setup_helper = Helper(module_name, module)
|
||||||
|
|
||||||
|
|
||||||
def setup_all_modules(essential=False):
|
def setup_modules(module_list=None, essential=False):
|
||||||
"""Run setup on all essential modules and exit."""
|
"""Run setup on selected or essential modules."""
|
||||||
logger.info('Running setup for all modules, essential - %s', essential)
|
logger.info('Running setup for modules, essential - %s, '
|
||||||
|
'selected modules - %s', essential, module_list)
|
||||||
for module_name, module in plinth.module_loader.loaded_modules.items():
|
for module_name, module in plinth.module_loader.loaded_modules.items():
|
||||||
if essential and not getattr(module, 'is_essential', False):
|
if essential and not getattr(module, 'is_essential', False):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
if module_list and module_name not in module_list:
|
||||||
|
continue
|
||||||
|
|
||||||
module.setup_helper.run()
|
module.setup_helper.run()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user