I have a shutdown script that suspends all vmware workstation guests when the host is shutdown.
I manually placed symbolic links to the shutdown script in rc0.d (shutdown) and rc6.d (reboot). (ln -s /etc/init.d/shutdownvms /etc/rc0.d/K00shutdownvms)
The /etc/init.d/shutdownvms script is:
Code:
#! /bin/sh
vms=$(vmrun list | grep '/');
echo $(date) >> /home/log
echo 'total vms:' ${vms} >> /home/log
for vm in ${vms}
do
echo 'suspending vm ' $vm >> /home/log
vmrun suspend $vm soft
echo 'done, sleeping 10 seconds' >> /home/log
sleep 10
done
exit 0
The problem is, my script runs but it shows that there are 0 vms running.
In my rc0.d, I see that there is K01gdm which kills xserver/gdm. I think if those are killed, the VMware guests are also killed. However my script should be firing before that because it has a order of 0.
Maybe when gnome shutdown is trigger, it kills xserver etc.
How do I resolve this?