• [6.10.0] acpi_handler.sh modifications been ignored/duplicated.


    vampyre_masquerade
    • Solved Annoyance

    Hi

     

    Recently upgraded from 6.9.2 up to 6.10 stable, the process was quite smooth with only some small hiccups updating my Windows 11 to use the new TMP method.

     

    There is how ever a change in the system through the upgrade that I am unable to rectify. Previously on unraid boot I had a script that modified the acpi_handler.sh to incorporate a script when the power button was pressed, this would determine the state of my Windows 11 VM and Start/Stop the VM if needed. Now it seems to be both performing the VM start as well as the default behaviour of system shutdown i.e. when the power button is pressed the VM will load for about 1 minute before the system force closes it and the array stops for a shutdown.

     

    acpi_handler.sh update script run at array first start. (I have also tried just replacing the entire file instead of the line, no difference)

     

    #!/bin/bash
    sed -i 's|power) /sbin/init 0|power) . /boot/config/plugins/user.scripts/scripts/VMStartStop/script|g' /etc/acpi/acpi_handler.sh

     

    modified acpi_handler.sh file after array start. (so we know its been modified correctly)

     

    #!/bin/sh
    # Default acpi script that takes an entry for all actions

    IFS=${IFS}/
    set $@

    case "$1" in
      button)
        case "$2" in
          power) . /boot/config/plugins/user.scripts/scripts/VMStartStop/script
             ;;
          *) logger "ACPI action $2 is not defined"
             ;;
        esac
        ;;
      *)
    #    logger "ACPI group $1 / action $2 is not defined"
        ;;
    esac
     

    VM control script that is called from acpi_handler.sh.

     

    #! /bin/bash

    # if domain is running, shut down
    if virsh list | grep "Windows 11 .*running" ; then
      virsh shutdown "Windows 11"

    # resume domain if it's paused
    elif virsh list | grep "Windows 11 .*paused" ; then
      virsh resume "Windows 10"
    elif virsh list | grep "Windows 11 .*pmsuspended" ; then
      virsh dompmwakeup "Windows 11"

    # otherwise start domain
    else
      virsh start "Windows 11"
    fi

     

    With nothing changed from the original running scripts except updating the 6.10 I can only assume a critical change has occurred in the new kernel or system version.

    Please don't recommend I use WOL as I already do, or a separate button or device. Been able to just press the power button and treat my server like a desktop is a very convenient feature for all that use the desktop.

     

    Troy




    User Feedback

    Recommended Comments

    After having some free time and no replies I decided to look into this more my self.

     

    After running acpi_listen and pressing the power button I was presented with 2 events.

     

    button/power LNXPWRBN:00 00000080 00000001

    button/power PBTN 00000080 00000000

     

    Not knowing why there was two I decided to modify acpi_handler.sh to reflect the two options. (I do not understand this script at all, had to piece one together from other examples) 

     

    #!/bin/sh
    # Default acpi script that takes an entry for all actions

    IFS=${IFS}/
    set $@

    case "$1" in
      button/power)
        case "$2" in
          PBTN) . /boot/config/plugins/user.scripts/scripts/VMStartStop/script
             ;;
          *) logger "ACPI action $2 is not defined"
             ;;
        esac
        ;;
      button/power)
        case "$2" in
          LNXPWRBN:00) . /boot/config/plugins/user.scripts/scripts/VMStartStop/script
             ;;
          *) logger "ACPI action $2 is not defined"
             ;;
        esac
        ;;
      *)
    #    logger "ACPI group $1 / action $2 is not defined"
        ;;
    esac
     

    So a bit more information but still no further ahead, still shuts down the system like there was no modification at all.

    Link to comment

    I think there is a logical issue with your script. There are duplicate case statements [ button/power ]. Only the first one will be executed. I think you need to adjust your script so your customization is combined into the first case statement. Maybe something more like this:

     

    #!/bin/sh
    # Default acpi script that takes an entry for all actions

    IFS=${IFS}/
    set $@

    case "$1" in
      button/power)
        case "$2" in
          PBTN) . /boot/config/plugins/user.scripts/scripts/VMStartStop/script
             ;;
          LNXPWRBN:00) . /boot/config/plugins/user.scripts/scripts/VMStartStop/script
             ;;
          *) logger "ACPI action $2 is not defined"
             ;;
        esac
        ;;
      *)
    #    logger "ACPI group $1 / action $2 is not defined"
        ;;
    esac

    Link to comment
    12 hours ago, BRiT said:

    I think there is a logical issue with your script. There are duplicate case statements [ button/power ]. Only the first one will be executed. I think you need to adjust your script so your customization is combined into the first case statement. Maybe something more like this:

     

    #!/bin/sh
    # Default acpi script that takes an entry for all actions

    IFS=${IFS}/
    set $@

    case "$1" in
      button/power)
        case "$2" in
          PBTN) . /boot/config/plugins/user.scripts/scripts/VMStartStop/script
             ;;
          LNXPWRBN:00) . /boot/config/plugins/user.scripts/scripts/VMStartStop/script
             ;;
          *) logger "ACPI action $2 is not defined"
             ;;
        esac
        ;;
      *)
    #    logger "ACPI group $1 / action $2 is not defined"
        ;;
    esac

    Hi

    Thanks for the idea, gave it a try and unfortunately nothing changed from the original issue, still ignores the acpi and goes straight to shutdown.

    Link to comment

    WOW this is reallly starting to piss me off now, even if I fully nuke the scripts and make it as simple as possible it still ignores the commands.

     

    First I made a dead simple event handler, /etc/acpi/events/power

    event=button/power
    action=/etc/acpi/VM.sh

     

    Copied the VM handling script into VM.sh and made sure it was executable.

    #! /bin/bash

    # if domain is running, shut down
    if virsh list | grep "Windows 11 .*running" ; then
      virsh shutdown "Windows 11"

    # resume domain if it's paused
    elif virsh list | grep "Windows 11 .*paused" ; then
      virsh resume "Windows 10"
    elif virsh list | grep "Windows 11 .*pmsuspended" ; then
      virsh dompmwakeup "Windows 11"

    # otherwise start domain
    else
      virsh start "Windows 11"
    fi

     

    Reload acpid, press the power button and BAM FFS it still shuts down the system. I'm convinced this cant just be me now, it has to be a bug.

    Link to comment

    As far as i can tell this has never been looked at by the developers as an issue, is it because this is now a defunct feature, or is it been addressed in 6.11.0? Either way knowledge is key.

    Edited by vampyre_masquerade
    • Upvote 1
    Link to comment

    $%^&$%^&*%&$%^&!!!    After all this time i finally figured it out!!!!!!

     

    For some reason after 6.10 both acpid and logind were activly fighting to handle the button calls, so both responded, acpid was working correctly and start my VM but then logind would chime in and shutdown the system.

     

    I modified logind.conf to the below

    HandlePowerKey=ignore
    HandleSuspendKey=ignore
    HandleSuspendKey=ignore
    HandleHibernateKey=ignore

     

    Kept acpi_handler.sh the same

     

    Then modified my array start up script to edit the logind.conf on startup just like the acpi_handler.sh.

     

    • Thanks 1
    Link to comment
    10 hours ago, vampyre_masquerade said:

    Changed Status to Solved

    Hello! Thanks for your post! 

     

    I am facing same issue you do but your solution doesnt work for me. 

     

    I edited etc/elogind/logind.conf same as you:

    Quote

    HandlePowerKey=ignore
    HandleSuspendKey=ignore
    HandleSuspendKey=ignore
    HandleHibernateKey=ignore

     

    I also deleted the line causing shutdown in etc/acpi/acpi_handler.sh

    Quote

     

    #!/bin/sh
    # Default acpi script that takes an entry for all actions

    IFS=${IFS}/
    set $@

    case "$1" in
      button)
        case "$2" in
             ;;
          *) logger "ACPI action $2 is not defined"
             ;;
        esac
        ;;
      *)
    #    logger "ACPI group $1 / action $2 is not defined"
        ;;
    esac

     

     

    However the powerdown button STILL shuts down the server. Dou you have any idea what I am doing wrong? 

    Link to comment
    14 hours ago, Janko said:

    Hello! Thanks for your post! 

     

    I am facing same issue you do but your solution doesnt work for me. 

     

    I edited etc/elogind/logind.conf same as you:

     

    I also deleted the line causing shutdown in etc/acpi/acpi_handler.sh

     

    However the powerdown button STILL shuts down the server. Dou you have any idea what I am doing wrong? 

     

    As far as i can tell there are 2 services that handle the button calls, logind and acpid, with the changes made to the logind config this should disable logind from handling the calls, take note though that the logind config file will be over written with each reboot so a script needs to be used to rewrite the chnages on each boot, this is a simple user script that is run on array start. It just copies a prewritten file from the usb to the system on array start.

     

    cp /boot/config/acpi_handler.sh /etc/acpi/acpi_handler.sh && chmod 755 /etc/acpi/acpi_handler.sh && /etc/rc.d/rc.acpid restart && cp /boot/config/logind.conf /etc/elogind/logind.conf && chmod 644 /etc/elogind/logind.conf && /etc/rc.d/rc.elogind restart

     

    (its all one line), also when you make changes to acpid or logind the service needs to be restarted, maybe you missed that step. Lastly im assuming the acpi_handler needs to have complete information, so the lines about the power button need to stay, but have nothing to run, maybe it defaults to bios if it cant see anything to do with the call.

     

    Tbh thats as far as my knowledge goes, youll have to practice some google fu like i did. I did a quick search and there are lots of discussions on disabling the power button.

    • Thanks 1
    Link to comment
    6 hours ago, vampyre_masquerade said:

    (its all one line), also when you make changes to acpid or logind the service needs to be restarted, maybe you missed that step.

    I sure did! Thank you for your reply!

    Link to comment

    Okay, still doesnt work. Did I missed something else? I am just trying to disable the shutdown button.

     

    What i did:

    1. open MC

    2. edit both files 
    3. restart both services from command line ( /etc/rc.d/rc.elogind restart  /etc/rc.d/rc.acpid restart  )

    4. stopped the array and tried the button - the server shut down

    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
    Add a comment...

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


  • Status Definitions

     

    Open = Under consideration.

     

    Solved = The issue has been resolved.

     

    Solved version = The issue has been resolved in the indicated release version.

     

    Closed = Feedback or opinion better posted on our forum for discussion. Also for reports we cannot reproduce or need more information. In this case just add a comment and we will review it again.

     

    Retest = Please retest in latest release.


    Priority Definitions

     

    Minor = Something not working correctly.

     

    Urgent = Server crash, data loss, or other showstopper.

     

    Annoyance = Doesn't affect functionality but should be fixed.

     

    Other = Announcement or other non-issue.