From 47cfa40908970eddc39b36ec5ea27ebe3162df6e Mon Sep 17 00:00:00 2001 From: Srikant Patnaik Date: Tue, 3 Feb 2015 13:30:32 +0530 Subject: [NOT IMP] Error handling in check connectivity --- patcher.sh | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/patcher.sh b/patcher.sh index dce2c55..bd96aca 100755 --- a/patcher.sh +++ b/patcher.sh @@ -1,21 +1,25 @@ #!/bin/bash +source easybashgui -INET_AVAILABLE=0 -# handles both network and internet availability function check_internet() { - for each in {fossee.in,spoken-tutorial.org}; do + for each in {fossee.in,github.com}; + do wget $each/robots.txt &> /dev/null - return_code=$? - [ $return_code -eq 0 ] && INET_AVAILABLE=1 - [ $return_code -eq 4 ] && echo 'Please connect to internet!' - [ $return_code -eq 5 ] && echo 'Please check the system date!' - [ $return_code -eq 8 ] && echo 'Server error' - done - [ $INET_AVAILABLE -eq 0 ] && exit 0 + # return_code=$? + return_code=8 + [ $return_code -eq 0 ] && break + [ $return_code -eq 1 ] && alert_message 'Generic error occured. Working offline. Select Ok to continue.' && break + [ $return_code -eq 3 ] && alert_message 'File I/0 error. Check the permission of the present directory. Working offline. Select Ok to continue' && break + [ $return_code -eq 4 ] && alert_message 'Network failure. Unable to connect internet. Working offline. Select Ok to continue.' && break + [ $return_code -eq 5 ] && alert_message 'SSL verification failure. Check system date. Working offline. Select Ok to continue' && break + [ $return_code -eq 7 ] && alert_message 'Protocol error. Working offline. Select Ok to continue.' && break + done + + [ $return_code -eq 8 ] && alert_message 'Server error. Working offline. Select Ok to continue.' } -# from github and show +#fetch updates from github and show function fetch_updates() { UPDATES=$(git fetch &> /dev/null && \ comm --nocheck-order -3 \ @@ -25,5 +29,7 @@ function fetch_updates() { } + + check_internet fetch_updates -- cgit