From fe4ad2411fdffb4286462a076bd5ceeb346072a4 Mon Sep 17 00:00:00 2001 From: saeedjohar Date: Tue, 26 Apr 2022 17:03:13 +0300 Subject: [PATCH] perf: add installation requirements for automatic connection (#34) --- ppp_install.sh | 70 ++++++++++++++++++++++++++------------------------ 1 file changed, 36 insertions(+), 34 deletions(-) diff --git a/ppp_install.sh b/ppp_install.sh index 3bd9be5..44874a4 100755 --- a/ppp_install.sh +++ b/ppp_install.sh @@ -40,7 +40,6 @@ function colored_echo echo -e "$COLOR$1 ${SET}" } - # Check Sixfab path if [[ -e $SIXFAB_PATH ]]; then colored_echo "Sixfab path already exist!" ${SET} @@ -83,45 +82,16 @@ colored_echo "Checking requirements..." colored_echo "Updating headers..." sudo apt-get update -colored_echo "Installing python3 if it is required..." -if ! [ -x "$(command -v python3)" ]; then - sudo apt-get install python3 -y - if [[ $? -ne 0 ]]; then colored_echo "Process failed" ${RED}; exit 1; fi -fi - -colored_echo "Installing pip3 if it is required..." -if ! [ -x "$(command -v pip3)" ]; then - sudo apt-get install python3-pip -y - if [[ $? -ne 0 ]]; then colored_echo "Process failed" ${RED}; exit 1; fi -fi - -colored_echo "Installing or upgrading atcom if it is required..." - -pip3 install -U atcom -if [[ $? -ne 0 ]]; then colored_echo "Process failed" ${RED}; exit 1; fi - -source ~/.profile -if [[ $? -ne 0 ]]; then colored_echo "Process failed" ${RED}; exit 1; fi - - colored_echo "Copying setup files..." cp $SOURCE_PATH/chat-connect chat-connect cp $SOURCE_PATH/chat-disconnect chat-disconnect cp $SOURCE_PATH/provider provider -colored_echo "ppp and wiringpi (gpio tool) installing..." -apt-get install ppp wiringpi -y +colored_echo "ppp installing..." +apt-get install ppp -y if [[ $? -ne 0 ]]; then colored_echo "Process failed" ${RED}; exit 1; fi -# test wiringpi and fix if there is any issue -gpio readall | grep Oops > /dev/null -if [[ $? -ne 1 ]]; then - colored_echo "Known wiringpi issue is detected! Wiringpi is updating..." - wget https://project-downloads.drogon.net/wiringpi-latest.deb - sudo dpkg -i wiringpi-latest.deb -fi - colored_echo "What is your carrier APN?" read carrierapn @@ -223,8 +193,40 @@ do colored_echo "You chose $auto_reconnect" ${GREEN} case $auto_reconnect in - [Yy]* ) colored_echo "Copying setup file..." - + [Yy]* ) + colored_echo "Installing python3 if it is required..." + if ! [ -x "$(command -v python3)" ]; then + sudo apt-get install python3 -y + if [[ $? -ne 0 ]]; then colored_echo "Process failed" ${RED}; exit 1; fi + fi + + colored_echo "Installing pip3 if it is required..." + if ! [ -x "$(command -v pip3)" ]; then + sudo apt-get install python3-pip -y + if [[ $? -ne 0 ]]; then colored_echo "Process failed" ${RED}; exit 1; fi + fi + + colored_echo "Installing or upgrading atcom if it is required..." + + pip3 install -U atcom + if [[ $? -ne 0 ]]; then colored_echo "Process failed" ${RED}; exit 1; fi + + source ~/.profile + if [[ $? -ne 0 ]]; then colored_echo "Process failed" ${RED}; exit 1; fi + + colored_echo "wiringpi (gpio tool) installing..." + apt-get install wiringpi -y + if [[ $? -ne 0 ]]; then colored_echo "WiringPi installation failed \nTry manual insatallation" ${RED} ; fi + + # test wiringpi and fix if there is any issue + gpio readall | grep Oops > /dev/null + if [[ $? -ne 1 ]]; then + colored_echo "Known wiringPi issue is detected! WiringPi is updating..." + wget https://project-downloads.drogon.net/wiringpi-latest.deb + sudo dpkg -i wiringpi-latest.deb + fi + + colored_echo "Copying setup file..." cp $SOURCE_PATH/$SERVICE_NAME $SERVICE_NAME cp $SOURCE_PATH/functions.sh functions.sh cp $SOURCE_PATH/configs.sh configs.sh