forked from apg/heroku-buildpack-tor
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcompile
More file actions
executable file
·85 lines (66 loc) · 1.89 KB
/
Copy pathcompile
File metadata and controls
executable file
·85 lines (66 loc) · 1.89 KB
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
#!/usr/bin/env bash
indent() {
sed -u 's/^/ /'
}
BUILD_DIR=$1
CACHE_DIR=$2
ENV_DIR=$3
if [[ -e "${ENV_DIR}/TOR_SRC_URL" ]]; then
TOR_SRC_URL=$(cat ${ENV_DIR}/TOR_SRC_URL)
fi
if [[ -z "${TOR_SRC_URL}" ]]; then
TOR_SRC_URL="https://www.torproject.org/dist/tor-0.2.7.6.tar.gz"
fi
wget -q $TOR_SRC_URL
if ! [ $? ]; then
echo "FAILED to obtain tor src" | indent
exit 1
fi
## TODO: Need to figure out how to verify properly.
# TOR_SRC_SIG=${TOR_SRC_URL}.asc
# wget -q $TOR_SRC_SIG
# if ! [ $? ]; then
# echo "FAILED to obtain tor src signature file" | indent
# exit 1
# fi
# # Receive the Tor signers key
# gpg --keyserver x-hkp://pool.sks-keyservers.net --recv-keys 0x4E2C6E8793298290
# if ! [ $? ]; then
# echo "FAILED to recv key for signature verification" | indent
# exit 1
# fi
# gpg --verify $BUILD_DIR/tor-*.tar.gz{.asc,} | grep "Good signature"
# if ! [ $? ]; then
# echo "FAILED to verify integrity of downloaded tarball. Aborting!!!!" | indent
# exit 1
# fi
# Finally do some compilation.
tar -zxf tor-*.tar.gz
cd tor-*
./configure --prefix=$BUILD_DIR
if ! [ $? ]; then
echo "FAILED to configure for compliation" | indent
exit 1
fi
make install
if ! [ $? ]; then
echo "FAILED to run make install" | indent
fi
# Cache builds to avoid unnecessary wait times.
echo $TOR_SRC_URL > $CACHE_DIR/.src-dist
cat > ${BUILD_DIR}/bin/hide <<EOF
#!/usr/bin/env bash
mkdir -p "${HOME}/hidden_service"
echo "Setting up hidden service"
cat > ${HOME}/hidden_service/private_key <<EPK
\${HIDDEN_PRIVATE_KEY}
EPK
echo \${HIDDEN_DOT_ONION} > ${HOME}/hidden_service/hostname
echo "HiddenServiceDir ${HOME}/hidden_service/" > $HOME/etc/tor/torrc
echo "HiddenServicePort 80 127.0.0.1:\${PORT}" >> $HOME/etc/tor/torrc
# Use -f to be safe here.
$HOME/bin/tor -f $HOME/etc/tor/torrc &
exec \$*
EOF
chmod a+x ${BUILD_DIR}/bin/hide
echo "Installed Tor successfully" | indent