Skip to content
Snippets Groups Projects
Unverified Commit 77c45fde authored by Gigadoc 2's avatar Gigadoc 2
Browse files

enable multiline commands

parent 6ebd5963
No related branches found
No related tags found
No related merge requests found
......@@ -2,3 +2,12 @@
Runlevel=1
CmdStart=pulseaudio start
CmdStop=pulseaudio stop
[message]
Runlevel=2
CmdStart=
say Subraum startet
sob subraum_startup
CmdStop=
say Subraum faehrt runter
sob subraum_shutdown
......@@ -18,8 +18,8 @@ for section in config.sections():
command = config[section]
try:
runlevel = int(command['Runlevel'])
start = command['CmdStart']
stop = command['CmdStop']
start = command['CmdStart'].splitlines()
stop = command['CmdStop'].splitlines()
if runlevel not in runlevels:
runlevels[runlevel] = list()
runlevels[runlevel].append({ 'name': section, 'start': start, 'stop': stop })
......@@ -31,10 +31,13 @@ old_level = 0
eins = Eins()
def emit_cmd(command_string):
print(f"Emitting cmd: {command_string}")
argv = shlex.split(command_string)
eins.emit_cmd(argv[0], *argv[1:])
def emit_cmds(command_strings):
for command in command_strings:
if command == "":
continue
print(f"Emitting cmd: {command}")
argv = shlex.split(command)
eins.emit_cmd(argv[0], *argv[1:])
# This is a silent command, subinitd already describes the same command
@eins.simple_cmd()
......@@ -48,13 +51,13 @@ def telinit2(new_level):
if i in runlevels:
for command in runlevels[i]:
print(f"Starting {command['name']}")
emit_cmd(command['start'])
emit_cmds(command['start'])
else:
for i in reversed(range(new_level+1, old_level+1)):
if i in runlevels:
for command in runlevels[i]:
print(f"Stopping {command['name']}")
emit_cmd(command['stop'])
emit_cmds(command['stop'])
old_level = new_level
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment