Bob Mottram 8 lat temu
rodzic
commit
e4bb83835c
1 zmienionych plików z 21 dodań i 116 usunięć
  1. 21
    116
      src/freedombone-utils-config

+ 21
- 116
src/freedombone-utils-config Wyświetl plik

@@ -181,125 +181,30 @@ function check_system_type {
181 181
     echo "System type: $SYSTEM_TYPE"
182 182
 }
183 183
 
184
-# check that domain names are sensible
184
+# check that domain names are valid and that they are unique for each app
185 185
 function check_domains {
186
-    if [ ${#WIKI_DOMAIN_NAME} -gt 1 ]; then
187
-        function_check test_domain_name
188
-        test_domain_name "$WIKI_DOMAIN_NAME"
189
-
190
-        if [[ "$test_domain_name" == "$FULLBLOG_DOMAIN_NAME" ]]; then
191
-            echo $'Wiki domain name is the same as blog domain name. They must be different'
192
-            exit 97326
193
-        fi
194
-        if [[ "$test_domain_name" == "$MICROBLOG_DOMAIN_NAME" ]]; then
195
-            echo $'Wiki domain name is the same as microblog domain name. They must be different'
196
-            exit 36827
197
-        fi
198
-        if [[ "$test_domain_name" == "$HUBZILLA_DOMAIN_NAME" ]]; then
199
-            echo $'Wiki domain name is the same as hubzilla domain name. They must be different'
200
-            exit 65848
201
-        fi
202
-        if [ ${#GIT_DOMAIN_NAME} -gt 1 ]; then
203
-            if [[ "$test_domain_name" == "$GIT_DOMAIN_NAME" ]]; then
204
-                echo $'Wiki domain name is the same as Gogs domain name. They must be different'
205
-                exit 73529
206
-            fi
207
-        fi
208
-    fi
209
-
210
-    if [ ${#FULLBLOG_DOMAIN_NAME} -gt 1 ]; then
211
-        function_check test_domain_name
212
-        test_domain_name "$FULLBLOG_DOMAIN_NAME"
213
-
214
-        if [[ "$test_domain_name" == "$WIKI_DOMAIN_NAME" ]]; then
215
-            echo $'Blog domain name is the same as wiki domain name. They must be different'
216
-            exit 62348
217
-        fi
218
-        if [[ "$test_domain_name" == "$MICROBLOG_DOMAIN_NAME" ]]; then
219
-            echo $'Blog domain name is the same as microblog domain name. They must be different'
220
-            exit 38236
221
-        fi
222
-        if [[ "$test_domain_name" == "$HUBZILLA_DOMAIN_NAME" ]]; then
223
-            echo $'Blog domain name is the same as hubzilla domain name. They must be different'
224
-            exit 35483
225
-        fi
226
-        if [ $GIT_DOMAIN_NAME ]; then
227
-            if [[ "$test_domain_name" == "$GIT_DOMAIN_NAME" ]]; then
228
-                echo $'Blog domain name is the same as Gogs domain name. They must be different'
229
-                exit 84695
230
-            fi
231
-        fi
232
-    fi
233
-
234
-    if [ ${#MICROBLOG_DOMAIN_NAME} -gt 1 ]; then
235
-        function_check test_domain_name
236
-        test_domain_name "$MICROBLOG_DOMAIN_NAME"
237
-
238
-        if [[ "$test_domain_name" == "$WIKI_DOMAIN_NAME" ]]; then
239
-            echo $'Microblog domain name is the same as wiki domain name. They must be different'
240
-            exit 73924
241
-        fi
242
-        if [[ "$test_domain_name" == "$FULLBLOG_DOMAIN_NAME" ]]; then
243
-            echo $'Microblog domain name is the same as blog domain name. They must be different'
244
-            exit 26832
245
-        fi
246
-        if [[ "$test_domain_name" == "$HUBZILLA_DOMAIN_NAME" ]]; then
247
-            echo $'Microblog domain name is the same as hubzilla domain name. They must be different'
248
-            exit 678382
249
-        fi
250
-        if [ $GIT_DOMAIN_NAME ]; then
251
-            if [[ "$test_domain_name" == "$GIT_DOMAIN_NAME" ]]; then
252
-                echo $'Microblog domain name is the same as Gogs domain name. They must be different'
253
-                exit 684325
254
-            fi
255
-        fi
256
-    fi
257
-
258
-    if [ $HUBZILLA_DOMAIN_NAME ]; then
259
-        function_check test_domain_name
260
-        test_domain_name "$HUBZILLA_DOMAIN_NAME"
261
-
262
-        if [[ "$test_domain_name" == "$WIKI_DOMAIN_NAME" ]]; then
263
-            echo $'Hubzilla domain name is the same as wiki domain name. They must be different'
264
-            exit 83682
265
-        fi
266
-        if [[ "$test_domain_name" == "$FULLBLOG_DOMAIN_NAME" ]]; then
267
-            echo $'Hubzilla domain name is the same as blog domain name. They must be different'
268
-            exit 74817
269
-        fi
270
-        if [[ "$test_domain_name" == "$MICROBLOG_DOMAIN_NAME" ]]; then
271
-            echo $'Hubzilla domain name is the same as microblog domain name. They must be different'
272
-            exit 83683
273
-        fi
274
-        if [ ${#GIT_DOMAIN_NAME} -gt 1 ]; then
275
-            if [[ "$test_domain_name" == "$GIT_DOMAIN_NAME" ]]; then
276
-                echo $'Hubzilla domain name is the same as Gogs domain name. They must be different'
277
-                exit 135523
186
+    specified_domains=$(cat $CONFIGURATION_FILE | grep "_DOMAIN_NAME" | uniq)
187
+    domains_array=($specified_domains)
188
+    checked_domains=()
189
+
190
+    for d in "${domains_array[@]}"
191
+    do
192
+        domain_param=$(echo "$d" | awk -F '=' '{print $1}')
193
+        if [[ $domain_param != "DEFAULT_DOMAIN_NAME" ]]; then
194
+            domain_value=$(echo "$d" | awk -F '=' '{print $2}')
195
+            item_in_array "${domain_value}" "${checked_domains[@]}"
196
+            if [[ $? != 0 ]]; then
197
+                # test that this is a valid domain name
198
+                function_check test_domain_name
199
+                test_domain_name "$domain_value"
200
+                # add it to the list of domains
201
+                checked_domains+=("$domain_value")
202
+            else
203
+                echo $"Domain ${domain_value} collides with another app. The domain for each app should be unique."
204
+                exit 673925
278 205
             fi
279 206
         fi
280
-    fi
281
-
282
-    if [ ${#GIT_DOMAIN_NAME} -gt 1 ]; then
283
-        function_check test_domain_name
284
-        test_domain_name "$GIT_DOMAIN_NAME"
285
-
286
-        if [[ "$test_domain_name" == "$WIKI_DOMAIN_NAME" ]]; then
287
-            echo $'Hubzilla domain name is the same as wiki domain name. They must be different'
288
-            exit 83682
289
-        fi
290
-        if [[ "$test_domain_name" == "$FULLBLOG_DOMAIN_NAME" ]]; then
291
-            echo $'Hubzilla domain name is the same as blog domain name. They must be different'
292
-            exit 74817
293
-        fi
294
-        if [[ "$test_domain_name" == "$MICROBLOG_DOMAIN_NAME" ]]; then
295
-            echo $'Hubzilla domain name is the same as microblog domain name. They must be different'
296
-            exit 83683
297
-        fi
298
-        if [[ "$test_domain_name" == "$HUBZILLA_DOMAIN_NAME" ]]; then
299
-            echo $'Microblog domain name is the same as hubzilla domain name. They must be different'
300
-            exit 678382
301
-        fi
302
-    fi
207
+    done
303 208
 }
304 209
 
305 210
 # NOTE: deliberately no exit 0