s6-rc-svscan 724 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #!/bin/execlineb
  2. # execline is used for `piperw`, there is nothing similar in posix shell
  3. elgetopt "l:c:s:"
  4. multisubstitute {
  5. importas -ui LIVE ELGETOPT_l
  6. importas -ui COMPILED ELGETOPT_c
  7. importas -ui SVDIR ELGETOPT_s
  8. }
  9. fdreserve 2
  10. multisubstitute
  11. {
  12. importas -ui fdr FD0
  13. importas -ui fdw FD1
  14. }
  15. piperw "${fdr}" "${fdw}"
  16. getpid -E ppid
  17. background {
  18. fdclose "${fdw}"
  19. fdmove 0 "${fdr}"
  20. withstdinas -NE __new_line
  21. ifelse {
  22. ifelse { test -d "${LIVE}" }
  23. { # then
  24. s6-rc-update -l "${LIVE}" "${COMPILED}"
  25. } # else
  26. s6-rc-init -l "${LIVE}" -c "${COMPILED}" "${SVDIR}"
  27. } { # then
  28. s6-rc -l "${LIVE}" -up change default
  29. } # else
  30. kill "${ppid}"
  31. }
  32. fdclose "${fdr}"
  33. s6-svscan -d "${fdw}" -- "${SVDIR}"