January 19, 20233 yr 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?
January 19, 20233 yr Solution Use this as a starting point You'd of course have to modify the scripts with the appropriate commands to turn off the VM
January 23, 20233 yr Author 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, 20233 yr by allanp81
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.