-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathos.sh
executable file
·67 lines (46 loc) · 1.14 KB
/
os.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
#!/bin/bash
# SPDX-License-Identifier: GPL-3.0-or-later
# set -x
# setup an onion service
# $1: <ip address>, $2: <port number>, $3: [unset or "non"]
#######################################################################
set -euf
export LANG=C.utf8
export PATH="/usr/sbin:/usr/bin:/sbin:/bin"
if [[ "$(whoami)" != "root" ]]; then
echo "you must be root "
exit 2
fi
dir=/tmp/onionsvc.d
mkdir -m 0700 $dir
chown -R tor:tor $dir
cat <<EOF >$dir/torrc
User tor
SandBox 1
RunAsDaemon 1
DataDirectory $dir/data
PIDFile $dir/tor.pid
SocksPort 0
ControlPort 9099 # https://github.com/mikeperry-tor/vanguards
CookieAuthentication 1
Log debug file $dir/debug.log
Log info file $dir/info.log
Log notice file $dir/notice.log
AvoidDiskWrites 1
BandwidthRate 512 KBytes
BandwidthBurst 1024 KBytes
HiddenServiceDir $dir/data/osdir
HiddenServicePort 80 ${1:-127.0.0.1}:${2:-1234}
EOF
if [[ $3 == "non" ]]; then
cat <<EOF >>$dir/torrc
HiddenServiceNonAnonymousMode 1
HiddenServiceSingleHopMode 1
EOF
fi
chmod 600 $dir/torrc
chown tor:tor $dir/torrc
/usr/bin/tor -f $dir/torrc
echo
echo "onion address: $(tail -v $dir/data/osdir/hostname)"
echo