commit c1beeb1d86c4f73d627a0dd31e800d2fbb0c6878
parent 0108e47a11ed6e8187d7b6fbb4c8b8d66a48bf9e
Author: Anders Damsgaard <anders@adamsgaard.dk>
Date: Thu, 25 Oct 2018 10:52:39 +0200
Fix tor-browser-update script on Debian
Diffstat:
1 file changed, 39 insertions(+), 23 deletions(-)
diff --git a/links/bin/tor-browser-update.sh b/links/bin/tor-browser-update.sh
@@ -7,21 +7,28 @@ set -e
# downloads it, verifies it, and extracts it.
# The scripts downloads the files using "torify", if available.
-# To import the signing key to Debian run:
-# $ gpg --keyserver keys.gnupg.net --recv 886DDD89
-# $ gpg --export A3C4F0F979CAA22CDBA8F512EE8CBC9E886DDD89 | sudo apt-key add -
-# $ sudo apt-get update
-# $ sudo apt-get install deb.torproject.org-keyring
-
# Folder where to download and extract the archives
TORFOLDER=~/tor
# Remote folder containing the TBB archives
-UNAMESTR=`uname`
+UNAMESTR=$(uname)
if [[ "$UNAMESTR" == 'Linux' ]]; then
- DIR="https://www.torproject.org/dist/torbrowser/4.0/"
-elif [[ "$UNAMESTR" == 'Darwin' ]]; then
- DIR="https://www.torproject.org/dist/torbrowser/osx/"
+ DIR="https://www.torproject.org/dist/torbrowser"
+
+ if [ -e /etc/apt/sources.list ] && \
+ ! dpkg -l deb.torproject.org-keyring; then
+
+ # Import the signing key to Debian
+ gpg2 --recv A3C4F0F979CAA22CDBA8F512EE8CBC9E886DDD89
+ gpg2 --export A3C4F0F979CAA22CDBA8F512EE8CBC9E886DDD89 | \
+ sudo apt-key add -
+
+ sudo apt-get update
+ sudo apt-get install deb.torproject.org-keyring
+ fi
+
+# elif [[ "$UNAMESTR" == 'Darwin' ]]; then
+# DIR="https://www.torproject.org/dist/torbrowser"
else
echo "Platform not supported"
exit 1
@@ -39,9 +46,18 @@ fi
# Find latest TBB version
echo "Determining latest Tor Browser Bundle stable version"
TMPFILENAME=/tmp/tordownloadpage.html
-$DOWNLOADCMD https://www.torproject.org/projects/torbrowser.html.en#downloads -O $TMPFILENAME && \
-LATESTTBB=`grep '_en-US.tar.xz">64-bit' $TMPFILENAME | head -n 1 | sed 's/.*tor-browser/tor-browser/' | sed 's/tar.xz.*/tar.xz/'` && \
+$DOWNLOADCMD https://www.torproject.org/projects/torbrowser.html.en#downloads \
+ -O $TMPFILENAME && \
+LATESTTBB=$(grep '_en-US.tar.xz">64-bit' $TMPFILENAME | \
+ head -n 1 | \
+ sed 's/.*tor-browser/tor-browser/' | \
+ sed 's/tar.xz.*/tar.xz/') && \
echo "Latest Tor Browser Bundle stable version is $LATESTTBB"
+LATESTVERSION="$(echo "$LATESTTBB" | \
+ sed 's/.*-linux64-//' | \
+ sed 's/_en-US.*//')"
+echo "Latest version string: $LATESTVERSION"
+
#rm $TMPFILENAME
# Check if the TBB version is already downloaded
@@ -54,18 +70,18 @@ fi
mkdir -p $TORFOLDER
cd $TORFOLDER &&\
echo "Attempting to download Tor Browser Bundle and signature"
-TARGET=$DIR$LATESTTBB.asc
-echo $TARGET
-$DOWNLOADCMD $TARGET &&\
+TARGET="${DIR}/${LATESTVERSION}/$LATESTTBB.asc"
+echo "$TARGET"
+$DOWNLOADCMD "$TARGET" &&\
if [[ -z "$TORIFY" ]]; then
- $GETCMD $TARGET -O $TARGET.notor
+ $GETCMD "$TARGET" -O "$TARGET".notor
fi
-TARGET=$DIR$LATESTTBB
-echo $TARGET
-$DOWNLOADCMD $TARGET &&\
-gpg --verify $LATESTTBB{.asc,} &&\
+TARGET="${DIR}/${LATESTVERSION}/$LATESTTBB"
+echo "$TARGET"
+$DOWNLOADCMD "$TARGET" &&\
+gpg --verify "$LATESTTBB"{.asc,} &&\
if [[ -z "$TORIFY" ]]; then
- gpg --verify $LATESTTBB{.asc.notor,}
+ gpg --verify "$LATESTTBB"{.asc.notor,}
fi
# Save the Tor data directory, if it exists
@@ -78,8 +94,8 @@ if [ -e $DATAFOLDER ]; then
fi
# Unpack the TBB
-tar -xJf $LATESTTBB &&\
-echo "Installation complete. Start with $TORFOLDER/tor-browser_en-US/start-tor-browser"
+tar -xJf "$LATESTTBB" &&\
+echo "Installation complete. Start with tor-browser.sh"
# Copy the old Data folder to the new TBB
if [ $BACKUPDATA == 1 ]; then