Closed pgaskin closed 4 years ago
I've done some minimal testing with:
menu_item :main :Telnet (toggle) :cmd_output :500:quiet :/usr/bin/pkill -f "^/usr/bin/tcpsvd -E 0.0.0.0 2023"
chain:skip:5
chain_failure :cmd_spawn :quiet :/bin/mount -t devpts | /bin/grep -q /dev/pts || { /bin/mkdir -p /dev/pts && /bin/mount -t devpts devpts /dev/pts; }
chain :cmd_spawn :quiet :exec /usr/bin/tcpsvd -E 0.0.0.0 2023 /usr/sbin/telnetd -i -l /bin/login
chain :dbg_toast :Started Telnet server on port 2023
chain_failure :dbg_toast :Error starting Telnet server on port 2023
chain_always:skip:-1
chain :dbg_toast :Stopped Telnet server on port 2023
Okay, I had a hard time wrapping my head around the use case when you mentioned that in #31, but now it's clearer, thanks ;).
(I just needed to remember that chain
only chains on success ^^. i.e., if pkill returns sucess, stuff was killed -> jump to saying stuff was killed. If not, stuff wasn't up, continue chain to start stuff and skip the rest of the other branch).
I'd possibly find a goto
action more readable than this, but it'd probably be more complex to implement :).
Okay, I had a hard time wrapping my head around the use case when you mentioned that in #31, but now it's clearer, thanks ;).
I ran into this issue a while ago because you can't control the exit status for actions other than cmd_output, but I couldn't think of a sufficiently simple enough way (and non-hacky) to implement it without essentially making the config into a scripting language, which is out of the scope of NickelMenu (it adds unnecessary complexity, opens up a whole can of worms for stability, reduces future extensibility, and there's usually a better way of doing things).
I just needed to remember that chain only chains on success
I got confused by that too. In hindsight, I should have named it chain_success
, but I didn't expect I'd be implementing something like #20 at the time. I could rename it and keep compatibility by silently accepting the old one.
I'd possibly find a goto action more readable than this, but it'd probably be more complex to implement :).
See my first point.
I've done a bit more testing, and I think this is ready.
closes #31