Skip to content
Snippets Groups Projects
Commit da059f83 authored by Bob Mottram's avatar Bob Mottram
Browse files

More directly check for onion service

parent ba69e9fe
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment