#!/bin/bash # # Download the Tor Browser Bundle. # # Parameters BASENAME="`basename $0`" APPS="$HOME/apps" #APP_BASE="$APPS/tor-browser" APP_BASE="$HOME/.local/share/tor-browser" TEMP="$TMP/tor-browser" DL="$HOME/data/distros/tor/" VERSION="$1" ARCH="$2" #LANG="$3" #LANG="ALL" #BASE_URL="https://dist.torproject.org/torbrowser/$VERSION" BASE_URL="https://archive.torproject.org/tor-package-archive/torbrowser/" # Syntax check if [ -z "$VERSION" ]; then #echo "usage: $BASENAME [arch] [lang]" #echo "example: $BASENAME 12.5.2 linux64 en-US" echo "usage: $BASENAME [arch]" echo "example: $BASENAME 12.5.2 linux64" exit 1 fi # Determine architecture and file suffix if echo $VERSION | grep -q 'a'; then APP="tor-browser-alpha" else APP="tor-browser" FILE_SUFFIX="_ALL" fi # Determine architecture if [ "$ARCH" = "i386" ]; then ARCH="linux32" elif [ "$ARCH" = "i686" ]; then ARCH="linux32" elif [ "$ARCH" = "x86_64" ]; then if [ "$APP" = "tor-browser" ]; then ARCH="linux64" else ARCH="linux-x86_64" fi elif [ -z "$ARCH" ]; then ARCH="linux64" fi # Set lang #if [ -z "$LANG" ]; then # LANG="en-US" #fi # Set file names #FILE="tor-browser-$ARCH-$VERSION"_"$LANG.tar.xz" FILE="tor-browser-${ARCH}-${VERSION}${FILE_SUFFIX}.tar.xz" SIGN="$FILE.asc" # Check existing installation if [ -d "$APP_BASE/$ARCH-$VERSION" ]; then echo "TBB version $VERSION for $ARCH already installed" exit 1 fi # Create folders mkdir -p "$TEMP" mkdir -p "$APP_BASE" mkdir -p "$DL" # Download package if [ ! -e "$DL/$FILE" ]; then wget -c "$BASE_URL/$VERSION/$FILE" -O "$DL/$FILE" || exit 1 fi # Download signature if [ ! -e "$DL/$SIGN" ]; then wget -c "$BASE_URL/$VERSION/$SIGN" -O "$DL/$SIGN" || exit 1 fi # Check signature gpg --verify "$DL/$SIGN" "$DL/$FILE" || exit 1 # Unpack ( cd "$TEMP" && tar xf "$DL/$FILE" ) || exit 1 # Move and symlink mv "$TEMP/tor-browser_$LANG" "$APP_BASE/$ARCH-$VERSION" rm -rf $APP_BASE/$ARCH && \ ( cd "$APP_BASE" && ln -sf "$ARCH-$VERSION" "$ARCH" ) # Set pentadactyl if available #if [ -e "$HOME/.pentadactyl" ]; then # ( # cd "$APP_BASE/$ARCH-$VERSION/Browser" # ln -s "$HOME/.pentadactyl" # ln -s "$HOME/.pentadactylrc" # ) #fi # Set vimperator if available #if [ -e "$HOME/.vimperator" ]; then # ( # cd "$APP_BASE/$ARCH-$VERSION/Browser" # ln -s "$HOME/.vimperator" # ln -s "$HOME/.vimperatorrc" # ) #fi # Cleanup rm -rf "$TEMP" echo "Please check and cleanup old versions at $APP_BASE"