aboutsummaryrefslogtreecommitdiff
path: root/tor-browser-dl
blob: f1243fb60b72a10a0e9bfe231f4fdd1ef87424b6 (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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#!/bin/bash
#
# Download specific versions of the Tor Browser Bundle, for testing purposes
#

# 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"
DL_ONLY="$3"
#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 <version> [arch] [lang]"
  #echo "example: $BASENAME 12.5.2 linux64 en-US"
  echo "usage: $BASENAME <version> [arch] [donwload-only]"
  echo "example: $BASENAME 12.5.2 x86_64"
  echo "example: $BASENAME 12.5.2 x86_64 download-only"
  exit 1
fi

# Determine the application name
if echo $VERSION | grep -q 'a'; then
  APP="tor-browser-alpha"
else
  APP="tor-browser"
fi

# Determine architecture
if [ -z "$ARCH" ]; then
  ARCH="`uname -m`"
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-linux-${ARCH}-${VERSION}.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/$ARCH"
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

if [ ! -z "$DL_ONLY" ] && [ "$DL_ONLY" == "download-only" ]; then
  echo "$BASENAME: Tor Browser $VERSION for $ARCH saved on $DL/$FILE"
  echo "$BASENAME: Signature saved at $DL/$SIGN"
  exit
fi

# Unpack
( cd "$TEMP" && tar xf "$DL/$FILE" ) || exit 1

# Install
rm -rf $APP_BASE/$ARCH/$VERSION                          || exit 1
#mv "$TEMP/tor-browser_$LANG" "$APP_BASE/$ARCH/$VERSION" || exit 1
mv "$TEMP/tor-browser" "$APP_BASE/$ARCH/$VERSION"        || exit 1

# Create symlink to scripts
mkdir -p $HOME/.local/bin                                                         || exit 1
cd $HOME/.local/bin                                                               || exit 1
ln -sf $APP_BASE/$ARCH/$VERSION/Browser/start-tor-browser $APP-${ARCH}-${VERSION} || exit 1

# 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"
echo "Be aware that Tor Browser has a self-update mechanism, so at some point the installation at $APP_BASE/$ARCH/$VERSION will have a newer version, even if the folder name is kept as is"