Remotely wake VM?


Go to solution Solved by Squid,

Recommended Posts

In case anyone ever asks, I got this working quite simply by doing the following:

 

#!/bin/bash

f=/path/to/file/on/nextcloud/instance

inotifywait -m -e modify "$f" --format "%e" | while read -r event; do
    if [ "$event" == "MODIFY" ]; then

        cat $f
        contents=$( cat $f )
        if [ $contents == "on" ]; then

                echo "Starting VM"
                virsh start "VM NAMe"

        elif [ $contents == "off" ]; then

                echo "Stopping VM"
                virsh shutdown "VM NAMe"

        fi

    fi
done

 

So basically create a text file on your nextcloud instance and then find the path to it via the terminal. If you then edit the file via the nextcloud web interface or mobile app and set the contents to "on" or "off" it will power the VM on or off accordingly.

Edited by allanp81
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.