I have an openwrt router (TP-Link MR3040) and on boot I have it check the slider (AP, WISP, 3G/4G mode). The goal was to have it execute the current "slider status" vs the old one, or do nothing if it's the same (before reboot). I just want a critique on making it more elegant.
#!/bin/sh
test=$(cat /root/logs/sliderstatus)
status=""
if grep -qe "sw1.*in hi" /sys/kernel/debug/gpio ; then
if grep -qe "sw2.*in hi" /sys/kernel/debug/gpio ; then
# AP
logger "Configure AP"
status="AP"
else
# WISP
logger "Configure WISP"
status="CLIENT"
fi
else
# 3G
logger "Configure 3G"
status="CUSTOM"
fi
if [ $status != $test ] ; then
case $status in
CLIENT) echo "status is client, executing now"
#sh /root/scripts/shell/CLIENT_MODE.sh &
;;
AP) echo "status is AP, executing now"
#sh /root/scripts/shell/AP_MODE.sh &
;;
CUSTOM) echo "status is CUSTOM, executing now"
;;
*) echo "ERROR status does not match ERROR"
;;
esac
elif [ $status == $test ] ; then
echo " Status: $status and Slider $test are the same"
else
echo "You shouldn't have seen this"
fi