tons of updates, should have checked in sooner
[buildscripts] / tor-browser
index df4dd8c4533093799d790b21147a57f674071a0d..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.