Browse Source

Check that file exists

Bob Mottram 8 years ago
parent
commit
ff95d79d26
1 changed files with 6 additions and 4 deletions
  1. 6
    4
      src/freedombone-utils-onion

+ 6
- 4
src/freedombone-utils-onion View File

@@ -107,10 +107,12 @@ function add_onion_service {
107 107
     onion_address=$(cat /var/lib/tor/hidden_service_${onion_service_name}/hostname)
108 108
 
109 109
     # Record the domain in the completion file
110
-    if ! grep "${onion_service_name} onion domain" $COMPLETION_FILE; then
111
-        echo "${onion_service_name} onion domain:${onion_address}" >> $COMPLETION_FILE
112
-    else
113
-        sed -i "s|${onion_service_name} onion domain.*|${onion_service_name} onion domain:${onion_address}|g" $COMPLETION_FILE
110
+    if [ -f $COMPLETION_FILE ]; then
111
+        if ! grep "${onion_service_name} onion domain" $COMPLETION_FILE; then
112
+            echo "${onion_service_name} onion domain:${onion_address}" >> $COMPLETION_FILE
113
+        else
114
+            sed -i "s|${onion_service_name} onion domain.*|${onion_service_name} onion domain:${onion_address}|g" $COMPLETION_FILE
115
+        fi
114 116
     fi
115 117
 
116 118
     echo $onion_address