allanp81 Posted January 19 Share Posted January 19 I only need my VM to be accessible 2 days a week so is there a simple way I could somehow trigger a power on of the VM? I have nextcloud so I thought is there a way using a script that I could watch for the presence of a file or a change of a file to trigger? Quote Link to comment
Solution Squid Posted January 19 Solution Share Posted January 19 Use this as a starting point You'd of course have to modify the scripts with the appropriate commands to turn off the VM Quote Link to comment
allanp81 Posted January 23 Author Share Posted January 23 (edited) 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 January 23 by allanp81 Quote Link to comment
Recommended Posts
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.