[GUIDE] Simple script to start VMs (MacOS App)


Maddeen

Recommended Posts

Hi there, 

 

one thing that bothers me, is the way to start my virtual machine. 

I only have a gaming vm that's not running 24/7 and only need to be fired up temporary. 

 

Current way is to start your browser, open the URL, log in and start your vm. 

Yes - this is a solution - but not smart :)

 

So I build this simple script to start my vm with just a simple click :)

I don't use windows or linux but I be pretty sure that this can be easy adopted

 

For users of MacOs its pretty simple to realize due to the script editor.

Requirement: You need to enable ssh-key authentication as described here

 

Start the script editor and copy the following into the editor

try
	do shell script "/usr/bin/ssh [email protected] virsh start Windows_10q35_5_own_vBIOS"
	if result contains "Domain Windows_10q35_5_own_vBIOS started" then
		display notification "VM started successfully" with title "Gaming VM"
	else
		display notification "VM couldn't started" with title "Gaming VM"
	end if
on error
	display notification "Script Error" with title "Gaming VM"
end try

 

Only a few things must to be changed based on your preferences

- the IP-Adress of your unraid server - in my script the 192.168.2.1

- the name of your virtual machine - in my script the Windows_10q35_5_own_vBIOS

 

Other things can be changed due to your personal needs.

That concerns all parameters in " " regarding the display notification.

 

Save the script as an app and change the app icon to your wishes :)

 

After that you can enable MacOS notifications to get the most out of the script. (see screenshot)

Ultimate lazy? Maybe you already own "QuickLinks" or other similar apps. With this you can fire up your vm with a simple shortcut ;-)

 

P.S Most common errors are

- Domain is already active --> That means, that the virtual machine is already started

- Domain can't be found --> That indicates, that you got a typo where you set the name of your vm

 

I'm not a developer - all things above based on my research with google - but I'll check if I can add an error specific notification in the future.
In the current script you're only able to see the specific error within the script editor app. 

 

I hope some of you found that little helper useful. Have a nice weekend. 

example_notification.png

Edited by Maddeen
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.