-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdocker-entrypoint.sh
executable file
·177 lines (134 loc) · 5.34 KB
/
docker-entrypoint.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
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
#!/bin/bash
set -e
PARTICL_CONF="${PARTICL_DATA}/particl.conf"
if [[ ! -z "${CONF_CLEAN_INIT}" ]]; then
rm -rf ${PARTICL_CONF}
# rm -rf /var/lib/tor/torrc.current
fi
# if [[ -f "/var/lib/tor/torrc.current" ]]
# then
# cp /var/lib/tor/torrc.current /etc/tor/torrc
# fi
# recreate everything if theres no particl.conf
if [[ ! -f "${PARTICL_CONF}" ]]
then
# cp /etc/tor/torrc /var/lib/tor/torrc.org
# cp /usr/share/tor/tor-service-defaults-torrc /var/lib/tor/tor-service-defaults-torrc.org
# rm -rf /etc/tor/torrc
# rm -rf /usr/share/tor/tor-service-defaults-torrc
# chown -R debian-tor:debian-tor /var/lib/tor
# chmod -R 700 /var/lib/tor
# CONF_TORPASSWORD=${CONF_TORPASSWORD:-$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)}
# echo "HiddenServiceDir /var/lib/tor/particl-service/" >> /etc/tor/torrc
# echo "HiddenServicePort 51738 127.0.0.1:51738" >> /etc/tor/torrc
# echo "HiddenServicePort 51935 127.0.0.1:51935" >> /etc/tor/torrc
# echo "DataDirectory /var/lib/tor" >> /etc/tor/torrc
# echo "PidFile /var/lib/tor/tor.pid" >> /etc/tor/torrc
# echo "RunAsDaemon 1" >> /etc/tor/torrc
# echo "User debian-tor" >> /etc/tor/torrc
# echo "ControlSocket /var/run/tor/control GroupWritable RelaxDirModeCheck" >> /etc/tor/torrc
# echo "ControlSocketsGroupWritable 1" >> /etc/tor/torrc
# echo "SocksPort unix:/var/run/tor/socks WorldWritable" >> /etc/tor/torrc
# echo "SocksPort 9050" >> /etc/tor/torrc
# echo "ControlPort 9051" >> /etc/tor/torrc
# echo "HashedControlPassword $(tor --hash-password ${CONF_TORPASSWORD} | sed -n '2p')" >> /etc/tor/torrc
# echo "Log notice syslog" >> /etc/tor/torrc
# echo "CookieAuthentication 1" >> /etc/tor/torrc
# echo "CookieAuthFile /var/lib/tor/control.authcookie" >> /etc/tor/torrc
# echo "CookieAuthFileGroupReadable 1" >> /etc/tor/torrc
# cp /etc/tor/torrc /var/lib/tor/torrc.current
# more /etc/tor/torrc
# /etc/init.d/tor start
echo "${PARTICL_CONF} does not exist, creating..."
touch ${PARTICL_CONF}
# HOSTNAME='/var/lib/tor/particl-service/hostname'
# until [ -e $HOSTNAME ]; do
# echo "waiting for tor $HOSTNAME, sleeping for 5s..."
# ls -al /var/lib/tor/particl-service
# sleep 5;
# done
# TORHOSTNAME=$(cat $HOSTNAME)
# echo "...onion address is ${TORHOSTNAME}"
# TODO: add rpcauth
# TODO: add rpcbind
# TODO: this needs to be redone
RPCUSERNAME=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)
RPCPASSWORD=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)
echo "rpcuser=${CONF_RPCUSERNAME:-$RPCUSERNAME}" >> ${PARTICL_CONF}
echo "rpcpassword=${CONF_RPCPASSWORD:-$RPCPASSWORD}" >> ${PARTICL_CONF}
if [[ ! -z "${CONF_RPCPORT}" ]]; then
echo "rpcport=${CONF_RPCPORT}" >> ${PARTICL_CONF}
else
echo "rpcport=51935" >> ${PARTICL_CONF}
fi
echo "printtoconsole=${CONF_PRINTTOCONSOLE:-1}" >> ${PARTICL_CONF}
if [[ ! -z "${CONF_TESTNET}" ]]; then
echo "testnet=${CONF_TESTNET}" >> ${PARTICL_CONF}
fi
if [[ ! -z "${CONF_SERVER}" ]]; then
echo "server=${CONF_SERVER}" >> ${PARTICL_CONF}
if [[ "${CONF_SERVER}" == 1 ]]; then
echo "rpcallowip=10.211.0.0/16" >> ${PARTICL_CONF}
echo "rpcallowip=172.17.0.0/16" >> ${PARTICL_CONF}
echo "rpcallowip=192.168.0.0/16" >> ${PARTICL_CONF}
echo "rpcallowip=${CONF_RPCALLOWIP:-127.0.0.1}" >> ${PARTICL_CONF}
fi
fi
if [[ ! -z "${CONF_REST}" ]]; then
echo "rest=${CONF_REST}" >> ${PARTICL_CONF}
fi
if [[ ! -z "${CONF_ONLYNET}" ]]; then
echo "onlynet=${CONF_ONLYNET}" >> ${PARTICL_CONF}
fi
if [[ ! -z "${CONF_PROXY}" ]]; then
echo "proxy=${CONF_PROXY}" >> ${PARTICL_CONF}
echo "externalip=${TORHOSTNAME}" >> ${PARTICL_CONF}
fi
if [[ ! -z "${CONF_ONION}" ]]; then
echo "onion=${CONF_ONION}" >> ${PARTICL_CONF}
echo "externalip=${TORHOSTNAME}" >> ${PARTICL_CONF}
fi
if [[ ! -z "${CONF_LISTENONION}" ]]; then
echo "listenonion=${CONF_LISTENONION}" >> ${PARTICL_CONF}
fi
if [[ ! -z "${CONF_TORCONTROL}" ]]; then
echo "torcontrol=${CONF_TORCONTROL}" >> ${PARTICL_CONF}
if [[ ! -z "${CONF_TORPASSWORD}" ]]; then
echo "torpassword=${CONF_TORPASSWORD}" >> ${PARTICL_CONF}
fi
fi
if [[ ! -z "${CONF_LISTEN}" ]]; then
echo "listen=${CONF_LISTEN}" >> ${PARTICL_CONF}
fi
if [[ ! -z "${CONF_BIND}" ]]; then
echo "bind=${CONF_BIND}" >> ${PARTICL_CONF}
fi
if [[ ! -z "${CONF_DISCOVER}" ]]; then
echo "discover=${CONF_DISCOVER}" >> ${PARTICL_CONF}
fi
if [[ ! -z "${CONF_MAXCONNECTIONS}" ]]; then
echo "maxconnections=${CONF_MAXCONNECTIONS}" >> ${PARTICL_CONF}
fi
if [[ ! -z "${CONF_DEBUG}" ]]; then
echo "debug=${CONF_DEBUG}" >> ${PARTICL_CONF}
fi
else
echo "${PARTICL_CONF} allready generated..."
fi
echo
echo "particl.conf:"
echo
more $PARTICL_CONF
echo
echo rpcauth.py:
rpcauth.py test test
echo
if [[ "$1" = "particld" ]]; then
if [[ "${CREATEDEFAULTMASTERKEY}" = true ]]; then
set -- "$@" -datadir="${PARTICL_DATA}" -conf="${PARTICL_CONF}" -createdefaultmasterkey
exec "$@"
else
set -- "$@" -datadir="${PARTICL_DATA}" -conf="${PARTICL_CONF}"
exec "$@"
fi
fi