Prevent acidental acpi shutdown

Help
Anonymous
2012-05-21
2013-04-25

  • Anonymous
    2012-05-21

    Prevent acidental shutdowns on headless solutions:
    Should be default config !

    Add this to the end of  /etc/acpi/powerbtn.sh

    # chaveiro mod
    #Check for powerbutton pressings
    # 1s/(60sXmin)=0.0166666667 min
    s=2 # seconds for second press
    ns="0.0"$((s*1000/60))
    
    last=$(find /tmp/powerbtn -type f -amin -$ns)
    if test "$last" != ""; then
        rm -f /tmp/powerbtn
        shutdown -k -h now "Power button pressed"
    else
        touch /tmp/powerbtn
        shutdown -k -h now "Press power button again in $s seconds to accept."  
    fi
      
    # If all else failed, just initiate a plain shutdown.
    #/sbin/shutdown -h now "Power button pressed"
    

    Add to sources as desired:)