-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathdocker-entrypoint
executable file
·52 lines (45 loc) · 1.78 KB
/
docker-entrypoint
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
#!/bin/sh
set -o errexit
chmodf() { find $2 -type f -exec chmod -v $1 {} \;
}
chmodd() { find $2 -type d -exec chmod -v $1 {} \;
}
echo -e "\n========================================================"
# If DataDirectory, identity keys or torrc is mounted here,
# ownership needs to be changed to the TOR_USER user
chown -Rv ${TOR_USER}:${TOR_USER} /var/lib/tor
# fix permissions
chmodd 700 /var/lib/tor
chmodf 600 /var/lib/tor
if [ ! -e /tor-config-done ]; then
touch /tor-config-done # only run this once
# Add Nickname from env variable or randomized, if none has been set
if ! grep -q '^Nickname ' /etc/tor/torrc; then
if [ ${TOR_NICKNAME} == "Tor4" ] || [ -z "${TOR_NICKNAME}" ]; then
# if user did not change the default Nickname, genetrate a random pronounceable one
RPW=$(pwgen -0A 8)
TOR_NICKNAME="Tor4${RPW}"
echo "Setting random Nickname: ${TOR_NICKNAME}"
else
echo "Setting chosen Nickname: ${TOR_NICKNAME}"
fi
echo -e "\nNickname ${TOR_NICKNAME}" >> /etc/tor/torrc
fi
# Add Contact_Email from env variable, if none has been set in torrc
if ! grep -q '^ContactInfo ' /etc/tor/torrc; then
# if CONTACT_EMAIL is not null
if [ -n "${CONTACT_EMAIL}" ]; then
echo "Setting Contact Email: ${CONTACT_EMAIL}"
echo -e "\nContactInfo ${CONTACT_EMAIL}" >> /etc/tor/torrc
fi
fi
fi
echo -e "\n========================================================"
# Display OS version, Tor version & torrc in log
echo -e "Alpine Version: \c" && cat /etc/alpine-release
tor --version
obfs4proxy -version
cat /etc/tor/torrc
echo -e "========================================================\n"
# else default to run whatever the user wanted like "bash"
exec "$@"