tons of updates, should have checked in sooner
[buildscripts] / tor-browser
index c105e6e42ba0ff70592b9ddc7034207ae2afb5e1..9b3212cbc7330e7081bb9319f37894e3a5d38e25 100755 (executable)
@@ -13,7 +13,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-if [[ -s ~/.bashrc ]];then . ~/.bashrc;fi
+if [[ -s ~/.bashrc ]]; then . ~/.bashrc; fi
 
 
 # stable version is shown on:
@@ -24,11 +24,16 @@ if [[ -s ~/.bashrc ]];then . ~/.bashrc;fi
 # we exclude verions with letters, as that seems to
 # be a relatively reliable indication of alpha/beta releases.
 
-vers=($(curl -s https://dist.torproject.org/torbrowser/ \
-          | sed -rn 's#.*href="([0-9]+\.[0-9]+[.0-9]*)/.*#\1#p' \
-          | sort -Vr))
-
-
+# Their server has failed a few times on me, so do some retrying.
+for (( i=0; i <= 6 ; i++ )); do
+  c=$(curl -s https://dist.torproject.org/torbrowser/) && break
+  sleep 15
+done
+if [[ ! $c ]]; then
+  echo "$0: error: failed to curl tor directory listing" >&2
+  exit 1
+fi
+vers=($(printf "%s\n" "$c" | sed -rn 's#.*href="([0-9]+\.[0-9]+[.0-9]*)/.*#\1#p' | sort -Vr))
 
 # by default it has perms for just 1 non-root user, which is ok for now.
 
@@ -57,6 +62,20 @@ if [[ $timestamp != $new_timestamp || ! -e /a/opt/tor-browser_en-US/Browser/star
   # not already installed
   rm -rf tor-browser_en-US
   tar Jxf $f
+
+  ## begin handlers customization
+  dest=/a/opt/tor-browser_en-US/Browser/TorBrowser/Data/Browser/profile.default/handlers.json
+  orig=/p/c/tor-handlers-orig.json
+  src=/p/c/tor-handlers.json
+  if diff -q $src $dest; then
+    echo "Error: handlers file changed. adjust based on upstream"
+    exit 1
+  fi
+  cp $src $dest
+  ## end handlers customization
+
+  cp /p/c/tor-user.js /a/opt/tor-browser_en-US/Browser/TorBrowser/Data/Browser/profile.default/user.js
+
 fi
 
 for x in tor-*.tar.xz; do
@@ -65,4 +84,3 @@ for x in tor-*.tar.xz; do
   [[ $x != $f ]] || continue
   command rm -f $x
 done
-sudo ln -sf /a/opt/tor-browser_en-US/Browser/start-tor-browser /usr/local/bin