-
Notifications
You must be signed in to change notification settings - Fork 1
/
tor
executable file
·60 lines (48 loc) · 1.89 KB
/
tor
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
#!/bin/bash
WORKDIR="/root/docker/tor"
if [ `id -u` != 0 ]; then
# if [ -t 0 ]; then
exec sudo `realpath $0` "$@"
# else
# exec sakura -e sudo `realpath $0` --no-interaction "$@"
# fi
fi
set -e
if echo -- "$@" | grep -q " --build"; then
cd $WORKDIR
VER=0
for i in $(curl -s https://www.torproject.org/projects/torbrowser/RecommendedTBBVersions | \
sed -e 's/\[//;s/\]//;s/\"//g;s/,//g;s/-hardened//g;s/-Linux//g;s/-MacOS//g;s/-Windows//g' | sort -u); do
if [[ $i =~ ^[0-9]+(\.[0-9]+)?(\.[0-9]+)?$ ]]; then
VER=${i}
fi
done
curl -s https://dist.torproject.org/torbrowser/${VER}/sha256sums-signed-build.txt | \
grep tor-browser-linux64-${VER}_en-US.tar.xz | cut -f1 -d' ' | tr '\n' ' ' > sha256sum.txt
echo "tor-browser.tar.xz" >> sha256sum.txt
if ! sha256sum --ignore-missing --status -c sha256sum.txt; then
echo "Fetching newest Tor Browser"
curl -L https://www.torproject.org/dist/torbrowser/${VER}/tor-browser-linux64-${VER}_en-US.tar.xz > tor-browser.tar.xz
curl -L https://www.torproject.org/dist/torbrowser/${VER}/tor-browser-linux64-${VER}_en-US.tar.xz.asc > tor-browser.tar.xz.asc
fi
rm sha256sum.txt
docker build --pull=true -t tor .
echo "Successfully built Tor Browser - exiting!"
exit 0
fi
if echo -- "$@" | grep -q " --no-interaction"; then
setsid `realpath $0` "$(echo " " "$@" | sed 's/--no-interaction//')" >/dev/null </dev/null 2>/dev/null &
sleep 1.5
exit 0
fi
TMP_XAUTH=`mktemp /tmp/.docker-tor-XXXX`
xauth nlist :0 | sed -e 's/^..../ffff/' | xauth -f $TMP_XAUTH nmerge -
chown -R $SUDO_UID:$SUDO_GID $TMP_XAUTH
mkdir /tmp/firefox || true
chown -R $SUDO_UID:$SUDO_UID /tmp/firefox
docker run --cap-drop=all --rm --shm-size 2g -e DISPLAY=$DISPLAY \
-v /tmp/firefox:/home/user/tor-browser_en-US/Browser/Downloads/ \
-v /tmp/.X11-unix:/tmp/.X11-unix:ro \
-v $TMP_XAUTH:/home/user/.Xauthority:ro \
tor
rm -rf $TMP_XAUTH