More directly check for onion service

This commit is contained in:
Bob Mottram 2017-06-11 13:53:01 +01:00
parent ba69e9fe10
commit da059f8368
2 changed files with 6 additions and 16 deletions

View File

@ -170,7 +170,7 @@ function configure_email_onion {
function_check wait_for_onion_service
wait_for_onion_service email
if [[ $(onion_service_exists email) == "0" ]]; then
if [ ! -f /var/lib/tor/hidden_service_email/hostname ]; then
echo $"email onion site hostname not found"
systemctl restart tor
exit 782352

View File

@ -50,21 +50,11 @@ function onion_update {
systemctl restart tor
}
function onion_service_exists {
onion_service_name="$1"
if [ -f /var/lib/tor/hidden_service_${onion_service_name}/hostname ]; then
echo -n "1"
else
echo -n "0"
fi
}
function wait_for_onion_service_base {
onion_service_name="$1"
sleep_ctr=0
while [[ $(onion_service_exists ${onion_service_name}) == "0" ]]; do
while [ ! -f /var/lib/tor/hidden_service_${onion_service_name}/hostname ]; do
sleep 1
sleep_ctr=$((sleep_ctr + 1))
if [ $sleep_ctr -gt 10 ]; then
@ -78,7 +68,7 @@ function wait_for_onion_service {
wait_for_onion_service_base ${onion_service_name}
if [[ $(onion_service_exists ${onion_service_name}) == "0" ]]; then
if [ ! -f /var/lib/tor/hidden_service_${onion_service_name}/hostname ]; then
# try a second time
onion_update
wait_for_onion_service_base ${onion_service_name}
@ -123,8 +113,8 @@ function add_onion_service {
onion_service_port_to=$3
onion_stealth_name="$4"
if [[ $(onion_service_exists ${onion_service_name}) == "1" ]]; then
cat /var/lib/tor/hidden_service_${onion_service_name}/hostname
if [ -f /var/lib/tor/hidden_service_${onion_service_name}/hostname ]; then
echo $(cat /var/lib/tor/hidden_service_${onion_service_name}/hostname)
return
fi
@ -145,7 +135,7 @@ function add_onion_service {
function_check wait_for_onion_service
wait_for_onion_service ${onion_service_name}
if [[ $(onion_service_exists ${onion_service_name}) == "0" ]]; then
if [ ! -f /var/lib/tor/hidden_service_${onion_service_name}/hostname ]; then
echo $"${onion_service_name} onion site hostname not found"
exit 763624
fi