HEX
Server:Apache/2.4.65 (Amazon Linux)
System:Linux ip-172-31-26-109.ec2.internal 6.1.155-176.282.amzn2023.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Oct 7 15:53:25 UTC 2025 x86_64
User:apache (48)
PHP:8.4.13
Disabled:NONE
Upload Files
File: //etc/acpi/actions/sleep.sh
#!/usr/bin/bash

PATH=/sbin:/bin:/usr/bin
failed='false'

# Hibernation selects the swapfile with highest priority. Since there may be
# other swapfiles configured, ensure /swap is selected as hibernation
# target by setting to maximum priority.
swap_priority=32767

set -x

case "$2" in
    SBTN|LNXSLPBN:*)
        # The iteration had been placed here to add retry logic to hibernation
        # in case of failures and to avoid force stop of instances after 20min
        logger -t hibernate -p user.notice "Got $2 event, going to hibernate"
        for i in 1 2 3
        do
          if swapon --priority=$swap_priority /swap && sleep 1 && systemctl hibernate; then
                break
          else
                logger -t hibernate -p user.notice "Failed iteration $i"
                swapoff /swap
                sleep 10
          fi
       done
       ;;
    *)
        logger -t hibernate "ACPI action undefined: $2" ;;
esac