LTE technology bug fixed & username and password requirement added

This commit is contained in:
saeedjohar 2019-05-02 16:42:04 +03:00
parent e19160d5fa
commit c7703946b9

View File

@ -1,37 +1,40 @@
#!/bin/sh #!/bin/sh
# How to use case-esac
YELLOW='\033[1;33m' YELLOW='\033[1;33m'
RED='\033[0;31m' RED='\033[0;31m'
BLUE='\033[1;34m'
SET='\033[0m' SET='\033[0m'
echo "${YELLOW}Please choose your Sixfab Shield:${SET}" echo "${YELLOW}Please choose your Sixfab Shield/HAT:${SET}"
echo "${YELLOW}1: GSM/GPRS Shield${SET}" echo "${YELLOW}1: GSM/GPRS Shield${SET}"
echo "${YELLOW}2: 3G, 4G/LTE Base Shield${SET}" echo "${YELLOW}2: 3G, 4G/LTE Base Shield${SET}"
echo "${YELLOW}3: Cellular IoT App Shield${SET}" echo "${YELLOW}3: Cellular IoT App Shield${SET}"
echo "${YELLOW}4: Cellular IoT HAT${SET}" echo "${YELLOW}4: Cellular IoT HAT${SET}"
read answer read shield_hat
case $answer in case $shield_hat in
1) echo "${YELLOW}You chose GSM/GPRS Shield${SET}";; 1) echo "${YELLOW}You chose GSM/GPRS Shield${SET}";;
2) echo "${YELLOW}You chose Base Shield${SET}";; 2) echo "${YELLOW}You chose Base Shield${SET}";;
3) echo "${YELLOW}You chose CellularIoT Shield${SET}";; 3) echo "${YELLOW}You chose CellularIoT Shield${SET}";;
4) echo "${YELLOW}You chose CellularIoT HAT${SET}";; 4) echo "${YELLOW}You chose CellularIoT HAT${SET}";;
*) echo "${YELLOW}You did not chose 1, 2,3 or 4${SET}"; exit 1; *) echo "${RED}Wrong Selection, exiting${SET}"; exit 1;
esac esac
if [ $answer -eq 3 ] || [ $answer -eq 4 ]; then if [ $shield_hat -eq 3 ] || [ $shield_hat -eq 4 ]; then
echo "${YELLOW}Please choose LTE Technology:${SET}" echo "${YELLOW}Please choose LTE Technology:${SET}"
echo "${YELLOW}1: GPRS/EDGE${SET}" echo "${YELLOW}1: GPRS/EDGE${SET}"
echo "${YELLOW}2: CATM1${SET}" echo "${YELLOW}2: CATM1${SET}"
echo "${YELLOW}3: NB-IoT${SET}" echo "${YELLOW}3: NB-IoT${SET}"
read answer4 read network_technology
case $answer4 in case $network_technology in
1) echo "${YELLOW}You chose GPRS/EDGE${SET}";; 1) echo "${YELLOW}You chose GPRS/EDGE${SET}"
2) echo "${YELLOW}You chose CATM1${SET}";; EXTRA='OK AT+QCFG="band",F,400A0E189F,A0E189F,1\nOK AT+QCFG="nwscanseq",01,1\nOK AT+QCFG="nwscanmode",1,1\nOK AT+QCFG="iotopmode",2,1';;
3) echo "${YELLOW}You chose NB-IoT${SET}";; 2) echo "${YELLOW}You chose CATM1${SET}"
*) echo "${YELLOW}You did not chose 1, 2 or 3${SET}"; exit 1; EXTRA='OK AT+QCFG="band",F,400A0E189F,A0E189F,1\nOK AT+QCFG="nwscanseq",02,1\nOK AT+QCFG="nwscanmode",3,1\nOK AT+QCFG="iotopmode",0,1';;
3) echo "${YELLOW}You chose NB-IoT${SET}"
EXTRA='OK AT+QCFG="band",F,400A0E189F,A0E189F,1\nOK AT+QCFG="nwscanseq",03,1\nOK AT+QCFG="nwscanmode",3,1\nOK AT+QCFG="iotopmode",1,1';;
*) echo "{RED}Wrong Selection, exiting${SET}"; exit 1;
esac esac
fi fi
@ -59,16 +62,16 @@ fi
while [ 1 ] while [ 1 ]
do do
echo "${YELLOW}Do you have updated kernel ? [Y/n] ${SET}" echo "${YELLOW}Do you have updated kernel? [Y/n] ${SET}"
read answer2 read kernelUpdate
case $answer2 in case $kernelUpdate in
Y) break;; [Yy]* ) break;;
n) echo "${YELLOW}rpi-update${SET}" [Nn]* ) echo "${YELLOW}rpi-update${SET}"
rpi-update rpi-update
break;; break;;
*) echo "${YELLOW}You did not choose y, N${SET}";; *) echo "${RED}Wrong Selection, Select among Y or n${SET}";;
esac esac
done done
@ -78,25 +81,36 @@ apt-get install ppp
echo "${YELLOW}What is your carrier APN?${SET}" echo "${YELLOW}What is your carrier APN?${SET}"
read carrierapn read carrierapn
while [ 1 ]
do
echo "${YELLOW}Does your carrier need username and password? [Y/n]${SET}"
read usernpass
case $usernpass in
[Yy]* ) while [ 1 ]
do
echo "${YELLOW}Enter username${SET}"
read username
echo "${YELLOW}Enter password${SET}"
read password
sed -i "s/noauth/#noauth\n$username\n$password/" provider
break
done
break;;
[Nn]* ) break;;
*) echo "${RED}Wrong Selection, Select among Y or n${SET}";;
esac
done
echo "${YELLOW}What is your device communication PORT? (ttyS0/ttyUSB3/etc.)${SET}" echo "${YELLOW}What is your device communication PORT? (ttyS0/ttyUSB3/etc.)${SET}"
read devicename read devicename
if [ $answer4 -eq 1 ]; then
EXTRA='OK AT+QCFG="band",F,400A0E189F,A0E189F,1\nOK AT+QCFG="nwscanseq",01,1\nOK AT+QCFG="nwscanmode",1,1\nOK AT+QCFG="iotopmode",2,1'
elif [ $answer4 -eq 2 ]; then
EXTRA='OK AT+QCFG="band",F,400A0E189F,A0E189F,1\nOK AT+QCFG="nwscanseq",02,1\nOK AT+QCFG="nwscanmode",3,1\nOK AT+QCFG="iotopmode",0,1'
elif [ $answer4 -eq 3 ]; then
EXTRA='OK AT+QCFG="band",F,400A0E189F,A0E189F,1\nOK AT+QCFG="nwscanseq",03,1\nOK AT+QCFG="nwscanmode",3,1\nOK AT+QCFG="iotopmode",1,1'
fi
mkdir -p /etc/chatscripts mkdir -p /etc/chatscripts
if [ $answer -eq 3 ]; then if [ $shield_hat -eq 3 ]; then
sed -i "s/#EXTRA/$EXTRA/" chat-connect sed -i "s/#EXTRA/$EXTRA/" chat-connect
else else
sed -i "/#EXTRA/d" chat-connect sed -i "/#EXTRA/d" chat-connect
@ -115,7 +129,7 @@ if ! (grep -q 'route' /etc/ppp/ip-up ); then
echo "sudo route add default ppp0" >> /etc/ppp/ip-up echo "sudo route add default ppp0" >> /etc/ppp/ip-up
fi fi
if [ $answer -eq 2 ]; then if [ $shield_hat -eq 2 ]; then
if ! (grep -q 'max_usb_current' /boot/config.txt ); then if ! (grep -q 'max_usb_current' /boot/config.txt ); then
echo "max_usb_current=1" >> /boot/config.txt echo "max_usb_current=1" >> /boot/config.txt
fi fi
@ -124,26 +138,26 @@ fi
while [ 1 ] while [ 1 ]
do do
echo "${YELLOW}Do you want to activate auto connect/reconnect service at R.Pi boot up? [Y/n] ${SET}" echo "${YELLOW}Do you want to activate auto connect/reconnect service at R.Pi boot up? [Y/n] ${SET}"
read answer3 read auto_reconnect
case $answer3 in case $auto_reconnect in
Y) echo "${YELLOW}Downloading setup file${SET}" [Yy]* ) echo "${YELLOW}Downloading setup file${SET}"
wget --no-check-certificate https://raw.githubusercontent.com/sixfab/Sixfab_PPP_Installer/master/ppp_installer/reconnect_service -O reconnect.service wget --no-check-certificate https://raw.githubusercontent.com/sixfab/Sixfab_PPP_Installer/master/ppp_installer/reconnect_service -O reconnect.service
if [ $answer -eq 1 ]; then if [ $shield_hat -eq 1 ]; then
wget --no-check-certificate https://raw.githubusercontent.com/sixfab/Sixfab_PPP_Installer/master/ppp_installer/reconnect_gprsshield -O reconnect.sh wget --no-check-certificate https://raw.githubusercontent.com/sixfab/Sixfab_PPP_Installer/master/ppp_installer/reconnect_gprsshield -O reconnect.sh
elif [ $answer -eq 2 ]; then elif [ $shield_hat -eq 2 ]; then
wget --no-check-certificate https://raw.githubusercontent.com/sixfab/Sixfab_PPP_Installer/master/ppp_installer/reconnect_baseshield -O reconnect.sh wget --no-check-certificate https://raw.githubusercontent.com/sixfab/Sixfab_PPP_Installer/master/ppp_installer/reconnect_baseshield -O reconnect.sh
elif [ $answer -eq 3 ]; then elif [ $shield_hat -eq 3 ]; then
wget --no-check-certificate https://raw.githubusercontent.com/sixfab/Sixfab_PPP_Installer/master/ppp_installer/reconnect_cellulariot_app -O reconnect.sh wget --no-check-certificate https://raw.githubusercontent.com/sixfab/Sixfab_PPP_Installer/master/ppp_installer/reconnect_cellulariot_app -O reconnect.sh
elif [ $answer -eq 4 ]; then elif [ $shield_hat -eq 4 ]; then
wget --no-check-certificate https://raw.githubusercontent.com/sixfab/Sixfab_PPP_Installer/master/ppp_installer/reconnect_cellulariot -O reconnect.sh wget --no-check-certificate https://raw.githubusercontent.com/sixfab/Sixfab_PPP_Installer/master/ppp_installer/reconnect_cellulariot -O reconnect.sh
fi fi
@ -157,11 +171,11 @@ do
break;; break;;
n) echo "${YELLOW}To connect to internet run \"sudo pon\" and to disconnect run \"sudo poff\" " [Nn]* ) echo "${YELLOW}To connect to internet run ${BLUE}\"sudo pon\"${YELLOW} and to disconnect run ${BLUE}\"sudo poff\" ${SET}"
break;; break;;
*) echo "${YELLOW}You did not chose Y, N${SET}";; *) echo "${RED}Wrong Selection, Select among Y or n${SET}";;
esac esac
done done
read -p "Press ENTER key to reboot" ENTER
reboot reboot