From bf888cd7de73717a02be583713e9989360dce8dc Mon Sep 17 00:00:00 2001
From: Srikant Patnaik
Date: Mon, 2 Feb 2015 20:04:41 +0530
Subject: [NOT IMP] Added internet check API
---
patcher.sh | 32 ++++++++++++++++++++------------
1 file changed, 20 insertions(+), 12 deletions(-)
mode change 100644 => 100755 patcher.sh
(limited to 'patcher.sh')
diff --git a/patcher.sh b/patcher.sh
old mode 100644
new mode 100755
index d256481..dce2c55
--- a/patcher.sh
+++ b/patcher.sh
@@ -1,21 +1,29 @@
#!/bin/bash
-HEAD_NOW=''
-HEAD_PREV=''
+INET_AVAILABLE=0
-#
-#
-#
+# 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
+}
# 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
--
cgit