diff options
author | makefu <github@syntax-fehler.de> | 2013-11-12 11:01:42 +0100 |
---|---|---|
committer | makefu <github@syntax-fehler.de> | 2013-11-12 11:01:42 +0100 |
commit | 16e39cc6a98977cc731abc19069b79aa9918654d (patch) | |
tree | a22c8dae089e9f42feb24984c6bb5b9eeafb73fe | |
parent | 9c37085f71b3fd7dd182813834c6e8017077f08c (diff) |
ship: refactor tor service
-rw-r--r-- | ship/lib/tor | 19 | ||||
-rwxr-xr-x | ship/src/tor_publish_ssh | 17 |
2 files changed, 22 insertions, 14 deletions
diff --git a/ship/lib/tor b/ship/lib/tor new file mode 100644 index 00000000..8d9e33f1 --- /dev/null +++ b/ship/lib/tor @@ -0,0 +1,19 @@ +# 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(){ + 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 +} diff --git a/ship/src/tor_publish_ssh b/ship/src/tor_publish_ssh index df904444..14cb9cb4 100755 --- a/ship/src/tor_publish_ssh +++ b/ship/src/tor_publish_ssh @@ -2,24 +2,13 @@ #@include core #@include network #@include punani -# 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/ ) +#@include tor + -torrc=${torrc:-/etc/tor/torrc} -hidden_service_dir=${hidden_service_dir:-/var/lib/tor/hidden_service/} punani install tor test -w "$torrc" || ( error "$torrc is not writable!"; exit 1 ) || exit 1 -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 +configure_hidden_service cat $hidden_service_dir/hostname | send_irc |