Debian Codegraph @

contrib/tor/monero-over-tor.sh

raw symbols SCIP
1 #!/bin/bashscip-shell filesystem . . `/bin/bash`.
2
3 DIR=$(realpathscip-shell system . . realpath. $(dirnamescip-shell system . . dirname. $0))
4
5 echoscip-shell system . . echo. "Checking monerod..."
6 monerod=""
7 for dir in \
8 . \
9 "$DIR" \
10 "$DIR/../.." \
11 "$DIR/build/release/bin" \
12 "$DIR/../../build/release/bin" \
13 "$DIR/build/Linux/master/release/bin" \
14 "$DIR/../../build/Linux/master/release/bin" \
15 "$DIR/build/Windows/master/release/bin" \
16 "$DIR/../../build/Windows/master/release/bin"
17 do
18 if testscip-shell system . . test. -x "$dir/monerod"
19 then
20 monerod="$dir/monerod"
21 break
22 fi
23 done
24 if testscip-shell system . . test. -z "$monerod"
25 then
26 echoscip-shell system . . echo. "monerod not found"
27 exit 1
28 fi
29 echoscip-shell system . . echo. "Found: $monerod"
30
31 TORDIR="$DIR/monero-over-tor"
32 TORRC="$TORDIR/torrc"
33 HOSTNAMEFILE="$TORDIR/hostname"
34 echoscip-shell system . . echo. "Creating configuration..."
35 mkdirscip-shell system . . mkdir. -p "$TORDIR"
36 chmodscip-shell system . . chmod. 700 "$TORDIR"
37 rmscip-shell system . . rm. -f "$TORRC"
38 catscip-shell system . . cat. << EOF > "$TORRC"
39 ControlSocket $TORDIR/control
40 ControlSocketsGroupWritable 1
41 CookieAuthentication 1
42 CookieAuthFile $TORDIR/control.authcookie
43 CookieAuthFileGroupReadable 1
44 HiddenServiceDir $TORDIR
45 HiddenServicePort 18083 127.0.0.1:18083
46 EOF
47
48 echoscip-shell system . . echo. "Starting Tor..."
49 nohupscip-shell system . . nohup. tor -f "$TORRC" 2> "$TORDIR/tor.stderr" 1> "$TORDIR/tor.stdout" &
50 ready=0
51 for i in `seqscip-shell system . . seq. 10`
52 do
53 sleepscip-shell system . . sleep. 1
54 if testscip-shell system . . test. -f "$HOSTNAMEFILE"
55 then
56 ready=1
57 break
58 fi
59 done
60 if testscip-shell system . . test. "$ready" = 0
61 then
62 echoscip-shell system . . echo. "Error starting Tor"
63 catscip-shell system . . cat. "$TORDIR/tor.stdout"
64 exit 1
65 fi
66
67 echoscip-shell system . . echo. "Starting monerod..."
68 HOSTNAME=$(catscip-shell system . . cat. "$HOSTNAMEFILE")
69 "$monerod" \
70 --anonymous-inbound "$HOSTNAME":18083,127.0.0.1:18083,25 --tx-proxy tor,127.0.0.1:9050,10 \
71 --add-priority-node zbjkbsxc5munw3qusl7j2hpcmikhqocdf4pqhnhtpzw5nt5jrmofptid.onion:18083 \
72 --add-priority-node 2xmrnode5itf65lz.onion:18083 \
73 --detach
74 ready=0
75 for i in `seqscip-shell system . . seq. 10`
76 do
77 sleepscip-shell system . . sleep. 1
78 status=$("$monerod" status)
79 echoscip-shell system . . echo. "$status" | grepscip-shell system . . grep. -q "Height:"
80 if testscip-shell system . . test. $? = 0
81 then
82 ready=1
83 break
84 fi
85 done
86 if testscip-shell system . . test. "$ready" = 0
87 then
88 echoscip-shell system . . echo. "Error starting monerod"
89 tailscip-shell system . . tail. -n 400 "$HOME/.bitmonero/bitmonero.log" | grepscip-shell system . . grep. -Ev stacktrace\|"Error: Couldn't connect to daemon:"\|"src/daemon/main.cpp:.*Monero\ \'" | tailscip-shell system . . tail. -n 20
90 exit 1
91 fi
92
93 echoscip-shell system . . echo. "Ready. Your Tor hidden service is $HOSTNAME"