From 7b9687d4e735d11c6e62a0c6dd4eeed9b542ab0d Mon Sep 17 00:00:00 2001 From: Yasin Kaya Date: Thu, 19 Nov 2020 03:54:45 -0800 Subject: [PATCH] Updated installer.sh files for jetson and Sixfab SIM --- install.sh | 12 ++--- install_ppp_jetson.sh | 104 ++++++++++++++++++++++++++++-------------- install_supersim.sh | 91 ++++++++++++++++++++++++++---------- 3 files changed, 140 insertions(+), 67 deletions(-) diff --git a/install.sh b/install.sh index 33d2cb7..c9771fb 100755 --- a/install.sh +++ b/install.sh @@ -16,10 +16,6 @@ RED='\033[0;31m' BLUE='\033[1;34m' SET='\033[0m' -function debug() -{ - echo $(date "+%Y/%m/%d - %H:%M:%S :") "$1" -} function colored_echo { @@ -30,18 +26,18 @@ function colored_echo # Check Sixfab path if [[ -e $SIXFAB_PATH ]]; then - debug "Path already exist!" + colored_echo "Sixfab path already exist!" ${SET} else sudo mkdir $SIXFAB_PATH - debug "Sixfab path is created." + colored_echo "Sixfab path is created." ${SET} fi # Check PPP path if [[ -e $PPP_PATH ]]; then - debug "Path already exist!" + colored_echo "PPP path already exist!" ${SET} else sudo mkdir $PPP_PATH - debug "PPP path is created." + colored_echo "PPP path is created." ${SET} fi diff --git a/install_ppp_jetson.sh b/install_ppp_jetson.sh index aa021a9..7b52ec3 100755 --- a/install_ppp_jetson.sh +++ b/install_ppp_jetson.sh @@ -1,72 +1,108 @@ -#!/bin/sh -' -Created on July 12, 2019 by Saeed Johar (saeedjohar) -' +#!/bin/bash + +# Created on July 12, 2019 by Saeed Johar (saeedjohar) +# Revised on November 19, 2020 by Yasin Kaya (selengalp) + +SIXFAB_PATH="/opt/sixfab" +PPP_PATH="/opt/sixfab/ppp_connection_manager" + +REPO_PATH="https://raw.githubusercontent.com/sixfab/Sixfab_PPP_Installer" +BRANCH=revision +SOURCE_PATH="$REPO_PATH/$BRANCH/src" +SCRIPT_PATH="$REPO_PATH/$BRANCH/src/reconnect_scripts" +RECONNECT_SCRIPT_NAME="ppp_reconnect.sh" +MANAGER_SCRIPT_NAME="ppp_connection_manager.sh" +SERVICE_NAME="ppp_connection_manager.service" + YELLOW='\033[1;33m' RED='\033[0;31m' BLUE='\033[1;34m' SET='\033[0m' -echo "${YELLOW}Please choose your Sixfab Shield/HAT:${SET}" -echo "${YELLOW}1: GSM/GPRS Shield${SET}" -echo "${YELLOW}2: 3G, 4G/LTE Base Shield${SET}" -echo "${YELLOW}3: Cellular IoT App Shield${SET}" -echo "${YELLOW}4: Cellular IoT HAT${SET}" -echo "${YELLOW}5: Tracker HAT${SET}" -echo "${YELLOW}6: 3G/4G Base HAT${SET}" + +function colored_echo +{ + COLOR=${2:-$YELLOW} + echo -e "$COLOR $1 ${SET}" +} + + +# Check Sixfab path +if [[ -e $SIXFAB_PATH ]]; then + colored_echo "Sixfab path already exist!" ${SET} +else + sudo mkdir $SIXFAB_PATH + colored_echo "Sixfab path is created." ${SET} +fi + +# Check PPP path +if [[ -e $PPP_PATH ]]; then + colored_echo "PPP path already exist!" ${SET} +else + sudo mkdir $PPP_PATH + colored_echo "PPP path is created." ${SET} +fi + +colored_echo "Please choose your Sixfab Shield/HAT:" +colored_echo "1: GSM/GPRS Shield" +colored_echo "2: 3G, 4G/LTE Base Shield" +colored_echo "3: Cellular IoT App Shield" +colored_echo "4: Cellular IoT HAT" +colored_echo "5: Tracker HAT" +colored_echo "6: 3G/4G Base HAT" read shield_hat case $shield_hat in - 1) echo "${YELLOW}You chose GSM/GPRS Shield${SET}";; - 2) echo "${YELLOW}You chose Base Shield${SET}";; - 3) echo "${YELLOW}You chose CellularIoT Shield${SET}";; - 4) echo "${YELLOW}You chose CellularIoT HAT${SET}";; - 5) echo "${YELLOW}You chose Tracker HAT${SET}";; - 6) echo "${YELLOW}You chose 3G/4G Base HAT${SET}";; - *) echo "${RED}Wrong Selection, exiting${SET}"; exit 1; + 1) colored_echo "You chose GSM/GPRS Shield";; + 2) colored_echo "You chose Base Shield";; + 3) colored_echo "You chose CellularIoT Shield";; + 4) colored_echo "You chose CellularIoT HAT";; + 5) colored_echo "You chose Tracker HAT";; + 6) colored_echo "You chose 3G/4G Base HAT";; + *) colored_echo "Wrong Selection, exiting" ${RED}; exit 1; esac -echo "${YELLOW}Downloading setup files${SET}" -wget --no-check-certificate https://raw.githubusercontent.com/sixfab/Sixfab_PPP_Installer/master/ppp_installer/chat-connect -O chat-connect +colored_echo "Downloading setup files..." +wget --no-check-certificate $SOURCE_PATH/chat-connect -O chat-connect if [ $? -ne 0 ]; then - echo "${RED}Download failed${SET}" + colored_echo "Download failed" ${RED} exit 1; fi -wget --no-check-certificate https://raw.githubusercontent.com/sixfab/Sixfab_PPP_Installer/master/ppp_installer/chat-disconnect -O chat-disconnect +wget --no-check-certificate $SOURCE_PATH/chat-disconnect -O chat-disconnect if [ $? -ne 0 ]; then - echo "${RED}Download failed${SET}" - exit 1; + colored_echo "Download failed" ${RED} + exit 1; fi -wget --no-check-certificate https://raw.githubusercontent.com/sixfab/Sixfab_PPP_Installer/master/ppp_installer/provider -O provider +wget --no-check-certificate $SOURCE_PATH/provider -O provider if [ $? -ne 0 ]; then - echo "${RED}Download failed${SET}" - exit 1; + colored_echo "Download failed" ${RED} + exit 1; fi -echo "${YELLOW}ppp install${SET}" +colored_echo "ppp installing" apt-get install ppp -y -echo "${YELLOW}What is your carrier APN?${SET}" +colored_echo "What is your carrier APN?" read carrierapn while [ 1 ] do - echo "${YELLOW}Does your carrier need username and password? [Y/n]${SET}" + colored_echo "Does your carrier need username and password? [Y/n]" read usernpass case $usernpass in [Yy]* ) while [ 1 ] do - echo "${YELLOW}Enter username${SET}" + colored_echo "Enter username" read username - echo "${YELLOW}Enter password${SET}" + colored_echo "Enter password" read password sed -i "s/noauth/#noauth\nuser \"$username\"\npassword \"$password\"/" provider break @@ -75,11 +111,11 @@ do break;; [Nn]* ) break;; - *) echo "${RED}Wrong Selection, Select among Y or n${SET}";; + *) colored_echo "Wrong Selection, Select among Y or n" ${RED};; esac done -echo "${YELLOW}What is your device communication PORT? (ttyS0/ttyUSB3/etc.)${SET}" +colored_echo "What is your device communication PORT? (ttyS0/ttyUSB3/etc.)" read devicename mkdir -p /etc/chatscripts diff --git a/install_supersim.sh b/install_supersim.sh index 297e239..78d242f 100644 --- a/install_supersim.sh +++ b/install_supersim.sh @@ -1,36 +1,71 @@ -#!/bin/sh +#!/bin/bash + +SIXFAB_PATH="/opt/sixfab" +PPP_PATH="/opt/sixfab/ppp_connection_manager" + +REPO_PATH="https://raw.githubusercontent.com/sixfab/Sixfab_PPP_Installer" +BRANCH=revision +SOURCE_PATH="$REPO_PATH/$BRANCH/src" +SCRIPT_PATH="$REPO_PATH/$BRANCH/src/reconnect_scripts" +RECONNECT_SCRIPT_NAME="ppp_reconnect.sh" +MANAGER_SCRIPT_NAME="ppp_connection_manager.sh" +SERVICE_NAME="ppp_connection_manager.service" YELLOW='\033[1;33m' RED='\033[0;31m' BLUE='\033[1;34m' SET='\033[0m' -echo "${YELLOW}Installing PPP for Sixfab Cellular IoT Shield/HAT with Twilio Super SIM${SET}" -echo "${YELLOW}Downloading setup files${SET}" -wget --no-check-certificate https://raw.githubusercontent.com/sixfab/Sixfab_PPP_Installer/master/ppp_installer/chat-connect -O chat-connect +function colored_echo +{ + COLOR=${2:-$YELLOW} + echo -e "$COLOR $1 ${SET}" +} + + +# Check Sixfab path +if [[ -e $SIXFAB_PATH ]]; then + colored_echo "Sixfab path already exist!" ${SET} +else + sudo mkdir $SIXFAB_PATH + colored_echo "Sixfab path is created." ${SET} +fi + +# Check PPP path +if [[ -e $PPP_PATH ]]; then + colored_echo "PPP path already exist!" ${SET} +else + sudo mkdir $PPP_PATH + colored_echo "PPP path is created." ${SET} +fi + +colored_echo "Installing PPP for Sixfab Cellular IoT Shield/HAT with Twilio Super SIM" + +colored_echo "Downloading setup files..." +wget --no-check-certificate $SOURCE_PATH/chat-connect -O chat-connect if [ $? -ne 0 ]; then - echo "${RED}Download failed${SET}" + colored_echo "Download failed" ${RED} exit 1; fi -wget --no-check-certificate https://raw.githubusercontent.com/sixfab/Sixfab_PPP_Installer/master/ppp_installer/chat-disconnect -O chat-disconnect +wget --no-check-certificate $SOURCE_PATH/chat-disconnect -O chat-disconnect if [ $? -ne 0 ]; then - echo "${RED}Download failed${SET}" - exit 1; + colored_echo "Download failed" ${RED} + exit 1; fi -wget --no-check-certificate https://raw.githubusercontent.com/sixfab/Sixfab_PPP_Installer/master/ppp_installer/provider -O provider +wget --no-check-certificate $SOURCE_PATH/provider -O provider if [ $? -ne 0 ]; then - echo "${RED}Download failed${SET}" - exit 1; + colored_echo "Download failed" ${RED} + exit 1; fi -echo "${YELLOW}ppp and wiringpi (gpio tool) install${SET}" -apt install ppp wiringpi -y +colored_echo "ppp and wiringpi (gpio tool) installing..." +apt-get install ppp wiringpi -y mkdir -p /etc/chatscripts @@ -43,33 +78,39 @@ sed -i "s/#DEVICE/ttyUSB3/" provider mv provider /etc/ppp/peers/provider if ! (grep -q 'sudo 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 while [ 1 ] do - echo "${YELLOW}Do you want to activate auto connect/reconnect service at R.Pi boot up? [Y/n] ${SET}" + colored_echo "Do you want to activate auto connect/reconnect service at R.Pi boot up? [Y/n]" read auto_reconnect case $auto_reconnect in - [Yy]* ) echo "${YELLOW}Downloading setup file${SET}" + [Yy]* ) colored_echo "Downloading setup file..." - 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_cellulariot -O reconnect.sh - - mv reconnect.sh /usr/src/ - mv reconnect.service /etc/systemd/system/ + wget --no-check-certificate $SOURCE_PATH/$SERVICE_NAME + wget --no-check-certificate $SOURCE_PATH/functions.sh + wget --no-check-certificate $SOURCE_PATH/configs.sh + wget --no-check-certificate $SOURCE_PATH/configure_modem.sh + wget --no-check-certificate $SOURCE_PATH/$MANAGER_SCRIPT_NAME + wget --no-check-certificate $SCRIPT_PATH/reconnect_cellulariot -O $RECONNECT_SCRIPT_NAME + + mv functions.sh $PPP_PATH + mv configs.sh $PPP_PATH + mv configure_modem.sh $PPP_PATH + mv $RECONNECT_SCRIPT_NAME $PPP_PATH + mv $MANAGER_SCRIPT_NAME $PPP_PATH + mv $SERVICE_NAME /etc/systemd/system/ systemctl daemon-reload - systemctl enable reconnect.service + systemctl enable $SERVICE_NAME break;; - [Nn]* ) echo "${YELLOW}To connect to internet run ${BLUE}\"sudo pon\"${YELLOW} and to disconnect run ${BLUE}\"sudo poff\" ${SET}" + [Nn]* ) echo -e "${YELLOW}To connect to internet run ${BLUE}\"sudo pon\"${YELLOW} and to disconnect run ${BLUE}\"sudo poff\" ${SET}" break;; - *) echo "${RED}Wrong Selection, Select among Y or n${SET}";; + *) colored_echo "Wrong Selection, Select among Y or n" ${RED};; esac done