-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathentrypoint.sh
More file actions
94 lines (85 loc) · 2.63 KB
/
Copy pathentrypoint.sh
File metadata and controls
94 lines (85 loc) · 2.63 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
86
87
88
89
90
91
92
93
94
#!/bin/sh
append_config() {
printf '%s\n' "$1" >> /etc/tor/torrc
}
append_if_set() {
name="$1"
value="$2"
if [ -n "$value" ]; then
append_config "$name $value"
fi
}
require_env() {
name="$1"
value="$2"
if [ -z "$value" ]; then
echo "Required environment variable '$name' is not set for mode '$mode'."
exit 1
fi
}
transport_port="${TransportPort:-$PTPort}"
echo "Running jfwenisch/alpine-tor"
echo -e "Alpine Version: \c" && cat /etc/alpine-release
echo -e "Tor Version: \c" && tor --version
echo -e "Lyrebird Version: \c" && lyrebird -version
echo "Searching for environment variable 'mode'"
append_config "DataDirectory /tor"
append_if_set "ContactInfo" "$ContactInfo"
append_if_set "Nickname" "$Nickname"
case "$mode" in
exit)
echo "Starting up as exit node"
require_env "ORPort" "$ORPort"
append_config "ORPort 0.0.0.0:$ORPort"
append_config "ExitRelay 1"
append_config "SocksPort 0"
if [ -n "$DirPort" ]; then
append_config "DirPort 0.0.0.0:$DirPort"
fi
append_if_set "DirPortFrontPage" "$DirPortFrontPage"
;;
middle)
echo "Starting up as middle / guard node"
require_env "ORPort" "$ORPort"
append_config "ORPort 0.0.0.0:$ORPort"
append_config "ExitRelay 0"
append_config "SocksPort 0"
;;
bridge)
echo "Starting up as bridge node"
require_env "ORPort" "$ORPort"
require_env "TransportPort or PTPort" "$transport_port"
append_config "ORPort 0.0.0.0:$ORPort"
append_config "BridgeRelay 1"
append_config "SocksPort 0"
append_config "ServerTransportPlugin obfs4 exec /usr/bin/lyrebird"
append_config "ServerTransportListenAddr obfs4 0.0.0.0:$transport_port"
append_config "ExtORPort auto"
if [ -n "$MyFamily" ]; then
echo "Ignoring MyFamily for bridge mode, as Tor bridges should not publish a family."
fi
;;
proxy)
echo "Starting up as proxy"
require_env "SOCKSPort" "$SOCKSPort"
append_config "SocksPort 0.0.0.0:$SOCKSPort"
;;
*)
echo "No valid mode set. Please refer to the README.md on how to run this image."
exit 1
;;
esac
append_if_set "DNSPort" "$DNSPort"
append_if_set "DNSListenAddress" "$DNSListenAddress"
if [ "$mode" != "bridge" ]; then
append_if_set "MyFamily" "$MyFamily"
fi
append_if_set "HiddenServiceDir" "$HiddenServiceDir"
append_if_set "HiddenServicePort" "$HiddenServicePort"
append_if_set "ExitNodes" "$ExitNodes"
append_if_set "ReducedExitPolicy" "$ReducedExitPolicy"
append_if_set "ExitPolicy" "$ExitPolicy"
append_if_set "PublishServerDescriptor" "$PublishServerDescriptor"
append_if_set "Address" "$Address"
echo "Running tor -f /etc/tor/torrc"
exec tor -f /etc/tor/torrc