tor: After enabling hidden service, wait for info

This commit is contained in:
James Valleroy authored and Sunil Mohan Adapa committed 2016-01-30 18:08:47 +05:30
1 parent 07130b6007
commit 1e67fcb61a
1 file changed
+13 -2
+13 -2
View File
@@ -229,6 +229,14 @@ def _enable_hs(restart=True):
if is_enabled() and is_running():
action_utils.service_restart('tor')
# wait until hidden service information is available
tries = 0
while get_hidden_service() in ('', 'error'):
tries += 1
if tries >= 12:
return
time.sleep(10)
def _disable_hs(restart=True):
"""Disable Tor hidden service"""
@@ -326,8 +334,11 @@ def _update_ports():
</service>
"""
for name, number in ports.items():
with open(SERVICE_FILE.format(name), 'w') as service_file:
service_file.writelines(lines.format(name, number))
try:
with open(SERVICE_FILE.format(name), 'w') as service_file:
service_file.writelines(lines.format(name, number))
except FileNotFoundError:
return
action_utils.service_restart('firewalld')