-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathconfig.sh
46 lines (36 loc) · 895 Bytes
/
config.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
#!/bin/sh
if [ -z "$TORRC" ]; then
echo "Please provide a valid TORRC parameter!"
echo "TORRC: $TORRC"
exit
fi
echo "Using template $TORRC"
chown -Rv tord:tord /home/tord/
# Assumes a key-value'ish pair
# $1 is the key and $2 is the value
function update_or_add {
FINDINFILE=$(grep -e "^$1.*$" $TORRC)
echo "Adding $1 $2 to Torrc"
# Append if missing.
# Update if exist.
if [ -z "$FINDINFILE" ]; then
echo "$1 $2" >> $TORRC
else
sed -i "s/^$1.*/$1 $2/g" $TORRC
fi
}
# Set $NICKNAME to the node nickname
if [ -n "$NICKNAME" ]; then
update_or_add 'Nickname' "$NICKNAME"
else
update_or_add 'Nickname' 'DockerTorRelay'
fi
# Set $CONTACTINFO to your contact info
if [ -n "$CONTACTINFO" ]; then
update_or_add 'ContactInfo' "$CONTACTINFO"
else
update_or_add 'ContactInfo' 'Anonymous'
fi
cp $TORRC /etc/tor/torrc -f
cat /etc/tor/torrc
tor -f /etc/tor/torrc