I have a startup service that uses data mounted on a nfs share. If I boot the 2 machines up at the same time, the nfs share is not available at the moment the service starts, and gets messed up. I would like to just pause the startup script in init.d to wait till the share is available. Has anyone done this?
2 Answers
Okay, so first you need to disable the script from startup
sudo update-rc.d foobar remove
And then add it again as
sudo update-rc.d foobar defaults 99
Replace foobar with your actual script.
Setting the script to defaults 99 will make it the last thing it does, so that should give it the time it needs for share to become available.
-
1Just had to add -f to first command to allow to remove without deleting file. Feb 3, 2015 at 0:03
I know this is a bit old, but since I found it while looking maybe someone else will.
If you're looking for a solution for systemd then here's what I did to make dovecot wait for a nfs mounted /home to be mounted before starting.
systemctl edit dovecot.service
[Unit]
RequiresMountsFor=/home
Save that and the next time you reboot it should be good to go.
You can do that for any service/mountpoint combo.