KillingSpark / rustysd

A service manager that is able to run "traditional" systemd services, written in rust
MIT License
506 stars 15 forks source link

ExecStart with commands like /bin/sh -c '<CMD>' #20

Closed pwFoo closed 4 years ago

pwFoo commented 4 years ago

Is it possible to get that command running as rustysd service? It's a complex shell command which should(?) work with systemd.

ExecStart=/bin/sh -c '/bin/grep -h MODALIAS /sys/bus/*/devices/*/uevent | /usr/bin/cut -d= -f2 | /usr/bin/xargs /sbin/modprobe -abq 2> /dev/null'

Fails with error because of ignored ' and " in the command.

[modules.service][STDERR] EXECV: "/bin/sh" ["sh", "-c", "\'/bin/grep", "-h", "MODALIAS", "/sys/bus/*/devices/*/uevent", "|", "/usr/bin/cut", "-d=", "-f2", "|", "/usr/bin/xargs", "/sbin/modprobe", "-abq", "2>", "/dev/null\'"]
[modules.service][STDERR] -h: line 1: syntax error: unterminated quoted string
KillingSpark commented 4 years ago

Ah that looks like a bug with the parsing of commands. I will look into how to correctly parse this. Currently rustysd splits on spaces but it should probably join again if a " or a ' is found.

KillingSpark commented 4 years ago

So this should be fixed now. Rustysd uses shellwords to parse these strings like bash would. This seems like what most people would expect.

pwFoo commented 4 years ago

Works fine for ExecStart and ExecStartPre 👍