You've already forked Geekwom-NASPi-Daemon
All checks were successful
Geekwom NASPi Daemon / Geekwom NASPi Daemon (Bookworm) [arm64] (push) Successful in 10s
43 lines
722 B
Bash
43 lines
722 B
Bash
#!/usr/bin/bash
|
|
|
|
|
|
###
|
|
#
|
|
# Options Section
|
|
#
|
|
###
|
|
|
|
set -e
|
|
set -u
|
|
set -o pipefail
|
|
|
|
|
|
###
|
|
#
|
|
# Runtime Environment
|
|
#
|
|
###
|
|
|
|
/usr/bin/gpioset '0' '17'='1'
|
|
|
|
while [ 1 ]; do
|
|
SIGNAL=$(/usr/bin/gpioget '0' '4')
|
|
if [ "${SIGNAL}" -eq '0' ]; then
|
|
/usr/bin/sleep '0.2s'
|
|
else
|
|
PULSE=$(/bin/date '+%s%N' | /usr/bin/cut '-b1-13')
|
|
while [ "${SIGNAL}" -eq '1' ]; do
|
|
/usr/bin/sleep '0.02s'
|
|
if [ $(($(/bin/date '+%s%N' | /usr/bin/cut '-b1-13')-${PULSE})) -gt '600' ]; then
|
|
/usr/sbin/poweroff
|
|
exit 0
|
|
fi
|
|
SIGNAL=$(/usr/bin/gpioget '0' '4')
|
|
done
|
|
if [ $(($(/usr/bin/date '+%s%N' | /usr/bin/cut '-b1-13')-${PULSE})) -gt '200' ]; then
|
|
/usr/sbin/reboot
|
|
exit 0
|
|
fi
|
|
fi
|
|
done
|