>Hmm. A tool to wait for a file is needed. So far this should do - /bin/need: > > #!/bin/sh > i=0 > while ! test -e "$1"; do > sleep "0.$i" > test "$i" = 9 || i=$((i+1)) > done
Surely, this already exists? Anyone knows? > Created /var/service/dbus-daemon service. run file: > > #!/bin/sh > #exec >/dev/null > exec 2>&1 > exec </dev/null > test "`pidof systemd`" && exec sv d . This is not entirely correct: "sv d" may exit before "down" signal is acted upon by supervisor. Thus, the service may be restarted yet another time. It's mostly harmless since even if it would be, then it'll be stopped. But this can be avoided using: && sv d . && exec sleep 1 Also, I'm going to switch to using "svc" instead of "sv" in all service scripts. This way, they will be compatible with original daemontools. (Since there are several competing daemontools derivatives, we need to give people a chance to write service scripts which run on any of them, unmodified. Without ugly conditionals. For one, they need either "sv" or "svc" to always work. I vote for "svc" - the original author's name.) > Created /init script. > #!/bin/sh > export PATH=/sbin:/bin:/usr/sbin:/usr/bin > /etc/runit/1 > exec 0>&- 1>&- 2>&- > # In this form, shell won't have an open fd to the script file > exec env - sh -c 'while :; do sleep 9999; done' > > Isn't it a cutie. Cheeky. But we probably need to have a binary which loops on waitpid(-1), not the shell. For one, it'll be smaller. Two, no need to have that sleep process. Third, actually, ":" in some shells _may fail_ (e.g. if received SIGINT. Anyone knows something existing and already suitable? If not, what name would you prefer? > Reboot/poweroff does not need cooperation with init. > > [todo: write it up here] Copied examples/shutdown-1.0 to /app/shutdown-1.0. Installed /sbin/* symlinks as described in README. https://git.busybox.net/busybox/tree/examples/shutdown-1.0/README > What's missing or needs improvement? > > ifplugd_handler needs a better way to code for the "if service FOO exists, > start it, if it does not, it's fine" idiom. Surprisingly, there is no way to do this elegantly in a script. "test -d /var/service/DIR" depends on the fact that service dirs are in /var/service - which may be not true for some other daemontools-like installations. I don't like it. daemontools "svok SERVICE" (which now exists in current git, but not in 1.28.3) is better, but it emits an error message if SERVICE does not exist: it's defined to be silent only if supervisor is not running, not if service does not exist at all. I can just blindly run "svc -u/-d SERVICE" and ignore error messages. But how admin is to know that error is ok here? _______________________________________________ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox