summaryrefslogtreecommitdiffstats
path: root/ship/lib/tor
blob: 0911e92a281886d74cdf63aecd5f1ff08d23d845 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# can be set via env:
# torrc              - path to torrc (default: /etc/tor/torrc )
# hidden_service_dir - path to hidden service (default: /var/lib/tor/hidden_service/ )


torrc=${torrc:-/etc/tor/torrc}
hidden_service_dir=${hidden_service_dir:-/var/lib/tor/hidden_service/}

configure_hidden_service(){
    mkdir -p "$hidden_service_dir"
    if ! grep -q '^HiddenService' "$torrc"  ;then
        info "adding hidden service to $torrc"
        cat >> "$torrc" << EOF
HiddenServiceDir ${hidden_service_dir}
HiddenServicePort 22 127.0.0.1:22
EOF
    else
        info "HiddenServiceDir or Port already in $torrc, skipping!"
    fi
}