sched_shutdown 559 B

12345678910111213141516171819202122
  1. #!/bin/sh
  2. # Uncomment the following line to get debug info
  3. #set -x
  4. if [ ${#} != 1 -o "${1}" -eq 0 ]; then
  5. echo "Usage: $(basename ${0}) grace_delay"
  6. exit 1
  7. fi
  8. # Send USR1 signal to the running FunKey process to warn about
  9. # impending shutdown
  10. pkill -USR1 -F /var/run/funkey.pid > /dev/null 2>&1
  11. # Delay for the given grace period seconds to catch signal USR2.
  12. # If the signal is caught, then it means the running FunKey process
  13. # canceled this shutdown and will handle it by itself.
  14. sleep ${1}
  15. # Delay expired, initiate shutdown
  16. shutdown_funkey