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

40 lines
673 B
Plaintext
Raw Normal View History

2024-10-01 20:45:22 +02:00
#!/bin/sh
#
# Script to run the remote control server.
#
PIDFILE=/var/run/puzzlefw_remotectl.pid
# Redirect output to console.
exec &> /dev/console
# Get MAC address without ':' separators.
serialnr=$(tr -d : < /sys/class/net/eth0/address)
# Run remote control server.
/opt/puzzlefw/bin/remotectl --serialnr $serialnr &
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