mirror of
https://github.com/sixfab/Sixfab_PPP_Installer
synced 2024-11-14 15:24:52 +00:00
Functions and config is seperated from reconnect scripts
This commit is contained in:
parent
9024ad56f2
commit
0db047c03c
5
ppp_installer/configs.sh
Normal file
5
ppp_installer/configs.sh
Normal file
@ -0,0 +1,5 @@
|
||||
#!/binenv bash
|
||||
|
||||
INTERVAL=60
|
||||
DOUBLE_CHECK_WAIT=10
|
||||
PING_TIMEOUT=9
|
43
ppp_installer/functions.sh
Normal file
43
ppp_installer/functions.sh
Normal file
@ -0,0 +1,43 @@
|
||||
#!/bin/env bash
|
||||
|
||||
function debug()
|
||||
{
|
||||
echo $(date "+%Y/%m/%d - %H:%M:%S :") "$1"
|
||||
}
|
||||
|
||||
function check_network()
|
||||
{
|
||||
NETWORK_TIMEOUT=300 # Check network for ($NETWORK_TIMEOUT x 2 Seconds)
|
||||
|
||||
# Check the network is ready
|
||||
debug "Checking the network is ready..."
|
||||
|
||||
for i in {1..$NETWORK_TIMEOUT}; do
|
||||
NETWORK_OK=0
|
||||
|
||||
debug "SIM Status:"
|
||||
atcom AT+CPIN? OK ERROR 10 | grep "CPIN: READY"
|
||||
SIM_READY=$?
|
||||
|
||||
debug "Network Registeration Status:"
|
||||
# For super SIM
|
||||
atcom AT+CREG? OK ERROR 10 | grep "CREG: 0,5"
|
||||
NETWORK_REG=$?
|
||||
# For native SIM
|
||||
atcom AT+CREG? OK ERROR 10 | grep "CREG: 0,1"
|
||||
NETWORK_REG_2=$?
|
||||
# Combined network registeration status
|
||||
NETWORK_REG=$((NETWORK_REG+NETWORK_REG_2))
|
||||
|
||||
if [[ $SIM_READY -eq 0 ]] && [[ $NETWORK_REG -le 1 ]]; then
|
||||
debug "Network is ready."
|
||||
NETWORK_OK=1
|
||||
return 0
|
||||
break
|
||||
else
|
||||
printf "?"
|
||||
fi
|
||||
sleep 2
|
||||
done
|
||||
return 1
|
||||
}
|
@ -1,48 +1,7 @@
|
||||
#!/bin/env bash
|
||||
|
||||
INTERVAL=60
|
||||
DOUBLE_CHECK_WAIT=10
|
||||
PING_TIMEOUT=9
|
||||
|
||||
function debug()
|
||||
{
|
||||
echo $(date "+%Y/%m/%d - %H:%M:%S :") "$1"
|
||||
}
|
||||
|
||||
function check_network()
|
||||
{
|
||||
# Check the network is ready
|
||||
debug "Checking the network is ready..."
|
||||
|
||||
for i in {1..600}; do
|
||||
NETWORK_OK=0
|
||||
|
||||
debug "SIM Status:"
|
||||
atcom AT+CPIN? OK ERROR 10 | grep "CPIN: READY"
|
||||
SIM_READY=$?
|
||||
|
||||
debug "Network Registeration Status:"
|
||||
# For super SIM
|
||||
atcom AT+CREG? OK ERROR 10 | grep "CREG: 0,5"
|
||||
NETWORK_REG=$?
|
||||
# For native SIM
|
||||
atcom AT+CREG? OK ERROR 10 | grep "CREG: 0,1"
|
||||
NETWORK_REG_2=$?
|
||||
# Combined network registeration status
|
||||
NETWORK_REG=$((NETWORK_REG+NETWORK_REG_2))
|
||||
|
||||
if [[ $SIM_READY -eq 0 ]] && [[ $NETWORK_REG -le 1 ]]; then
|
||||
debug "Network is ready."
|
||||
NETWORK_OK=1
|
||||
return 0
|
||||
break
|
||||
else
|
||||
printf "?"
|
||||
fi
|
||||
sleep 2
|
||||
done
|
||||
return 1
|
||||
}
|
||||
source functions.sh
|
||||
source configs.sh
|
||||
|
||||
if check_network -eq 0; then
|
||||
debug "PPP chatscript is starting...";
|
||||
|
10
ppp_installer/test.sh
Normal file
10
ppp_installer/test.sh
Normal file
@ -0,0 +1,10 @@
|
||||
#!/bin/env bash
|
||||
|
||||
source functions.sh
|
||||
source config.sh
|
||||
|
||||
echo "PING TIMEOUT: " $PING_TIMEOUT
|
||||
echo "DOUBLE CHECK WAIT: " $DOUBLE_CHECK_WAIT
|
||||
echo "INTERVAL: " $INTERVAL
|
||||
|
||||
check_network
|
Loading…
Reference in New Issue
Block a user