redpitaya-puzzlefw/sw/buildroot_overlay/opt/puzzlefw/lib/run-remotectl

46 lines
802 B
Plaintext
Raw Permalink Normal View History

2024-10-01 20:45:22 +02:00
#!/bin/sh
#
# Script to run the remote control server.
#
2024-10-04 19:36:04 +02:00
. /opt/puzzlefw/lib/functions.sh
2024-10-01 20:45:22 +02:00
PIDFILE=/var/run/puzzlefw_remotectl.pid
# Redirect output to console.
exec &> /dev/console
2024-10-04 13:12:11 +02:00
# Read model and serial number from EEPROM.
2024-10-04 19:36:04 +02:00
read_eeprom
model="${eeprom_hw_rev:-unknown}"
serialnr="${eeprom_ethaddr:-0}"
2024-10-04 13:12:11 +02:00
echo "model=$model"
echo "serialnr=$serialnr"
2024-10-01 20:45:22 +02:00
# Run remote control server.
2024-10-04 13:12:11 +02:00
/opt/puzzlefw/bin/remotectl --model "$model" --serialnr "$serialnr" &
2024-10-01 20:45:22 +02:00
serverpid=$!
# Write PID file.
echo $serverpid > $PIDFILE
# Wait until server exits.
wait $serverpid
status=$?
rm -f $PIDFILE
echo "Remote control server ended with status=${status}"
if [ $status -eq 10 ]; then
# Got command HALT.
echo "Halting system".
halt
fi
if [ $status -eq 11 ]; then
# Got command REBOOT.
reboot
fi