Merge @dr-dolomite 's for-merging branch

-Create new development-v2 branch to work on simpleadmin v2

-Merged @dr-dolomite work from:
2d197220a4

Co-Authored-By: Russel Yasol <73575327+dr-dolomite@users.noreply.github.com>
This commit is contained in:
iamromulan
2024-05-03 15:46:25 -04:00
parent 906688f458
commit c9d0e45aa3
32 changed files with 3702 additions and 2053 deletions

View File

@@ -1,13 +0,0 @@
#!/bin/bash
if [ ! -f /tmp/modemstatus.json ]
then
/usrdata/simpleadmin/scripts/modemstatus_parse.sh > /dev/null
fi
runcmd=$(</tmp/modemstatus.json)
echo "Content-type: text/json"
echo ""
cat <<EOT
$runcmd

View File

@@ -0,0 +1,19 @@
#!/bin/bash
# This script will ping 8.8.8.8 and return the result
# If the ping is successful, it will return "OK"
# If the ping fails, it will return "ERROR"
# Send the ping command and store the output
ping_output=$(ping -c 1 8.8.8.8)
# Check if the output contains "0% packet loss"
if echo "$ping_output" | grep -q "0% packet loss"; then
echo "Content-type: text/plain"
echo ""
echo "OK"
else
echo "Content-type: text/plain"
echo ""
echo "ERROR"
fi

View File

@@ -5,10 +5,6 @@ SMS_MESSAGE_INDICATION="AT+CNMI=2,1"
SMS_FORMAT="AT+CMGF=1"
SMS_LIST="AT+CMGL=\"ALL\""
# Send the all the AT commands 1 by 1 with 2 seconds waiting time for each command
runcmd=$(echo -en "$SMS_MESSAGE_INDICATION\r\n" | microcom -t 1000 /dev/ttyOUT2)
runcmd=$(echo -en "$SMS_FORMAT\r\n" | microcom -t 1000 /dev/ttyOUT2)
while true; do
runcmd=$(echo -en "$SMS_LIST\r\n" | microcom -t 2000 /dev/ttyOUT2)
if [[ $runcmd =~ "OK" ]] || [[ $runcmd =~ "ERROR" ]]; then

View File

@@ -1,7 +1,7 @@
#!/bin/bash
# Check iptables for ttlvalue
ttlvalue=$(/opt/bin/sudo /usr/sbin/iptables -w 5 -t mangle -vnL | grep TTL | awk '{print $13}' | head -n1)
ttlvalue=$(iptables -t mangle -vnL | awk '/TTL/ {print $13; exit}')
ttlenabled=true;
# Set Variables
@@ -17,4 +17,4 @@ cat <<EOT
"isEnabled": $ttlenabled,
"ttl": $ttlvalue
}
EOT
EOT

View File

@@ -0,0 +1,44 @@
#!/bin/bash
QUERY_STRING=$(echo "${QUERY_STRING}" | sed 's/;//g')
function urldecode() { : "${*//+/ }"; echo -e "${_//%/\\x}"; }
if [ "${QUERY_STRING}" ]; then
export IFS="&"
for cmd in ${QUERY_STRING}; do
if [ "$(echo $cmd | grep '=')" ]; then
key=$(echo $cmd | awk -F '=' '{print $1}')
value=$(echo $cmd | awk -F '=' '{print $2}')
eval $key=$value
fi
done
fi
# Extract phone number and message from inputs
phone_number="$number"
message="$msg"
# Prepare AT command with phone number and message
ATCMD="AT+CMGS=\"$phone_number\""
MYATCMD=$(printf '%b\n' "${ATCMD//%/\\x}")
if [ -n "${MYATCMD}" ]; then
x=$(urldecode "$ATCMD")
# Send the AT command to initiate message sending
echo -en "$x\r\n" | microcom /dev/ttyOUT2
# Wait for a brief moment (assuming the message sending is instantaneous)
sleep 1
fi
# Send the message
echo -en "$message\c"
# Send Ctrl+Z to terminate the message
echo -en "\032"
# Ensure microcom reads the response (assuming microcom will show response instantly)
sleep 1
# Capture and output the response
runcmd=$(microcom /dev/ttyOUT2)
echo "Content-type: text/plain"
echo "$runcmd"

View File

@@ -1,5 +1,5 @@
#!/bin/bash
PATH=/bin:/usr/sbin:/usr/bin:/sbin:/opt/sbin:/opt/bin:/usrdata/root/bin
# Get query
QUERY_STRING=$(echo "${QUERY_STRING}" | sed 's/;//g')
@@ -22,28 +22,28 @@ setTTL=$(printf '%b\n' "${ttlvalue//%/\\x}")
if [ -n "${setTTL}" ]; then
# Stop Service To Remove Rules
/opt/bin/sudo /usrdata/simplefirewall/ttl-override stop
/usrdata/simplefirewall/ttl-override stop
# Check iptables is still set
ttlcheck=$(/opt/bin/sudo /usr/sbin/iptables -w 5 -t mangle -vnL | grep TTL | awk '{print $13}')
ttlcheck=$(iptables -t mangle -vnL | grep TTL | awk '{print $13}')
# If TTL is still set manually remove values
if [ ! -z "${ttlcheck}" ]; then
/opt/bin/sudo /usr/sbin/iptables -w 5 -t mangle -D POSTROUTING -o rmnet+ -j TTL --ttl-set ${ttlcheck} &>/dev/null || true
/opt/bin/sudo /usr/sbin/ip6tables -w 5 -t mangle -D POSTROUTING -o rmnet+ -j HL --hl-set ${ttlcheck} &>/dev/null || true
if [ !-z "${ttlcheck}" ]; then
iptables -t mangle -D POSTROUTING -o rmnet+ -j TTL --ttl-set ${ttlcheck} &>/dev/null || true
ip6tables -t mangle -D POSTROUTING -o rmnet+ -j HL --hl-set ${ttlcheck} &>/dev/null || true
fi
# Echo TTL to file
echo $setTTL > /usrdata/simplefirewall/ttlvalue
# Set Start Service
/opt/bin/sudo /usrdata/simplefirewall/ttl-override start
/usrdata/simplefirewall/ttl-override start
fi
# Check iptables for ttlvalue
ttlvalue=$(/opt/bin/sudo /usr/sbin/iptables -w 5 -t mangle -vnL | grep TTL | awk '{print $13}')
ttlvalue=$(iptables -t mangle -vnL | grep TTL | awk '{print $13}')
ttlenabled=true;
# Set Variables
@@ -58,5 +58,4 @@ cat <<EOT
{
"isEnabled": $ttlenabled,
"ttl": $ttlvalue
}
EOT
}