Sunday, June 17, 2007

Some script to Shutdown and Start RDesktop XP VM session

Today I created customized shutdown script :
- check the XP VMware , if it is running, change it to suspend
- continue poweroff

The scripts are put in the /usr/local/sbin :
- vmxp -> check vm status
- xp -> start xp vm if not running, and launch rdesktop if already running
- matiin -> to shutdown vm and poweroff host

Content of the script :

vmxp
#!/bin/bash
if [ $# == 0 ]
then
vmware-cmd /home/thartono/data/vmware/Windows\ XP\ Professional.vmx getstate
else
vmware-cmd /home/thartono/data/vmware/Windows\ XP\ Professional.vmx $1
fi
xp
#!/bin/bash

VMSTATE=$(vmxp getstate | awk '{print $3}' )

if [ "$1" == "off" ] && [ "$VMSTATE" == "on" ]
then
echo "Suspending VM"
vmxp suspend

else

if [ "$VMSTATE" == 'off' ]
then
echo VM is off, now starting VM
vmxp start

elif [ "$VMSTATE" == "suspended" ]
then
echo VM is suspended, now starting VM
vmxp start

elif [ "$VMSTATE" == "on" ]
then
echo VM is on - starting Remote Desktop
rdesktop -D -K -g 1024x768 -a 16 192.168.207.129 -u thartono -p MYPASSWORD
fi
fi
matiin
#!/bin/bash
xp off
poweroff

Then we could create 2x GNOME Launcher with the following commands :
1. Power Off
sudo matiin # to shutdown vm and poweroff laptop


2. Start Remote Desktop

xp # to autopoweron XP VM, and open remote desktop session to the XP VM


No comments: