Public feed #531100

Someone

public shellscript v1 · immutable
Raw Edit
·published 2007-06-02 11:07 UTC
rendered paste body
#!/bin/bash# $Id$set -e# store cfg file names of automaticly suspended vms in this file, so we # can auto resume on the next start.STATE=/var/run/vmware.suspended;# this function suspends running vms.function stop {	running="";	for vm in `vmware-cmd -l`; do 		state=`vmware-cmd "$vm" getstate | grep "on"`;		if [[ ! -z "$state" ]]; then			running=`echo -e "$running\n$vm"`;			echo "Suspending vm: $vm";			vmware-cmd "$vm" suspend;		fi	done	echo "$running" > "$STATE";}# resume suspended vms.function start {	if [[ -f "$STATE" ]]; then		for vm in `cat "$STATE"`; do 			echo "Resuming vm: $vm";			vmware-cmd "$vm" start;		done		rm "$STATE";	fi}case "$1" in  start)  	start;;  stop)  	stop;;esacexit 0;