Showing 2 changed files with 36 additions and 16 deletions
+25 -16
flightgear/mount.terrafs
... ...
@@ -2,17 +2,6 @@
2 2
 
3 3
 terrafs_d=${1:-$HOME/.fgfs/terrafs.d}
4 4
 
5
-typeset -A osm2city_urls=(
6
-        cdn.merspieler.tk       o2c
7
-        ukmirror.flightgear.org osm2city
8
-    )
9
-
10
-typeset -A ws20_urls=(
11
-        cdn.merspieler.tk          ts
12
-        ukmirror.flightgear.org    fgscenery
13
-        flightgear.sourceforge.net scenery
14
-    )
15
-
16 5
 osm2city_dirs=(
17 6
         Buildings
18 7
         Details
... ...
@@ -28,6 +17,27 @@ ws20_dirs=(
28 17
         Terrain
29 18
     )
30 19
 
20
+for k in ${(koM)parameters}; do
21
+    if [[ $k =~ .+_dirs && ${(M)parameters[$k]} == array ]]; then
22
+        sceneries+=(${k%_dirs})
23
+        typeset -A ${k%_dirs}_urls
24
+    fi
25
+done
26
+
27
+if test -r $0.conf; then
28
+    source $0.conf
29
+else
30
+    echo pas de $0.conf trouvé
31
+    exit 1
32
+fi
33
+
34
+for scenery in ${sceneries[@]}; do
35
+    if ! eval "test \${#${scenery}_urls[@]} -gt 0"; then
36
+        echo $scenery erreur
37
+        exit 1
38
+    fi
39
+done
40
+
31 41
 get_url () {
32 42
     eval "local hosts=(\${(k)${1}_urls[@]})"
33 43
     echo ${hosts[$(( $RANDOM % ${#hosts[@]} + 1 ))]}
... ...
@@ -44,8 +54,8 @@ get_largest () {
44 54
         echo largest=$1
45 55
         echo smallest=$2
46 56
     else
47
-        echo largest=$1
48
-        echo smallest=$2
57
+        echo largest=$2
58
+        echo smallest=$1
49 59
     fi
50 60
 }
51 61
 
... ...
@@ -59,14 +69,13 @@ mount_dirs () {
59 69
     done
60 70
 }
61 71
 
62
-eval $(get_largest ws20 osm2city)
63
-
64 72
 if test $(grep -Ec "^terrafs +$terrafs_d" /proc/mounts) -ne $(( ${#ws20_dirs[@]} + ${#osm2city_dirs[@]} )); then
73
+    eval $(get_largest ${sceneries[@]})
65 74
     eval "${largest}_url=$(get_url $largest)"
66 75
     eval "remove_url $smallest \$${largest}_url"
67 76
     eval "${smallest}_url=$(get_url $smallest)"
68 77
 
69
-    for m in ws20 osm2city; do
78
+    for m in ${sceneries[@]}; do
70 79
         eval "printf 'montage %s depuis %s\n' ${(U)m} \$${m}_url"
71 80
         mount_dirs $m
72 81
     done
+11
flightgear/mount.terrafs.conf
... ...
@@ -0,0 +1,11 @@
1
+osm2city_urls=(
2
+        cdn.merspieler.tk       o2c
3
+        ukmirror.flightgear.org osm2city
4
+    )
5
+
6
+ws20_urls=(
7
+        cdn.merspieler.tk          ts
8
+        ukmirror.flightgear.org    fgscenery
9
+#        flightgear.sourceforge.net scenery
10
+    )
11
+