First off, have a look at this article by James on how to get after.local in systemd: systemd and using the after.local script in openSUSE 12.1 - Blogs - openSUSE Forums
While it works for some commands, other commands which rely on a daemon that hasn’t been started at this point will fail. The reason is that this after.local is in reality a “during local”, which gets executed simultaneously with other services in the multi-user.target. IMO the mutli-user.target is not the right place for an after-local servive. I tried other target - including, in my case, having to deal with the portmapper, the rpcbind.target and the remote-fs.target - but none of those worked. Adding a LSB header with the required facility (i.e $rpcbind or $portmap) in after.local didn’t help either.
- see man systemd.special for a description of special targets.
Adding a delay of 4 seconds in after.local would solve the issue with rpcbind. A more elegant approach - although contrary to the sytemd philosophy - is provided by the following function, which waits for the required process to be started before running the command. I called it runafter.
function runafter {
proc=$1
shift
-x $proc ] || return 1
while ( ! /sbin/checkproc $proc ) ; do
sleep 1
done
$* >/dev/null
}
Usage:
runafter daemon command
Example:
runafter /sbin/rpcbind "some command needing rpcbind"
I’m aware that it’s a hack (again) and that a separate after-local target would be a better solution… but I couldn’t find one and don’t know how to create a target in systemd (can we?). Anyway it’s working and allows me to finally boot in systemd.