diff options
author | Srikant Patnaik | 2015-02-02 20:04:41 +0530 |
---|---|---|
committer | Srikant Patnaik | 2015-02-02 20:04:41 +0530 |
commit | bf888cd7de73717a02be583713e9989360dce8dc (patch) | |
tree | e7e4ea9cf11a0c820133a3ba29b1ccd34570cd80 | |
parent | 90f5fa69f23a16ebded63bc86056379b2a9cfcad (diff) | |
download | FOSSEE-netbook-patcher-bf888cd7de73717a02be583713e9989360dce8dc.tar.gz FOSSEE-netbook-patcher-bf888cd7de73717a02be583713e9989360dce8dc.tar.bz2 FOSSEE-netbook-patcher-bf888cd7de73717a02be583713e9989360dce8dc.zip |
[NOT IMP] Added internet check API
-rwxr-xr-x[-rw-r--r--] | patcher.sh | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/patcher.sh b/patcher.sh index d256481..dce2c55 100644..100755 --- a/patcher.sh +++ b/patcher.sh @@ -1,21 +1,29 @@ #!/bin/bash -HEAD_NOW='' -HEAD_PREV='' +INET_AVAILABLE=0 -#<check internet> -# -#</check internet> +#<check internet> handles both network and internet availability +function check_internet() { + for each in {fossee.in,spoken-tutorial.org}; 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 +} #<fetch updates> from github and show function fetch_updates() { -UPDATES=$(git fetch && \ - comm --nocheck-order -3 \ - <(git log --all --pretty="%H")\ - <(git log --pretty="%H")) -git show -s --format=%B $UPDATES + UPDATES=$(git fetch &> /dev/null && \ + comm --nocheck-order -3 \ + <(git log --all --pretty="%H")\ + <(git log --pretty="%H")) + git show -s --format=%B $UPDATES } - - +check_internet +fetch_updates |