diff options
author | David Timber <dxdt@dev.snart.me> | 2022-05-15 21:31:54 +0800 |
---|---|---|
committer | David Timber <dxdt@dev.snart.me> | 2022-05-15 21:31:54 +0800 |
commit | f0e3d3ef8f9dad895f7b6bc1768630f0ef17912e (patch) | |
tree | 8fed439b2aab75f091c41e5778cbc72ac2c1f20a /src/palhm.py | |
parent | 7d2345ecae07e4b792c60f7d36fa78bb2dc69706 (diff) |
Add boot-report subcmd ...
- Fix palhm-dnssec-check.sh
- Make "tasks" config optional so that PALHM can be used only for
boot-report
Diffstat (limited to 'src/palhm.py')
-rwxr-xr-x | src/palhm.py | 32 |
1 files changed, 26 insertions, 6 deletions
diff --git a/src/palhm.py b/src/palhm.py index 474f0a0..f008736 100755 --- a/src/palhm.py +++ b/src/palhm.py @@ -7,6 +7,7 @@ from abc import ABC, abstractmethod from getopt import getopt import palhm +from palhm.exceptions import InvalidConfigError class ProgConf: @@ -113,6 +114,23 @@ class ModsCmd (Cmd): "Usage: " + sys.argv[0] + " mods" + ''' Prints the available modules to stdout.''') +class BootReportCmd (Cmd): + def __init__ (self, *args, **kwargs): + pass + + def do_cmd (self): + ProgConf.alloc_ctx() + + if ProgConf.ctx.boot_report is None: + raise InvalidConfigError("'boot-report' not configured") + + return ProgConf.ctx.boot_report.do_send(ProgConf.ctx) + + def print_help (): + print( +"Usage: " + sys.argv[0] + " boot-report" + ''' +Send mail of boot report to recipients configured.''') + class HelpCmd (Cmd): def __init__ (self, optlist, args): self.optlist = optlist @@ -138,11 +156,12 @@ Options: -f FILE Load config from FILE instead of the hard-coded default Config: ''' + ProgConf.conf + ''' Commands: - run run a task - config load config and print the contents - help [CMD] print this message and exit normally if [CMD] is not specified. - Print usage of [CMD] otherwise - mods list available modules''') + run run a task + config load config and print the contents + help [CMD] print this message and exit normally if [CMD] is not specified. + Print usage of [CMD] otherwise + mods list available modules + boot-report mail boot report''') return 0 @@ -150,7 +169,8 @@ CmdMap = { "config": ConfigCmd, "run": RunCmd, "help": HelpCmd, - "mods": ModsCmd + "mods": ModsCmd, + "boot-report": BootReportCmd } optlist, args = getopt(sys.argv[1:], "qvf:") |