Brandon Kim | f271434 | 2020-08-12 19:15:12 -0700 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # |
| 3 | # PSU hard reset (power cycle) script. |
| 4 | # |
| 5 | # Power cycle the entire tray by setting the PSU hotswap reset (GPIO218) to high |
| 6 | # |
| 7 | # Global variable: PSU_HARDRESET_DELAY specifies the number of seconds to wait |
| 8 | # before pulling the trigger. If not specified or zero, the script power cycles |
| 9 | # immediately. |
| 10 | main() { |
| 11 | # Sleep PSU_HARDRESET_DELAY seconds |
| 12 | local psu_delay=$((PSU_HARDRESET_DELAY)) |
| 13 | if ((psu_delay > 0)); then |
| 14 | echo "Sleeping ${psu_delay} seconds before PSU hard reset!" |
| 15 | sleep "${psu_delay}" |
| 16 | fi |
| 17 | |
| 18 | gpioset gpiochip6 26=1 |
| 19 | } |
| 20 | |
| 21 | # Exit without running main() if sourced |
| 22 | return 0 2>/dev/null |
| 23 | |
| 24 | main "$@" |