I need a shell scripting way to determine when a remote linux/OSX has completed all /etc/init.d/* for what ever run levels I have chosen to run in.
since I know I can ssh into a virutal box on my net while it is still booting and run commands like /bin/true or /bin/ps that not everthing is in the state it needs to be.
essentially I need to
while [ ${INIT_STILL_RUNNING_ON_REMOTE_SYSTEN} ]
do
sleep 30
done
ssh remoteUser@remoteSystem:command
You could put a script in the run-level you are interested in that is the last thing to run and first thing to shut down that touches a file somewhere to indicate it has run.
For instance, if you made a script called
S99finishedand put it in the run-level folder it would run last at that run-level. A correspondingK00finishedwould run first when shutting down.S99finishedcould look something like:and
K00finishedcould look something like:Then your startup script would poll until
~/.init_finishedexisted at which point it would go on it’s merry way.Note, the startup scripts run as root, so using the home directory tilde will put it in root’s home. That’s probably not ideal for what you’re doing, but illustrates the point. It’s just as easy to put it in
/var/logor somewhere else common to poll from. Just remember it has to have read permissions for everybody wherever you stick it.