July 23, 201510 yr Is there a way to map the power button (i.e. powerdown app that runs when you press power button) to start a KVM?
October 9, 20169 yr I am no expert on Unriad, but linux has a config file that lets you choose a command to send if the power-button is pressed. So if you can find a way to start a VM from command line you can I theory start a VM with the power-button.
October 11, 20169 yr I am no expert on Unriad, but linux has a config file that lets you choose a command to send if the power-button is pressed. So if you can find a way to start a VM from command line you can I theory start a VM with the power-button. Unfortunately that is going to clash with the power down system of unraid. When unraid receives a power button signal, it starts the shutdown process. Remapping that to start a VM is probably not a good idea.
January 18, 20179 yr I know this is an old thread but is the only on that came up when searching how to solve this issue, after some research and testing I have successfully used the power button to start and shutdown a vm. I discovered that /etc/acpi/acpi_handler.sh is the script that is run on a short press of the power button, so i edited that script to run another script instead of shutting down unraid. Below is my edited acpi_handler.sh modified to run my custom script vmstartstop.sh instead of shutting down. nano /etc/acpi/acpi_handler.sh #!/bin/sh # Default acpi script that takes an entry for all actions # limetech - power off via webGui IFS=${IFS}/ set $@ case "$1" in button) case "$2" in power) /mnt/disk1/vm/vmstartstop.sh ;; *) logger "ACPI action $2 is not defined" ;; esac ;; *) logger "ACPI group $1 / action $2 is not defined" ;; esac vmstartstop.sh checks to see if my vm named windows10 is running and starts it if it is not running if it is running it will shut down the windows10 vm.(not my script this is part of another script i found on another forum that does exactly what is needed) #! /bin/bash # only start domain if it's not already running if ! virsh list | grep -q " ${Windows10} .*running" ; then virsh start "Windows10" else # optionally shutdown domain otherwise virsh shutdown "Windows10" fi I hope this helps others , as stated previously in the thread you will no longer be able to shut down unraid using the power button and will need to use the web gui to stop the array then power down or restart unraid.
August 14, 20214 yr Do any of you know if this method still works? I know it's been a while, but I'm trying to replicate it and I cannot get my script to run. The server doesn't shutdown anymore tho, so I might be in the right direction.
April 9, 20224 yr Well, it has been yet a while again, but I similarly ran into the issue of the script not running, even though the server would no longer shut down. I did some more troubleshooting, and it appears there is some kind of issue calling the second script from the first. I do not care about being able to shut down the vm with the button, only starting it, and since virsh has its own error handling I was able to use this modification of the acpi script: #!/bin/sh # Default acpi script that takes an entry for all actions # limetech - power off via webGui IFS=${IFS}/ set $@ case "$1" in button) case "$2" in power) virsh start "your_vm_name_here_in_quotes" &> /dev/null ;; *) logger "ACPI action $2 is not defined" ;; esac ;; *) logger "ACPI group $1 / action $2 is not defined" ;; esac
April 23, 20224 yr And also, if you want your changes to persist reboot (as Unraid holds /etc in RAM), you should create a user script that runs at the startup of array, with the command: sed -i -e 's/\/sbin\/init 0/virsh start "your_vm_name_here_in_quotes" \&> \/dev\/null/g' /etc/acpi/acpi_handler.sh This way it will replace the normal shutdown command in the file with your "start vm" command on every boot. EDIT: Beginning with Unraid 6.10, there are now additional modifications that need to be made, per this thread: I therefore added the following lines to my script: /etc/rc.d/rc.acpid restart sed -i -e 's/#HandlePowerKey=poweroff/HandlePowerKey=ignore/g' /etc/elogind/logind.conf sed -i -e 's/#HandleSuspendKey=suspend/HandleSuspendKey=ignore/g' /etc/elogind/logind.conf sed -i -e 's/#HandleHibernateKey=hibernate/HandleHibernateKey=ignore/g' /etc/elogind/logind.conf /etc/rc.d/rc.elogind restart Edited January 1, 20233 yr by Iron_Eagl Changes to Unraid
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.