Showing posts with label vmware. Show all posts
Showing posts with label vmware. Show all posts

Wednesday, November 3, 2010

Start and stop VMware virtual machine as service for Linux OS

Here is my simple script for starting(non gui mode) automatically VMWare guests on system startup


[sargis@appsrv ~]# cat /etc/init.d/vm-guests
#!/bin/bash
#
# chkconfig: 235 81 29
# description: Start vmware guests.

# Source function library.
. /etc/rc.d/init.d/functions

case "$1" in
 start)
       echo -n $"Starting vmware guests: "
       su - sargis -c "/usr/bin/vmrun -T ws start /srv/vmware/dsrv/dsrv.vmx nogui"
       echo
       ;;
 stop)
       echo -n $"Shutting down vmware guests: "
       /usr/bin/vmrun -T ws stop /srv/vmware/dsrv/dsrv.vmx
       echo
       ;;
 restart|force-reload)
       stop
       start
       ;;
 *)
      echo $"Usage: $0 {start|stop|restart}"
      exit 2
esac