From e37b4d7d9e6994132386dbb9325609f054d1c26b Mon Sep 17 00:00:00 2001 From: Yasin Kaya Date: Thu, 19 Nov 2020 09:51:22 -0800 Subject: [PATCH] added safe checks to wgets --- install.sh | 34 +++++++++++++++++++--------------- install_ppp_jetson.sh | 18 +++--------------- install_supersim.sh | 29 ++++++++++++++--------------- 3 files changed, 36 insertions(+), 45 deletions(-) diff --git a/install.sh b/install.sh index c9771fb..554ca8b 100755 --- a/install.sh +++ b/install.sh @@ -62,26 +62,15 @@ case $shield_hat in esac colored_echo "Downloading setup files..." -wget --no-check-certificate $SOURCE_PATH/chat-connect -O chat-connect -if [ $? -ne 0 ]; then - colored_echo "Download failed" ${RED} - exit 1; -fi +wget --no-check-certificate $SOURCE_PATH/chat-connect -O chat-connect +if [[ $? -ne 0 ]]; then colored_echo "Download failed" ${RED}; exit 1; fi wget --no-check-certificate $SOURCE_PATH/chat-disconnect -O chat-disconnect - -if [ $? -ne 0 ]; then - colored_echo "Download failed" ${RED} - exit 1; -fi +if [[ $? -ne 0 ]]; then colored_echo "Download failed" ${RED}; exit 1; fi wget --no-check-certificate $SOURCE_PATH/provider -O provider - -if [ $? -ne 0 ]; then - colored_echo "Download failed" ${RED} - exit 1; -fi +if [[ $? -ne 0 ]]; then colored_echo "Download failed" ${RED}; exit 1; fi colored_echo "ppp and wiringpi (gpio tool) installing..." apt-get install ppp wiringpi -y @@ -146,35 +135,50 @@ do [Yy]* ) colored_echo "Downloading setup file..." wget --no-check-certificate $SOURCE_PATH/$SERVICE_NAME + if [[ $? -ne 0 ]]; then colored_echo "Download failed" ${RED}; exit 1; fi + wget --no-check-certificate $SOURCE_PATH/functions.sh + if [[ $? -ne 0 ]]; then colored_echo "Download failed" ${RED}; exit 1; fi + wget --no-check-certificate $SOURCE_PATH/configs.sh + if [[ $? -ne 0 ]]; then colored_echo "Download failed" ${RED}; exit 1; fi + wget --no-check-certificate $SOURCE_PATH/configure_modem.sh + if [[ $? -ne 0 ]]; then colored_echo "Download failed" ${RED}; exit 1; fi + wget --no-check-certificate $SOURCE_PATH/$MANAGER_SCRIPT_NAME + if [[ $? -ne 0 ]]; then colored_echo "Download failed" ${RED}; exit 1; fi if [ $shield_hat -eq 1 ]; then wget --no-check-certificate $SCRIPT_PATH/reconnect_gprsshield -O $RECONNECT_SCRIPT_NAME + if [[ $? -ne 0 ]]; then colored_echo "Download failed" ${RED}; exit 1; fi elif [ $shield_hat -eq 2 ]; then wget --no-check-certificate $SCRIPT_PATH/reconnect_baseshield -O $RECONNECT_SCRIPT_NAME + if [[ $? -ne 0 ]]; then colored_echo "Download failed" ${RED}; exit 1; fi elif [ $shield_hat -eq 3 ]; then wget --no-check-certificate $SCRIPT_PATH/reconnect_cellulariot_app -O $RECONNECT_SCRIPT_NAME + if [[ $? -ne 0 ]]; then colored_echo "Download failed" ${RED}; exit 1; fi elif [ $shield_hat -eq 4 ]; then wget --no-check-certificate $SCRIPT_PATH/reconnect_cellulariot -O $RECONNECT_SCRIPT_NAME + if [[ $? -ne 0 ]]; then colored_echo "Download failed" ${RED}; exit 1; fi elif [ $shield_hat -eq 5 ]; then wget --no-check-certificate $SCRIPT_PATH/reconnect_tracker -O $RECONNECT_SCRIPT_NAME + if [[ $? -ne 0 ]]; then colored_echo "Download failed" ${RED}; exit 1; fi elif [ $shield_hat -eq 6 ]; then wget --no-check-certificate $SCRIPT_PATH/reconnect_basehat -O $RECONNECT_SCRIPT_NAME + if [[ $? -ne 0 ]]; then colored_echo "Download failed" ${RED}; exit 1; fi fi diff --git a/install_ppp_jetson.sh b/install_ppp_jetson.sh index 7b52ec3..c01e719 100755 --- a/install_ppp_jetson.sh +++ b/install_ppp_jetson.sh @@ -64,25 +64,13 @@ esac colored_echo "Downloading setup files..." wget --no-check-certificate $SOURCE_PATH/chat-connect -O chat-connect - -if [ $? -ne 0 ]; then - colored_echo "Download failed" ${RED} - exit 1; -fi +if [[ $? -ne 0 ]]; then colored_echo "Download failed" ${RED}; exit 1; fi wget --no-check-certificate $SOURCE_PATH/chat-disconnect -O chat-disconnect - -if [ $? -ne 0 ]; then - colored_echo "Download failed" ${RED} - exit 1; -fi +if [[ $? -ne 0 ]]; then colored_echo "Download failed" ${RED}; exit 1; fi wget --no-check-certificate $SOURCE_PATH/provider -O provider - -if [ $? -ne 0 ]; then - colored_echo "Download failed" ${RED} - exit 1; -fi +if [[ $? -ne 0 ]]; then colored_echo "Download failed" ${RED}; exit 1; fi colored_echo "ppp installing" apt-get install ppp -y diff --git a/install_supersim.sh b/install_supersim.sh index 78d242f..7006210 100644 --- a/install_supersim.sh +++ b/install_supersim.sh @@ -44,25 +44,13 @@ colored_echo "Installing PPP for Sixfab Cellular IoT Shield/HAT with Twilio Supe colored_echo "Downloading setup files..." wget --no-check-certificate $SOURCE_PATH/chat-connect -O chat-connect - -if [ $? -ne 0 ]; then - colored_echo "Download failed" ${RED} - exit 1; -fi +if [[ $? -ne 0 ]]; then colored_echo "Download failed" ${RED}; exit 1; fi wget --no-check-certificate $SOURCE_PATH/chat-disconnect -O chat-disconnect - -if [ $? -ne 0 ]; then - colored_echo "Download failed" ${RED} - exit 1; -fi +if [[ $? -ne 0 ]]; then colored_echo "Download failed" ${RED}; exit 1; fi wget --no-check-certificate $SOURCE_PATH/provider -O provider - -if [ $? -ne 0 ]; then - colored_echo "Download failed" ${RED} - exit 1; -fi +if [[ $? -ne 0 ]]; then colored_echo "Download failed" ${RED}; exit 1; fi colored_echo "ppp and wiringpi (gpio tool) installing..." apt-get install ppp wiringpi -y @@ -90,11 +78,22 @@ do [Yy]* ) colored_echo "Downloading setup file..." wget --no-check-certificate $SOURCE_PATH/$SERVICE_NAME + if [[ $? -ne 0 ]]; then colored_echo "Download failed" ${RED}; exit 1; fi + wget --no-check-certificate $SOURCE_PATH/functions.sh + if [[ $? -ne 0 ]]; then colored_echo "Download failed" ${RED}; exit 1; fi + wget --no-check-certificate $SOURCE_PATH/configs.sh + if [[ $? -ne 0 ]]; then colored_echo "Download failed" ${RED}; exit 1; fi + wget --no-check-certificate $SOURCE_PATH/configure_modem.sh + if [[ $? -ne 0 ]]; then colored_echo "Download failed" ${RED}; exit 1; fi + wget --no-check-certificate $SOURCE_PATH/$MANAGER_SCRIPT_NAME + if [[ $? -ne 0 ]]; then colored_echo "Download failed" ${RED}; exit 1; fi + wget --no-check-certificate $SCRIPT_PATH/reconnect_cellulariot -O $RECONNECT_SCRIPT_NAME + if [[ $? -ne 0 ]]; then colored_echo "Download failed" ${RED}; exit 1; fi mv functions.sh $PPP_PATH mv configs.sh $PPP_PATH