#!/usr/bin/env sh # # Installs the latest Tor Browser stable or alpha # # Parameters BASENAME="$0" SHARE="$1" LIB="$2" # Additional parameters DIST="https://dist.torproject.org/torbrowser/" WORK="`mktemp -d`" || exit 1 ARCH="`uname -m`" # Determine the application name if echo $BASENAME | grep -q 'tor-browser-alpha'; then APP="tor-browser-alpha" else APP="tor-browser" fi # Include basic functions . $LIB/trashman/functions || exit 1 # Requirements trashman_require wget lynx gpg tar xz # Determine the current version filter if [ "$APP" = "tor-browser" ]; then VERSION_FILTER="-v" fi # Try to get the current version # Use a large (10000) number for grep to make sure we get all available versions VERSION="`LC_ALL=C lynx -dump https://dist.torproject.org/torbrowser/ 2> /dev/null | grep -A 10000 References | grep -e 'torbrowser' | grep -v '?' | sort -V | sed -e 's|^.*dist.torproject.org/torbrowser/||' -e 's|/||g' | grep $VERSION_FILTER a | tail -n 1`" # Check for available versions if [ -z "$VERSION" ]; then trashman_echo "error determining the available $APP version, aborting" exit 1 fi # Build the URL and filename strings URL="${DIST}/${VERSION}/" FILE="tor-browser-linux-${ARCH}-${VERSION}.tar.xz" # Download wget "$URL/$FILE" -O $WORK/$FILE || exit 1 wget "$URL/$FILE.asc" -O $WORK/$FILE.asc || exit 1 # Verify gpg --homedir $WORK/.gnupg --import $SHARE/$APP/unix/linux/files/$APP.asc || exit 1 gpg --homedir $WORK/.gnupg --verify $WORK/$FILE.asc || exit 1 rm -rf $WORK/.gnupg || exit 1 # Unpack tar xvf $WORK/$FILE -C $WORK || exit 1 # Install mkdir -p $HOME/.local/share || exit 1 cd $HOME/.local/share || exit 1 rm -rf $APP/$ARCH/$VERSION || exit 1 mkdir -p $APP/$ARCH || exit 1 mv $WORK/tor-browser $APP/$ARCH/$VERSION || exit 1 rm -rf $WORK || exit 1 rm -rf $APP/$ARCH/latest || exit 1 cd $APP/$ARCH && ln -s $VERSION latest || exit 1 # Create symlink to scripts mkdir -p $HOME/.local/bin || exit 1 cd $HOME/.local/bin || exit 1 ln -sf $HOME/.local/share/$APP/$ARCH/latest/Browser/start-tor-browser $APP-${ARCH} || exit 1 ln -sf $HOME/.local/share/$APP/$ARCH/$VERSION/Browser/start-tor-browser $APP-${ARCH}-${VERSION} || exit 1 # Remove old symlink to the Tor Browser script rm -f $HOME/.local/bin/$APP # Done trashman_installed_at $HOME/.local/share/$APP/$ARCH/latest trashman_run_with $HOME/.local/bin/$APP-$ARCH