4 ms·
> Aren’t you replacing systemd with run_rc_command? This is just as opinionated, but with less features. sure, but this is a 'reasonable shell library' rather
by cat199 7y ago
> Aren’t you replacing systemd with run_rc_command? This is just as opinionated, but with less features.
sure, but this is a 'reasonable shell library' rather than the 'systemd cruft + tentacles' that I mention.
want it to do something else?
write your own functions.
want "an init system that can automatically restart failed services, and with decent dependency management"
here you go:
# cat /etc/daemoncheck
#! /bin/sh
docheck() {
initscript="/etc/rc.d/$1";
if [ -x "$initscript" ]; then
$initscript check > /dev/null \
|| $initscript start
fi
}
docheck ntpd
docheck inetd
docheck dhcpd
docheck tftpd
& throw that, or similar in cron or make it run in a while loop. Nothing precludes
some rudimentary shell script being bundled as part of a simple shell-style init system
out of the box.
I don't need 5000 lines of C code, multiple binaries, 10 layers of symlinks, and all of the rest of it. a few hundred lines of shell that anyone who knows shell and how to read manual pages (that are kept up to date on the actual system, not bad HTML needing 10 tools to render the last time someone thought to update the documentation) can understand the entierty of in literally one sitting.
- theamk 7y agoThanks for the example -- because this is exactly why I am glad we had systemd! I do remember using the gentoo's rc system, and writing the script very much like you wrote here, and it always "kinda works". Specifically, how is "$initscript check" will work? I have seen three approaches: - Sometimes, "check" searches for the process with the given name. That can fail if you are on multi-user system, and a user runs a server on non-standard port. - Sometimes, "check" checks for .pid file, and that process with given pid exists. This can fail if you have high process churn, and your PID got reused. - Sometimes, "check" does completely strange things. Like check that PID file exists, but not the contents -- so it would work fine if you use start/stop commands, but will not notice if the server crashes. So yes, you can do it in shell, and it will work.. most of the time. And hey, you can always fix it -- the first time you discover that your server did not restart, you'd edit the script and add port checking... and then upgrade it to better kill runaway processes.. you can keep going and going. In the end, I think it all brings you back to old pets vs cattle debate. If your server is manually provisioned, each process is carefully tuned, then shell scripts are for you. If you just want to say "install something_d" and have things work, across thousands of systems, at the expense of uglier config and non-optimal file layout -- then more advanced inits are way better.