summaryrefslogtreecommitdiff
path: root/kvmd/apps
diff options
context:
space:
mode:
authorDevaev Maxim <[email protected]>2020-10-15 09:56:52 +0300
committerDevaev Maxim <[email protected]>2020-10-15 09:56:52 +0300
commitd96478b2092a433651712ac27c886c0d174f9484 (patch)
tree5b2d5a8a1175eb75cf277b1ad46900c612de7600 /kvmd/apps
parentde2998a42fb65d3207c1cf64e4b42e1d727f846e (diff)
parenta7f3773e0b47ddeeef5550859927fd4630b14da7 (diff)
Merge branch 'confirm' into master
Diffstat (limited to 'kvmd/apps')
-rw-r--r--kvmd/apps/__init__.py12
-rw-r--r--kvmd/apps/cleanup/__init__.py1
-rw-r--r--kvmd/apps/ipmi/__init__.py1
-rw-r--r--kvmd/apps/kvmd/__init__.py1
-rw-r--r--kvmd/apps/vnc/__init__.py1
5 files changed, 16 insertions, 0 deletions
diff --git a/kvmd/apps/__init__.py b/kvmd/apps/__init__.py
index 7cdaa53b..0318ac09 100644
--- a/kvmd/apps/__init__.py
+++ b/kvmd/apps/__init__.py
@@ -104,6 +104,7 @@ def init(
prog: Optional[str]=None,
description: Optional[str]=None,
add_help: bool=True,
+ check_run: bool=False,
argv: Optional[List[str]]=None,
**load: bool,
) -> Tuple[argparse.ArgumentParser, List[str], Section]:
@@ -118,6 +119,9 @@ def init(
help="Override config options list (like sec/sub/opt=value)")
args_parser.add_argument("-m", "--dump-config", dest="dump_config", action="store_true",
help="View current configuration (include all overrides)")
+ if check_run:
+ args_parser.add_argument("--run", dest="run", action="store_true",
+ help="Run the service")
(options, remaining) = args_parser.parse_known_args(argv)
if options.dump_config:
@@ -135,6 +139,14 @@ def init(
logging.captureWarnings(True)
logging.config.dictConfig(config.logging)
+
+ if check_run and not options.run:
+ raise SystemExit(
+ "To prevent accidental startup, you must specify the --run option to start.\n"
+ "Try the --help option to find out what this service does.\n"
+ "Make sure you understand exactly what you are doing!"
+ )
+
return (args_parser, remaining, config)
diff --git a/kvmd/apps/cleanup/__init__.py b/kvmd/apps/cleanup/__init__.py
index ec6a43c6..0d0ddb71 100644
--- a/kvmd/apps/cleanup/__init__.py
+++ b/kvmd/apps/cleanup/__init__.py
@@ -78,6 +78,7 @@ def main(argv: Optional[List[str]]=None) -> None:
config = init(
prog="kvmd-cleanup",
description="Kill KVMD and clear resources",
+ check_run=True,
argv=argv,
)[2].kvmd
diff --git a/kvmd/apps/ipmi/__init__.py b/kvmd/apps/ipmi/__init__.py
index 749f9750..0d1189c8 100644
--- a/kvmd/apps/ipmi/__init__.py
+++ b/kvmd/apps/ipmi/__init__.py
@@ -38,6 +38,7 @@ def main(argv: Optional[List[str]]=None) -> None:
config = init(
prog="kvmd-ipmi",
description="IPMI to KVMD proxy",
+ check_run=True,
argv=argv,
)[2].ipmi
diff --git a/kvmd/apps/kvmd/__init__.py b/kvmd/apps/kvmd/__init__.py
index 5e99919d..d11512b1 100644
--- a/kvmd/apps/kvmd/__init__.py
+++ b/kvmd/apps/kvmd/__init__.py
@@ -47,6 +47,7 @@ def main(argv: Optional[List[str]]=None) -> None:
prog="kvmd",
description="The main Pi-KVM daemon",
argv=argv,
+ check_run=True,
load_auth=True,
load_hid=True,
load_atx=True,
diff --git a/kvmd/apps/vnc/__init__.py b/kvmd/apps/vnc/__init__.py
index 534768a3..f252e404 100644
--- a/kvmd/apps/vnc/__init__.py
+++ b/kvmd/apps/vnc/__init__.py
@@ -39,6 +39,7 @@ def main(argv: Optional[List[str]]=None) -> None:
config = init(
prog="kvmd-vnc",
description="VNC to KVMD proxy",
+ check_run=True,
argv=argv,
)[2].vnc