forked from ni/nilrt-snac
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path_console_config.py
More file actions
41 lines (33 loc) · 1.4 KB
/
_console_config.py
File metadata and controls
41 lines (33 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import argparse
import subprocess
from nilrt_snac._configs._base_config import _BaseConfig
from nilrt_snac.opkg import opkg_helper as opkg
from nilrt_snac import logger
class _ConsoleConfig(_BaseConfig):
def __init__(self):
pass # Nothing to do for now
def configure(self, args: argparse.Namespace) -> None:
print("Deconfiguring console access...")
if not args.dry_run:
subprocess.run(
["nirtcfg", "--set", "section=systemsettings,token=consoleout.enabled,value=False"],
check=True,
)
else:
print("Dry run: would have run nirtcfg --set section=systemsettings,token=consoleout.enabled,value=False")
opkg.remove("sysconfig-settings-console", force_depends=True)
def verify(self, args: argparse.Namespace) -> bool:
print("Verifying console access configuration...")
valid = True
result = subprocess.run(
["nirtcfg", "--get", "section=systemsettings,token=consoleout.enabled"],
check=True,
stdout=subprocess.PIPE,
)
if result.stdout.decode().strip() != "False":
valid = False
logger.error("FOUND: console access not diabled")
if opkg.is_installed("sysconfig-settings-console"):
valid = False
logger.error("FOUND: sysconfig-settings-console still installed.")
return valid