diff options
author | P. J. McDermott <pj@pehjota.net> | 2018-06-01 23:00:51 (EDT) |
---|---|---|
committer | P. J. McDermott <pj@pehjota.net> | 2018-06-04 01:44:30 (EDT) |
commit | 6a2a1e5f1e5a4a70837a260e9ea57b34ba339981 (patch) | |
tree | 2482a165a7b63308709e32b1ff46278762a91dca | |
parent | 1b208ec3f5f303ed93d958b3d8f6d5732cf1a245 (diff) | |
download | homerc-6a2a1e5f1e5a4a70837a260e9ea57b34ba339981.zip homerc-6a2a1e5f1e5a4a70837a260e9ea57b34ba339981.tar.gz homerc-6a2a1e5f1e5a4a70837a260e9ea57b34ba339981.tar.bz2 |
bin/rc: Expose "bye" daemon cmd as "quit" action in CLI
-rwxr-xr-x | bin/rc | 24 |
1 files changed, 23 insertions, 1 deletions
@@ -263,10 +263,25 @@ status() return 0 } +quit() +{ + if mkfifo -m 0600 "${rc_fifo}" 2>/dev/null; then + # Daemonizing just to quit makes no sense. + error 'No running daemon found' + rm "${rc_fifo}" + return 1 + else + # Signal the running rc daemon. + printf '%s bye\n' "${MAGIC}" 1>"${rc_fifo}" + fi + + return 0 +} + usage() { printf 'Usage: %s {start|stop} <session-type>\n' "${0}" - printf ' or: %s status\n\n' "${0}" + printf ' or: %s {status|quit}\n\n' "${0}" printf '<session-type> is one or more strings of alphanumeric ' printf 'characters\nseparated by colons.\n' @@ -298,6 +313,13 @@ main() fi status ;; + 'quit') + if [ ${#} -ne 1 ]; then + usage 1>&2 + return 1 + fi + quit + ;; *) usage 1>&2 return 1 |