Combine Dependencies; Other Improvements
-Removed CPU intensive python based telnet server option -Removed Micropython -Renamed AT Telnet Daemon socat-at bridge -Moved TTL related files not part of the www/cgi-bin directory to /simplefirewall -Improved Simplefirewall menu, added ability to change TTL -Combined uninstall and install functions for simpleadmin and dependencies into single functions
This commit is contained in:
@@ -1,31 +0,0 @@
|
||||
#!/usrdata/micropython/micropython
|
||||
|
||||
# Add the /usrdata/micropython directory to sys.path so we can find the external modules.
|
||||
# TODO: Move external modules to lib?
|
||||
# TODO: Recompile Micropython with a syspath set up for our use case.
|
||||
import sys
|
||||
# Remove the home directory from sys.path.
|
||||
if "~/.micropython/lib" in sys.path:
|
||||
sys.path.remove("~/.micropython/lib")
|
||||
sys.path.append("/usrdata/micropython")
|
||||
|
||||
import serial
|
||||
import uos
|
||||
|
||||
|
||||
atcmd = sys.argv[1]
|
||||
|
||||
ser = serial.Serial("/dev/ttyOUT", baudrate=115200)
|
||||
ser.write(atcmd + "\r\n")
|
||||
|
||||
uos.system("sleep 0.025s")
|
||||
# wait for an OK
|
||||
out=r''
|
||||
while ser.in_waiting > 0:
|
||||
out += ser.read(1)
|
||||
|
||||
if "OK" not in str(out):
|
||||
print('Error NOT OK')
|
||||
|
||||
print(out.decode('utf-8'))
|
||||
ser.close()
|
||||
@@ -1,12 +0,0 @@
|
||||
[Unit]
|
||||
Description=TTL Override
|
||||
After=ql-netd.service
|
||||
DefaultDependencies=no
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/usrdata/simpleadmin/ttl/ttl-override start
|
||||
User=root
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
@@ -1,53 +0,0 @@
|
||||
#! /bin/bash
|
||||
|
||||
# Adapted from https://github.com/natecarlson/quectel-rgmii-configuration-notes/blob/main/files/ttl-override
|
||||
# Uses ttlvalue file to read what ttl should be set to
|
||||
|
||||
|
||||
if [ -f /usrdata/simpleadmin/ttl/ttlvalue ];
|
||||
then
|
||||
ttlfile=$(</usrdata/simpleadmin/ttl/ttlvalue)
|
||||
TTLVALUE=$(echo $ttlfile | grep -o "[0-9]\{1,3\}")
|
||||
|
||||
if [ -z "${TTLVALUE}" ]; then
|
||||
echo "Couldnt get proper ttl value from file" >&2
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
# Couldnt find ttlvalue file, lets generate one with 0 ttlvalue (0 = disabled)
|
||||
touch /usrdata/simpleadmin/ttl/ttlvalue && echo '0' > /usrdata/simpleadmin/ttl/ttlvalue
|
||||
exit 1
|
||||
fi
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
if (( $TTLVALUE > 0 )); then
|
||||
echo "Adding TTL override rules: "
|
||||
iptables -t mangle -I POSTROUTING -o rmnet+ -j TTL --ttl-set ${TTLVALUE}
|
||||
ip6tables -t mangle -I POSTROUTING -o rmnet+ -j HL --hl-set ${TTLVALUE}
|
||||
else
|
||||
echo "TTLVALUE set to 0, nothing to do..."
|
||||
fi
|
||||
echo "done"
|
||||
;;
|
||||
stop)
|
||||
if (( $TTLVALUE > 0 )); then
|
||||
echo "Removing TTL override rules: "
|
||||
iptables -t mangle -D POSTROUTING -o rmnet+ -j TTL --ttl-set ${TTLVALUE} &>/dev/null || true
|
||||
ip6tables -t mangle -D POSTROUTING -o rmnet+ -j HL --hl-set ${TTLVALUE} &>/dev/null || true
|
||||
else
|
||||
echo "TTLVALUE set to 0, nothing to do..."
|
||||
fi
|
||||
echo "done"
|
||||
;;
|
||||
restart)
|
||||
$0 stop
|
||||
$0 start
|
||||
;;
|
||||
*)
|
||||
echo "Usage ttl-override { start | stop | restart }" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
exit 0
|
||||
@@ -1 +0,0 @@
|
||||
0
|
||||
@@ -21,7 +21,6 @@ MYATCMD=$(printf '%b\n' "${atcmd//%/\\x}")
|
||||
if [ -n "${MYATCMD}" ]; then
|
||||
x=$(urldecode "$atcmd")
|
||||
runcmd=$(echo -en "$x\r\n" | microcom -t 2000 /dev/ttyOUT)
|
||||
# runcmd=$(/usrdata/simpleadmin/scripts/doAT.py "$MYATCMD")
|
||||
fi
|
||||
|
||||
echo "Content-type: text/plain"
|
||||
|
||||
@@ -22,7 +22,7 @@ setTTL=$(printf '%b\n' "${ttlvalue//%/\\x}")
|
||||
|
||||
if [ -n "${setTTL}" ]; then
|
||||
# Stop Service To Remove Rules
|
||||
/usrdata/simpleadmin/ttl/ttl-override stop
|
||||
/usrdata/simplefirewall/ttl-override stop
|
||||
|
||||
# Check iptables is still set
|
||||
ttlcheck=$(iptables -t mangle -vnL | grep TTL | awk '{print $13}')
|
||||
@@ -34,10 +34,10 @@ if [ -n "${setTTL}" ]; then
|
||||
fi
|
||||
|
||||
# Echo TTL to file
|
||||
echo $setTTL > /usrdata/simpleadmin/ttl/ttlvalue
|
||||
echo $setTTL > /usrdata/simplefirewall/ttlvalue
|
||||
|
||||
# Set Start Service
|
||||
/usrdata/simpleadmin/ttl/ttl-override start
|
||||
/usrdata/simplefirewall/ttl-override start
|
||||
fi
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user