Skip to content
View in the app

A better way to browse. Learn more.

Unraid

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Lightweight way to start/stop VM

Featured Replies

Hi everybody,

 

just want to ask if theres a lightweight way to start / stop a vm. 

Maybe with a CLI command that can be packed within a automator script or an app or something more efficent?

 

The way via webGUI is ok, but maybe there is an even more efficient way... because first you need to start the browser, than you have to login in unRAID and then you can start the VM. 

But imho there should be better way - similiar to WoL-Apps...

yes, it`s also possible to fire up a wake on LAN package via CLI command running a CLI, loggin in and so on ... but a simple (double)click on an app-icon is even better :)

 

Thanks for any hint. Have a nice sunday

The 4 virsh

  • virsh start
  • virsh reboot
  • virsh shutdown
  • virsh destroy --graceful

shutdown / reboot may or may not work depending on client; hence, virsh destroy to kill the VM (--graceful to at least attempt to clear cache)

 

  • Author

Thanks - works flawless. 

I`ll try to build a simple Automator script and give a feedback. 
Process should be very simple like.... 

  • open terminal app (hided)
  • ssh into server
  • virsh start <Name of VM>

 

 

49 minutes ago, Maddeen said:

Thanks - works flawless. 

I`ll try to build a simple Automator script and give a feedback. 
Process should be very simple like.... 

  • open terminal app (hided)
  • ssh into server
  • virsh start <Name of VM>

 

 

The putty program includes a command line "plink" that does all that in one line.

plink -pw <unraid root password> root@<unraid IP> virsh start <Name of VM>

  • Author

@testdasiok - the commands themself works as predicted. But now I got another problem. 

Due that I'm a MacOS user I can't get "sshpass" to work. So I can't build a cli command like 

sshpass -p "password" ssh -o StrictHostKeyChecking=no root@YOUR_IP_ADRESS

I need to have a passwordless login via ssh-key.
Normally this wouldn't be a problem for me - I set this up on my Raspberry with no struggles - but on Raspberry it was quite easy.

Copy pub-key to the PI - ready!

 

But the manual I found HERE in the forum, is outdated (Unraid 6.8 and above does not allow executing scripts from the flash (/boot) drive) and nobody have updated this for a current solution

 

Is it possible that I just copy the id_rsa.pub (generated on my mac) to the folder /boot/config/ssh/ - reboot - and everythings fine?

 

 

UPDATE: @jonathanm - thanks for this hint. I dont saw it when I wrote the lines above. I'll try it and give a feedback asap

UPDATE2: @jonathanm - sadly putty is a windows software and not be available for mac :( So the question above is still applies ;-)

Edited by Maddeen

52 minutes ago, Maddeen said:

UPDATE2: @jonathanm - sadly putty is a windows software and not be available for mac

I have it natively installed in linux, so not windows only.

 

https://onvinetech.wordpress.com/2016/01/26/49/

Putty installation on mac, no clue if it includes plink, but it probably does since it looks like an adaptation of linux.

  • Author

@jonathanm - thanks. The good news - I managed to install it.

But know I need your assistance again hoping that the linux adaption is likely the macport. 

After installation I can run the command "putty" .. but it just opens the typical putty GUI :( (see Screen)

But how about using the command plink as you described above? 

Bildschirmfoto 2020-08-25 um 22.03.37.png

Edited by Maddeen

10 minutes ago, Maddeen said:

how about using the command plink as you described above? 

Does the plink file not exist in the same spot as putty?

In the linux distribution, both files are put into /usr/bin

In the windows version, putty.exe and plink.exe are both in the program files/putty folder.

Not having a mac, I'm going to be of limited help here.

  • Author

I got it  ... just need to enter "plink" in the cli instead of "putty" - the typical ?help information appeared :) 

If I match your commands

plink -pw <unraid root password> root@<unraid IP> virsh start <Name of VM>

with my credentials .... magic happens :) 
Now I just need to find a way to wrap this command in an Automator script or a shortcut to start that command with a simple double click without seeing the terminal window appear ;) 

 

Thanks again for you help. As soon as I got a solution I'll make a short summarized guide/documentation for other MacOS users out there :)

runs.jpg

Edited by Maddeen

  • 3 years later...

My approach, a simple program in golang. It can be run by a script at Unraid startup.
./vmhook 192.168.1.2:8151 windows10

At http://192.168.1.2:8151 there will be a “start” button, below is the code and the compiled version of the program. You can add other behavior or other buttons and build the program yourself.
 

// Command to build program:
// go build -trimpath -ldflags "-s -w" -o vmhook main.go

package main

import (
    "fmt"
    "net/http"
    "os"
    "os/exec"
)

func main() {
    if len(os.Args) < 3 {
        fmt.Println("Usage: ./vmhook <address>:<port> <VM_name>")
        return
    }

    addr := os.Args[1]
    vmName := os.Args[2]

    // Handler for the index page
    http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
        // Serve a simple HTML page with a button
        html := `
        <html>
            <head>
                <title>Start Windows10 VM</title>
            </head>
            <body>
                <form action="/start" method="post">
                    <input type="submit" value="Start">
                </form>
            </body>
        </html>
        `
        fmt.Fprintf(w, html)
    })

    // Handler for the start button
    http.HandleFunc("/start", func(w http.ResponseWriter, r *http.Request) {
        // Execute the command "virsh start windows10"
        cmd := exec.Command("virsh", "start", vmName)
        err := cmd.Run()
        if err != nil {
            fmt.Fprintf(w, "Error starting VM: %v", err)
            return
        }
        fmt.Fprintf(w, vmName+" VM has been started successfully")
    })

    // Start the HTTP server
    fmt.Printf("Server is starting on %s\n", addr)
    err := http.ListenAndServe(addr, nil)
    if err != nil {
        fmt.Printf("Server failed to start: %v\n", err)
    }
}

 

vmhook

Edited by leporel

  • 3 months later...
On 8/23/2020 at 9:40 AM, Maddeen said:

@testdasiok - the commands themself works as predicted. But now I got another problem. 

Due that I'm a MacOS user I can't get "sshpass" to work. So I can't build a cli command like 

sshpass -p "password" ssh -o StrictHostKeyChecking=no root@YOUR_IP_ADRESS

I need to have a passwordless login via ssh-key.
Normally this wouldn't be a problem for me - I set this up on my Raspberry with no struggles - but on Raspberry it was quite easy.

Copy pub-key to the PI - ready!

 

But the manual I found HERE in the forum, is outdated (Unraid 6.8 and above does not allow executing scripts from the flash (/boot) drive) and nobody have updated this for a current solution

 

Is it possible that I just copy the id_rsa.pub (generated on my mac) to the folder /boot/config/ssh/ - reboot - and everythings fine?

 

 

UPDATE: @jonathanm - thanks for this hint. I dont saw it when I wrote the lines above. I'll try it and give a feedback asap

UPDATE2: @jonathanm - sadly putty is a windows software and not be available for mac :( So the question above is still applies ;-)

Sorry - very late to the party.

 

To setup auto login with ssh keys I generally use :

ssh-copy-id user@host

Would that not work here?

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...

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.