Parcourir la source

More directly check for onion service

Bob Mottram il y a 8 ans
Parent
révision
da059f8368
2 fichiers modifiés avec 6 ajouts et 16 suppressions
  1. 1
    1
      src/freedombone-base-email
  2. 5
    15
      src/freedombone-utils-onion

+ 1
- 1
src/freedombone-base-email Voir le fichier

170
     function_check wait_for_onion_service
170
     function_check wait_for_onion_service
171
     wait_for_onion_service email
171
     wait_for_onion_service email
172
 
172
 
173
-    if [[ $(onion_service_exists email) == "0" ]]; then
173
+    if [ ! -f /var/lib/tor/hidden_service_email/hostname ]; then
174
         echo $"email onion site hostname not found"
174
         echo $"email onion site hostname not found"
175
         systemctl restart tor
175
         systemctl restart tor
176
         exit 782352
176
         exit 782352

+ 5
- 15
src/freedombone-utils-onion Voir le fichier

50
     systemctl restart tor
50
     systemctl restart tor
51
 }
51
 }
52
 
52
 
53
-function onion_service_exists {
54
-    onion_service_name="$1"
55
-
56
-    if [ -f /var/lib/tor/hidden_service_${onion_service_name}/hostname ]; then
57
-        echo -n "1"
58
-    else
59
-        echo -n "0"
60
-    fi
61
-}
62
-
63
 function wait_for_onion_service_base {
53
 function wait_for_onion_service_base {
64
     onion_service_name="$1"
54
     onion_service_name="$1"
65
 
55
 
66
     sleep_ctr=0
56
     sleep_ctr=0
67
-    while [[ $(onion_service_exists ${onion_service_name}) == "0" ]]; do
57
+    while [ ! -f /var/lib/tor/hidden_service_${onion_service_name}/hostname ]; do
68
         sleep 1
58
         sleep 1
69
         sleep_ctr=$((sleep_ctr + 1))
59
         sleep_ctr=$((sleep_ctr + 1))
70
         if [ $sleep_ctr -gt 10 ]; then
60
         if [ $sleep_ctr -gt 10 ]; then
78
 
68
 
79
     wait_for_onion_service_base ${onion_service_name}
69
     wait_for_onion_service_base ${onion_service_name}
80
 
70
 
81
-    if [[ $(onion_service_exists ${onion_service_name}) == "0" ]]; then
71
+    if [ ! -f /var/lib/tor/hidden_service_${onion_service_name}/hostname ]; then
82
         # try a second time
72
         # try a second time
83
         onion_update
73
         onion_update
84
         wait_for_onion_service_base ${onion_service_name}
74
         wait_for_onion_service_base ${onion_service_name}
123
     onion_service_port_to=$3
113
     onion_service_port_to=$3
124
     onion_stealth_name="$4"
114
     onion_stealth_name="$4"
125
 
115
 
126
-    if [[ $(onion_service_exists ${onion_service_name}) == "1" ]]; then
127
-        cat /var/lib/tor/hidden_service_${onion_service_name}/hostname
116
+    if [ -f /var/lib/tor/hidden_service_${onion_service_name}/hostname ]; then
117
+        echo $(cat /var/lib/tor/hidden_service_${onion_service_name}/hostname)
128
         return
118
         return
129
     fi
119
     fi
130
 
120
 
145
     function_check wait_for_onion_service
135
     function_check wait_for_onion_service
146
     wait_for_onion_service ${onion_service_name}
136
     wait_for_onion_service ${onion_service_name}
147
 
137
 
148
-    if [[ $(onion_service_exists ${onion_service_name}) == "0" ]]; then
138
+    if [ ! -f /var/lib/tor/hidden_service_${onion_service_name}/hostname ]; then
149
         echo $"${onion_service_name} onion site hostname not found"
139
         echo $"${onion_service_name} onion site hostname not found"
150
         exit 763624
140
         exit 763624
151
     fi
141
     fi