forked from EFForg/https-everywhere
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtor-browser.sh
executable file
·55 lines (44 loc) · 1.9 KB
/
tor-browser.sh
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
#!/bin/bash -ex
# Just run the Tor Browser with HTTPS Everywhere
# Get to the repo root directory, even when we're symlinked as a hook.
if [ -n "$GIT_DIR" ]
then
# $GIT_DIR is set, so we're running as a hook.
cd $GIT_DIR
else
# Git command exists? Cool, let's CD to the right place.
git rev-parse && cd "$(git rev-parse --show-toplevel)"
fi
source utils/mktemp.sh
die() {
echo "$@"
exit 1
}
# Unzip the Tor Browser archive to a temporary directory
if [ ! -f "$1" ] && [ "`echo $1 | tail -c 8 | head -c 7`" != ".tar.xz" ]; then
echo "Usage: $0 [path_to_tor_archive]"
echo
die "File provided is not a valid Tor Browser archive."
fi
PROFILE_DIRECTORY="$(mktemp -d)"
trap 'rm -r "$PROFILE_DIRECTORY"' EXIT
tar -Jxvf $1 -C $PROFILE_DIRECTORY > /dev/null
TBB_LOCALIZED_DIRECTORY=`find $PROFILE_DIRECTORY -maxdepth 1 -mindepth 1 -type d`
HTTPSE_INSTALL_XPI=$TBB_LOCALIZED_DIRECTORY/Browser/TorBrowser/Data/Browser/profile.default/extensions/[email protected]
echo 'pref("extensions.https_everywhere.log_to_stdout", true);' >> $TBB_LOCALIZED_DIRECTORY/Browser/TorBrowser/Data/Browser/profile.default/preferences/extension-overrides.js
echo 'pref("extensions.https_everywhere.LogLevel", 0);' >> $TBB_LOCALIZED_DIRECTORY/Browser/TorBrowser/Data/Browser/profile.default/preferences/extension-overrides.js
# Remove the prebundled HTTPSE
rm -rf $HTTPSE_INSTALL_XPI
# Build the XPI to run all the validations in make.sh, and to ensure that
# we test what is actually getting built.
./make.sh
XPI_NAME="`ls -tr pkg/https-everywhere-20*.xpi | tail -1`"
# Install into our fresh Tor Browser
cp -a $XPI_NAME $HTTPSE_INSTALL_XPI
if [ ! -f "$HTTPSE_INSTALL_XPI" ]; then
die "Tor Browser does not have HTTPS Everywhere installed"
fi
echo "Running Tor Browser"
$TBB_LOCALIZED_DIRECTORY/Browser/start-tor-browser --verbose ${@:2}
shasum=$(openssl dgst -sha256 "$XPI_NAME")
echo -e "Git commit `git rev-parse HEAD`\n$shasum"