[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [ooni-probe/master] Add support for parsing command line arguments



commit 0cf4ee626cf3b2661ae6912d57fab63f53d9e70f
Author: Arturo Filastò <art@xxxxxxxxx>
Date:   Fri Jul 3 17:44:13 2015 +0200

    Add support for parsing command line arguments
---
 scripts/install.sh |   47 ++++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 44 insertions(+), 3 deletions(-)

diff --git a/scripts/install.sh b/scripts/install.sh
index 46a6afa..fbdeb93 100644
--- a/scripts/install.sh
+++ b/scripts/install.sh
@@ -8,16 +8,53 @@ set -e
 #
 # It is heavily based upon the get.docker.io script
 
+TOR_DEB_REPO="http://deb.torproject.org/torproject.org";
+CLOUDFRONT="no"
+INSTALL_PT="yes"
+
 # These are the minimum ubuntu and debian version required to use the debian
 # package.
 # Currently you can only set the major version number.
 MIN_DEBIAN_VERSION=8
 MIN_UBUNTU_VERSION=11
-TOR_DEB_REPO="http://deb.torproject.org/torproject.org";
-INSTALL_PT="yes"
 
 url='https://get.ooni.io/'
 
+function usage()
+{
+    echo "This is the ooniprobe install script"
+    echo ""
+    echo "./install.sh"
+    echo "\t-h --help"
+    echo "\t-n Do not install pluggable transports"
+    echo "\t-c Use the cloudfronted Tor debian repository"
+    echo ""
+}
+ 
+while [ "$1" != "" ]; do
+    PARAM=`echo $1 | awk -F= '{print $1}'`
+    VALUE=`echo $1 | awk -F= '{print $2}'`
+    case $PARAM in
+        -h | --help)
+            usage
+            exit
+            ;;
+        -n)
+            INSTALL_PT="no"
+            ;;
+        -c)
+            CLOUDFRONT="yes"
+            ;;
+        *)
+            echo "ERROR: unknown parameter \"$PARAM\""
+            usage
+            exit 1
+            ;;
+    esac
+    shift
+done
+
+
 command_exists() {
 	command -v "$@" > /dev/null 2>&1
 }
@@ -64,7 +101,10 @@ elif command_exists busybox && busybox --list-modules | grep -q wget; then
 	curl='busybox wget --connect-timeout 20 -qO-'
 fi
 
-if ! ($curl $TOR_DEB_REPO | grep "Apache Server at deb.torproject.org");then
+if [ $CLOUDFRONT = "yes" ];then
+  echo '  Using the cloudfronted tor mirror.'
+  TOR_DEB_REPO="https://d3skbh62gb3f3v.cloudfront.net/torproject.org"; 
+elif ! ($curl $TOR_DEB_REPO | grep "Apache Server at deb.torproject.org");then
   echo '  The Tor Debian repository deb.torproject.org appears to be blocked.'
   echo '  Failing over to using the cloudfronted mirror.'
   TOR_DEB_REPO="https://d3skbh62gb3f3v.cloudfront.net/torproject.org"; 
@@ -141,6 +181,7 @@ install_pluggable_transports() {
 }
 
 install_pip() {
+  echo ' Installing pip via get-pip.py'
   $curl https://bootstrap.pypa.io/get-pip.py > /tmp/get-pip.py
   $sh_c "python /tmp/get-pip.py > /dev/null 2>&1"
 }



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits