mirror of
https://github.com/sixfab/Sixfab_PPP_Installer
synced 2024-11-14 15:24:52 +00:00
added ppp_installer
This commit is contained in:
parent
3a978b7286
commit
8bc05af94b
14
ppp_installer/chat-connect
Normal file
14
ppp_installer/chat-connect
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
# /etc/chatscripts/chat-connect
|
||||||
|
ABORT "BUSY"
|
||||||
|
ABORT "NO CARRIER"
|
||||||
|
ABORT "NO DIALTONE"
|
||||||
|
ABORT "ERROR"
|
||||||
|
ABORT "NO ANSWER"
|
||||||
|
TIMEOUT 30
|
||||||
|
"" AT
|
||||||
|
OK ATE0
|
||||||
|
OK ATI;+CSUB;+CSQ;+COPS?;+CGREG?;&D2
|
||||||
|
OK AT+CGDCONT=1,"IP","\T",,0,0
|
||||||
|
#EXTRA
|
||||||
|
OK ATD*99#
|
||||||
|
CONNECT
|
8
ppp_installer/chat-disconnect
Normal file
8
ppp_installer/chat-disconnect
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
# /etc/chatscripts/quectel-chat-disconnect
|
||||||
|
ABORT "ERROR"
|
||||||
|
ABORT "NO DIALTONE"
|
||||||
|
SAY "\nSending break to the modem\n"
|
||||||
|
"" +++
|
||||||
|
"" +++
|
||||||
|
"" +++
|
||||||
|
SAY "\nGoodbye\n"
|
135
ppp_installer/install.sh
Normal file
135
ppp_installer/install.sh
Normal file
@ -0,0 +1,135 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# How to use case-esac
|
||||||
|
|
||||||
|
YELLOW='\033[1;33m'
|
||||||
|
RED='\033[0;31m'
|
||||||
|
SET='\033[0m'
|
||||||
|
|
||||||
|
echo "${YELLOW}Please choose your Sixfab Shield:${SET}"
|
||||||
|
echo "${YELLOW}1: GSM/GPRS Shield${SET}"
|
||||||
|
echo "${YELLOW}2: 3G, 4G/LTE Base Shield${SET}"
|
||||||
|
echo "${YELLOW}3: Cellular IoT Shield${SET}"
|
||||||
|
|
||||||
|
read answer
|
||||||
|
case $answer in
|
||||||
|
1) echo "${YELLOW}You chose GSM/GPRS Shield${SET}";;
|
||||||
|
2) echo "${YELLOW}You chose Base Shield${SET}";;
|
||||||
|
3) echo "${YELLOW}You chose Cellular Iot Shield${SET}";;
|
||||||
|
*) echo "${YELLOW}You did not chose 1, 2 or 3${SET}"; exit 1;
|
||||||
|
esac
|
||||||
|
|
||||||
|
echo "${YELLOW}Downloading setup files${SET}"
|
||||||
|
wget --no-check-certificate https://raw.githubusercontent.com/sixfab/rpiShields/master/ppp_installer/chat-connect -O chat-connect
|
||||||
|
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "${RED}Download failed${SET}"
|
||||||
|
exit 1;
|
||||||
|
fi
|
||||||
|
|
||||||
|
wget --no-check-certificate https://raw.githubusercontent.com/sixfab/rpiShields/master/ppp_installer/chat-disconnect -O chat-disconnect
|
||||||
|
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "${RED}Download failed${SET}"
|
||||||
|
exit 1;
|
||||||
|
fi
|
||||||
|
|
||||||
|
wget --no-check-certificate https://raw.githubusercontent.com/sixfab/rpiShields/master/ppp_installer/provider -O provider
|
||||||
|
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "${RED}Download failed${SET}"
|
||||||
|
exit 1;
|
||||||
|
fi
|
||||||
|
|
||||||
|
while [ 1 ]
|
||||||
|
do
|
||||||
|
echo "${YELLOW}Do you have updated kernel ? [Y/n] ${SET}"
|
||||||
|
read answer2
|
||||||
|
|
||||||
|
case $answer2 in
|
||||||
|
Y) break;;
|
||||||
|
|
||||||
|
n) echo "${YELLOW}rpi-update${SET}"
|
||||||
|
rpi-update
|
||||||
|
break;;
|
||||||
|
*) echo "${YELLOW}You did not choose y, N${SET}";;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "${YELLOW}ppp install${SET}"
|
||||||
|
apt-get install ppp
|
||||||
|
|
||||||
|
echo "${YELLOW}What is your carrier APN?${SET}"
|
||||||
|
read carrierapn
|
||||||
|
|
||||||
|
echo "${YELLOW}What is your device communication PORT? (ttyS0/ttyUSB3/etc.)${SET}"
|
||||||
|
read devicename
|
||||||
|
|
||||||
|
EXTRA='OK AT+QCFG="nwscanseq",01,1\nOK AT+QCFG="nwscanmode",1,1\nOK AT+QCFG="iotopmode",2,1'
|
||||||
|
|
||||||
|
mkdir -p /etc/chatscripts
|
||||||
|
if [ $answer -eq 3 ]; then
|
||||||
|
sed -i "s/#EXTRA/$EXTRA/" chat-connect
|
||||||
|
else
|
||||||
|
sed -i "/#EXTRA/d" chat-connect
|
||||||
|
fi
|
||||||
|
|
||||||
|
mv chat-connect /etc/chatscripts/
|
||||||
|
mv chat-disconnect /etc/chatscripts/
|
||||||
|
|
||||||
|
mkdir -p /etc/ppp/peers
|
||||||
|
sed -i "s/#APN/$carrierapn/" provider
|
||||||
|
sed -i "s/#DEVICE/$devicename/" provider
|
||||||
|
mv provider /etc/ppp/peers/provider
|
||||||
|
|
||||||
|
if ! (grep -q 'route' /etc/ppp/ip-up ); then
|
||||||
|
echo "sudo route del default" >> /etc/ppp/ip-up
|
||||||
|
echo "sudo route add default ppp0" >> /etc/ppp/ip-up
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ $answer -eq 2 ]; then
|
||||||
|
if ! (grep -q 'max_usb_current' /boot/config.txt ); then
|
||||||
|
echo "max_usb_current=1" >> /boot/config.txt
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
while [ 1 ]
|
||||||
|
do
|
||||||
|
echo "${YELLOW}Do you want to activate auto connect/reconnect service at R.Pi boot up? [Y/n] ${SET}"
|
||||||
|
read answer3
|
||||||
|
|
||||||
|
case $answer3 in
|
||||||
|
Y) echo "${YELLOW}Downloading setup file${SET}"
|
||||||
|
|
||||||
|
wget --no-check-certificate https://raw.githubusercontent.com/sixfab/rpiShields/master/ppp_installer/reconnect_service -O reconnect.service
|
||||||
|
|
||||||
|
if [ $answer -eq 1 ]; then
|
||||||
|
|
||||||
|
wget --no-check-certificate https://raw.githubusercontent.com/sixfab/rpiShields/master/ppp_installer/reconnect_gprsshield -O reconnect.sh
|
||||||
|
|
||||||
|
elif [ $answer -eq 2 ]; then
|
||||||
|
|
||||||
|
wget --no-check-certificate https://raw.githubusercontent.com/sixfab/rpiShields/master/ppp_installer/reconnect_baseshield -O reconnect.sh
|
||||||
|
|
||||||
|
elif [ $answer -eq 3 ]; then
|
||||||
|
|
||||||
|
wget --no-check-certificate https://raw.githubusercontent.com/sixfab/rpiShields/master/ppp_installer/reconnect_cellulariot -O reconnect.sh
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
mv reconnect.sh /usr/src/
|
||||||
|
mv reconnect.service /etc/systemd/system/
|
||||||
|
|
||||||
|
|
||||||
|
systemctl daemon-reload
|
||||||
|
systemctl enable reconnect.service
|
||||||
|
|
||||||
|
break;;
|
||||||
|
|
||||||
|
n) echo "${YELLOW}To connect to internet run \"sudo pon\" and to disconnect run \"sudo poff\" "
|
||||||
|
break;;
|
||||||
|
*) echo "${YELLOW}You did not chose Y, N${SET}";;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
reboot
|
||||||
|
|
35
ppp_installer/provider
Normal file
35
ppp_installer/provider
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
# /etc/ppp/peers/provider
|
||||||
|
/dev/#DEVICE 115200
|
||||||
|
# The chat script, customize your APN in this file
|
||||||
|
connect 'chat -s -v -f /etc/chatscripts/chat-connect -T #APN'
|
||||||
|
# The close script
|
||||||
|
disconnect 'chat -s -v -f /etc/chatscripts/chat-disconnect'
|
||||||
|
# Hide password in debug messages
|
||||||
|
hide-password
|
||||||
|
# The phone is not required to authenticate
|
||||||
|
noauth
|
||||||
|
# Debug info from pppd
|
||||||
|
debug
|
||||||
|
# If you want to use the HSDPA link as your gateway
|
||||||
|
defaultroute
|
||||||
|
# pppd must not propose any IP address to the peer
|
||||||
|
noipdefault
|
||||||
|
# No ppp compression
|
||||||
|
novj
|
||||||
|
novjccomp
|
||||||
|
noccp
|
||||||
|
ipcp-accept-local
|
||||||
|
ipcp-accept-remote
|
||||||
|
local
|
||||||
|
# For sanity, keep a lock on the serial line
|
||||||
|
lock
|
||||||
|
modem
|
||||||
|
dump
|
||||||
|
updetach
|
||||||
|
# Hardware flow control
|
||||||
|
nocrtscts
|
||||||
|
remotename 3gppp
|
||||||
|
ipparam 3gppp
|
||||||
|
ipcp-max-failure 30
|
||||||
|
# Ask the peer for up to 2 DNS server addresses
|
||||||
|
usepeerdns
|
15
ppp_installer/reconnect_baseshield
Normal file
15
ppp_installer/reconnect_baseshield
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
while true; do
|
||||||
|
|
||||||
|
ping -c 1 8.8.8.8
|
||||||
|
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
echo "Connection up, reconnect not required..."
|
||||||
|
else
|
||||||
|
echo "Connection down, reconnecting..."
|
||||||
|
sudo pon
|
||||||
|
fi
|
||||||
|
|
||||||
|
sleep 1
|
||||||
|
done
|
33
ppp_installer/reconnect_cellulariot
Normal file
33
ppp_installer/reconnect_cellulariot
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
gpio -g mode 20 in
|
||||||
|
gpio -g mode 11 out
|
||||||
|
gpio -g mode 26 out
|
||||||
|
|
||||||
|
gpio -g write 26 0
|
||||||
|
sleep 1
|
||||||
|
gpio -g write 26 1
|
||||||
|
|
||||||
|
while true; do
|
||||||
|
|
||||||
|
if [ $(gpio -g read 20) = "1" ]; then
|
||||||
|
echo "Power up"
|
||||||
|
|
||||||
|
gpio -g write 11 0
|
||||||
|
gpio -g write 11 1
|
||||||
|
sleep 2
|
||||||
|
gpio -g write 11 0
|
||||||
|
sleep 2
|
||||||
|
else
|
||||||
|
ping -c 1 8.8.8.8
|
||||||
|
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
echo "Connection up, reconnect not required..."
|
||||||
|
else
|
||||||
|
echo "Connection down, reconnecting..."
|
||||||
|
sudo pon
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
sleep 1
|
||||||
|
done
|
28
ppp_installer/reconnect_gprsshield
Normal file
28
ppp_installer/reconnect_gprsshield
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
gpio -g mode 19 in
|
||||||
|
gpio -g mode 26 out
|
||||||
|
|
||||||
|
while true; do
|
||||||
|
|
||||||
|
if [ $(gpio -g read 19) = "0" ]; then
|
||||||
|
echo "Power up"
|
||||||
|
|
||||||
|
gpio -g write 26 0
|
||||||
|
gpio -g write 26 1
|
||||||
|
sleep 2
|
||||||
|
gpio -g write 26 0
|
||||||
|
sleep 2
|
||||||
|
else
|
||||||
|
ping -c 1 8.8.8.8
|
||||||
|
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
echo "Connection up, reconnect not required..."
|
||||||
|
else
|
||||||
|
echo "Connection down, reconnecting..."
|
||||||
|
sudo pon
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
sleep 1
|
||||||
|
done
|
14
ppp_installer/reconnect_service
Normal file
14
ppp_installer/reconnect_service
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=PPP Auto Connection
|
||||||
|
After=network.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
ExecStart=/bin/sh /usr/src/reconnect.sh
|
||||||
|
WorkingDirectory=/usr/src/
|
||||||
|
StandardOutput=inherit
|
||||||
|
StandardError=inherit
|
||||||
|
Restart=always
|
||||||
|
User=pi
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
Loading…
Reference in New Issue
Block a user