aboutsummaryrefslogtreecommitdiff
path: root/share/hoarder/tor-browser/unix/linux/install
blob: f3a9a186ff3e2290b9d6a30cc20af6f4897691c8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/usr/bin/env sh
#
# Install Tor Browser
#

# Parameters
BASENAME="$0"
SHARE="$1"
LIB="$2"

# Additional parameters
DIST="https://dist.torproject.org/torbrowser/"
WORK="`mktemp -d`" || exit 1

# 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-linux64-${VERSION}_ALL.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                 || exit 1
mv $WORK/tor-browser $APP   || exit 1
rm -rf $WORK                || 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/Browser/start-tor-browser $APP || exit 1

# Done
trashman_installed_at $HOME/.local/share/$APP
trashman_run_with $HOME/.local/bin/$APP