53 lines
1.1 KiB
Bash
Executable File
53 lines
1.1 KiB
Bash
Executable File
#!/bin/sh
|
|
#
|
|
# Script to run the remote control server.
|
|
#
|
|
|
|
PIDFILE=/var/run/puzzlefw_remotectl.pid
|
|
|
|
# Redirect output to console.
|
|
exec &> /dev/console
|
|
|
|
# Read model and serial number from EEPROM.
|
|
model=unknown
|
|
serialnr=0
|
|
dd if=/sys/bus/i2c/devices/0-0050/eeprom bs=1k skip=6 count=1 status=none | tr '\000' '\n' > /tmp/run_remotectl_eeprom
|
|
while read -r cfgitem cfgrest ; do
|
|
if [ "$cfgitem" != "${cfgitem#hw_rev=}" ]; then
|
|
model="${cfgitem#hw_rev=}"
|
|
fi
|
|
if [ "$cfgitem" != "${cfgitem#ethaddr=}" ]; then
|
|
serialnr="${cfgitem#ethaddr=}"
|
|
fi
|
|
done < /tmp/run_remotectl_eeprom
|
|
|
|
echo "model=$model"
|
|
echo "serialnr=$serialnr"
|
|
|
|
# Run remote control server.
|
|
/opt/puzzlefw/bin/remotectl --model "$model" --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
|
|
|