1 contributor
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
#!/bin/zsh
function fgfs () {
local fgfs_source=$FGDIR/source
local fgfs_build=$FGDIR/build
local fgfs_install=$FGDIR/install
function update_fg () {
case $1 in
fgaddon)
test -r $HOME/.fgfs/fgaddon && DB="$FGADDON/fgaddon.db" bash $HOME/.fgfs/fgaddon
;;
check)
test -r $HOME/.fgfs/jenkins-status && bash $HOME/.fgfs/jenkins-status
;;
rss)
test -r $HOME/.fgfs/fgcoderss && bash $HOME/.fgfs/fgcoderss
;;
data)
for control_system update_command in ${(kv)control_system_data}; do
find $FGADDON \
-maxdepth 3 \
-mindepth 1 \
-type d \
-name .${control_system} \
-printf "\n[ %h ]\n" \
-execdir ${control_system} ${update_command} \;
done
;;
source)
for component in $(<$fgfs_source/.$2); do
for control_system update_command in ${(kv)control_system_data}; do
find $fgfs_source/$component \
-maxdepth 1 \
-type d \
-name .${control_system} \
-printf "\n[ %h ]\n" \
-execdir ${control_system} ${update_command} \;
done
done
;;
build)
local simultaneous=$(nproc)
local previously_installed=()
mkdir -p $fgfs_install
for component in $(<$fgfs_source/.$2); do
if test -d $fgfs_source/$component/.git; then
local branch=$(git -C $fgfs_source/$component name-rev --name-only --no-undefined --always HEAD)
elif test -d $fgfs_source/${component}/.svn; then
local branch=${${(s:/:)$(svn info --show-item relative-url $fgfs_source/$component)}[2]}
fi
if test -r $fgfs_source/$component/CMakeLists.txt; then
local cmake_options=("-DCMAKE_BUILD_TYPE=Release" "-DCMAKE_INSTALL_PREFIX=$fgfs_install/$component")
test -e $fgfs_source/${component}.specific && source $fgfs_source/${component}.specific
if test ${#previously_installed[@]} -gt 0; then
cmake_options+=(${(j. .)${:--DCMAKE_PREFIX_PATH=$fgfs_install/${^previously_installed}}})
cmake_options+=(${(j. .)${:--DCMAKE_INCLUDE_PATH=$fgfs_install/${^previously_installed}/include}})
fi
title="*** ${component:u}${branch:+ [$branch]} ***"
printf "\n%s\n%s\n%s\n" "${(l:${#title}::*:)}" "$title" "${(l:${#title}::*:)}"
mkdir -p $fgfs_build/$component
cd $fgfs_build/$component
echo cmake ${cmake_options[@]//$HOME/\$HOME} ${fgfs_source/#$HOME/\$HOME}/$component
cmake ${cmake_options[@]} $fgfs_source/$component > /dev/null \
&& make -j$simultaneous > /dev/null \
&& {
make install | sed -r "s,$HOME,\$HOME,; /^-- Up-to-date:/d"
} \
|| {
echo "erreur construction $component"
cd $FGDIR
return
}
cd - > /dev/null
fi
previously_installed+=($component)
done
unset component
;;
esac
}
function ld_library_path () {
for component in $(<$fgfs_source/.flightgear); do
if test -d $fgfs_install/$component/lib; then
lib="$fgfs_install/$component/lib"
egrep -q "(^|:)$lib(:|$)" <<< "${LD_LIBRARY_PATH}" || LD_LIBRARY_PATH="${lib}${LD_LIBRARY_PATH:+:}${LD_LIBRARY_PATH}"
fi
done
export LD_LIBRARY_PATH
}
function check_fgaddon () {
if ! test -r $FGADDON/fgaddon.db; then
echo "aircraft DB not found at $FGADDON/fgaddon.db"
echo "please run $0 --update-fgaddon"
return 1
fi
if ! command -v sqlite3 > /dev/null; then
which sqlite3
return 1
fi
}
local aircrafts="$FGADDON/Aircraft"
local fgfs_args=("--fg-root=$FGDIR/source/fgdata")
local aircraft=
local airport=
if [[ -o BASH_REMATCH ]]; then
local bash_rematch_set=1
fi
for fgfs_arg in $@; do
if test ${fgfs_arg#--} = ${fgfs_arg}; then
if test -n "$(find $aircrafts -maxdepth 2 -type f -name ${fgfs_arg}-set.xml -print -quit)"; then
fgfs_args+=("--aircraft=$fgfs_arg")
fgfs_args+=("--fg-aircraft=$FGADDON/Aircraft")
elif official_aircraft=$(find "$fgfs_source/fgdata/Aircraft" -maxdepth 2 -type f -name ${fgfs_arg}-set.xml -printf "%h" -quit) && test -n "$official_aircraft"; then
fgfs_args+=("--aircraft=$fgfs_arg")
fgfs_args+=("--aircraft-dir=$official_aircraft")
unset official_aircraft
elif which sqlite3 > /dev/null 2>&1 \
&& test -r $FGADDON/fgaddon.db \
&& test $(sqlite3 $FGADDON/fgaddon.db <<< "select count(file) from setxml where file is '${fgfs_arg}'") -gt 0; then
local PS3='which aircraft ? '
local IFS=$'\n'
select ac in $(sqlite3 $FGADDON/fgaddon.db <<< "select distinct printf('%s [%s, %s]',
aircrafts.name,
hangars.name,
date(aircrafts.date, 'unixepoch'))
from aircrafts
inner join setxml, hangars
where
aircrafts.hangar = hangars.id
and
setxml.variantof = aircrafts.id
and
setxml.file = '${fgfs_arg}'
order by aircrafts.date desc"); do
test -z "$ac" && continue
read -q "REPLY?download ${${(@s/ /)ac}[1]} ? (y/N) "
if test -n "$REPLY" && test ${REPLY:l} = "y"; then
declare -A hangar
eval $(sqlite3 $FGADDON/fgaddon.db <<< "select printf('hangar[type]=%s;hangar[url]=%s;', type, url)
from hangars where name = '${${(@s/ /)ac}[2]:1:-1}'")
case ${hangar[type]} in
git)
git -C $FGADDON/Aircraft clone ${hangar[url]}/${${(@s/ /)ac}[1]}.git;;
svn)
svn checkout ${hangar[url]}/${${(@s/ /)ac}[1]} $FGADDON/Aircraft/${${(@s/ /)ac}[1]};;
esac
fgfs_args+=("--aircraft=$fgfs_arg")
fgfs_args+=("--fg-aircraft=$FGADDON/Aircraft")
unset -v hangar
else
echo "falling back to default"
fi
break
done
elif set -o BASH_REMATCH && [[ $fgfs_arg =~ "^mp([0-9]+)$" ]]; then
fgfs_args+=("--multiplay=out,10,mpserver${BASH_REMATCH[2]}.flightgear.org,5000")
if test -n "$(ls -rt1 $HOME/.fgfs/autosave_*.xml | tail -1)"; then
callsign=$(sed -rn 's/^.*<callsign.*>(.+)<.callsign>.*$/\1/p' $(ls -rt1 $HOME/.fgfs/autosave_*.xml | tail -1))
fi
if test -n "$callsign"; then
fgfs_args+=("--callsign=$callsign")
fi
test -z "$bash_rematch_set" && set +o BASH_REMATCH
elif [[ $fgfs_arg == "log" ]]; then
local log_requested=1
else
local candidate_airport=${fgfs_arg%:*}; [[ $candidate_airport == $fgfs_arg ]] && candidate_airport=${fgfs_arg%+*}
local candidate_parking=${fgfs_arg#*:}; [[ $candidate_parking == $fgfs_arg ]] && unset candidate_parking
local candidate_runway=${fgfs_arg#*+}; [[ $candidate_runway == $fgfs_arg ]] && unset candidate_runway
local terrafs=${candidate_airport#-}
if [[ $terrafs != $candidate_airport && -x $HOME/.fgfs/terrafs && -d $HOME/.fgfs/terrafs.d ]]; then
candidate_airport=$terrafs
$HOME/.fgfs/terrafs $HOME/.fgfs/terrafs.d
fgfs_args+=(--fg-scenery=$HOME/.fgfs/terrafs.d)
fgfs_args+=(--disable-terrasync)
local scenes_dir=$HOME/.fgfs/terrafs.d
else
fgfs_args+=(--terrasync-dir=$HOME/.fgfs/TerraSync)
fgfs_args+=(--enable-terrasync)
local scenes_dir=$HOME/.fgfs/TerraSync
fi
local airport_data="$scenes_dir/Airports/$candidate_airport[1]:u/$candidate_airport[2]:u/$candidate_airport[3]:u/${candidate_airport:u}"
if ! test -r "${airport_data}.threshold.xml"; then
echo "airport ${candidate_airport:u} not found !"
fi
if test -n "$candidate_parking" && test "$candidate_parking" = '?'; then
if test -r "${airport_data}.groundnet.xml"; then
echo "Parkings ${candidate_airport:u}:"
sed -rn "/<parkingList/,/parkingList>/s/^.* name=\"([^\"]+).*$/\1/p" "${airport_data}.groundnet.xml"
else
echo "no information for parkings available on ${candidate_airport:u}"
fi
return
elif test -n "$candidate_runway" && test "$candidate_runway" = '?'; then
if test -r "${airport_data}.threshold.xml"; then
echo "Runways ${candidate_airport:u}:"
sed -rn 's|^.*<rwy>(.+)</rwy>.*$|\1|p' "${airport_data}.threshold.xml"
else
echo "no information for runways available on ${candidate_airport:u}"
fi
return
fi
if test -r "${airport_data}.threshold.xml"; then
fgfs_args+=(--airport=$candidate_airport)
if [[ -a "${airport_data}.groundnet.xml" && -n "$candidate_parking" ]]; then
if sed -rn "/<parkingList/,/parkingList>/p" "${airport_data}.groundnet.xml" | grep -q "name=\"${candidate_parking}\""; then
fgfs_args+=("--parkpos='$candidate_parking'")
else
echo "$candidate_parking isn't a valid parking position"
fi
elif test -n "$candidate_runway"; then
if grep -q "<rwy>${candidate_runway}</rwy>" "${airport_data}.threshold.xml"; then
fgfs_args+=("--runway=$candidate_runway")
else
echo "$candidate_runway isn't a valid runway"
fi
fi
fi
fi
else
case $fgfs_arg in
--update(-data|-source|-build|))
echo 10 met à jour les data, les sources, ou compile. Prend en option le projet > /dev/null
if test ! -r $fgfs_source/.${2:-flightgear}; then
echo "${2:+unknown set $2\n}usage: --update|--update-data|--update-source|--update-build <set>"
echo "available sets :" ${$(find $fgfs_source -maxdepth 1 -type f -name ".*" -printf "%f ")//#.}
return 1
fi
for component in $(<$fgfs_source/.${2:-flightgear}); do
if ! test -d $fgfs_source/$component; then
echo component $component not found
return 1
fi
done
typeset -A control_system_data=(
git pull
svn up
)
for up in ${${=${fgfs_arg#--update}:-data source build}#-}; do
update_fg $up ${2:-flightgear}
done
unset control_system_data control_system update_command up
return
;;
--update-(fgaddon|check|rss))
echo 11 utilise les scripts externe fgaddon, check ou rss > /dev/null
update_fg ${fgfs_arg#--update-}
return
;;
--help)
echo 1 affiche cette aide et quitte > /dev/null
(
cat << EOH
VARIABLES IMPORTANTES:
FGDIR = ${FGDIR:-/!\\ ATTENTION FGDIR VIDE /!\\}
FGADDON = ${FGADDON:-/!\\ ATTENTION FGADDON VIDE /!\\}
OPTIONS SPÉCIFIQUES AU SCRIPT:
les options commençant par "--" sont:
$(declare -f $0 \
| sed -rn "s|^\s*\((--.+)\) echo ([0-9]+) \"?(.+)\"? > /dev/null$|\1:\2:\3|p" \
| sed 's/"$//' \
| awk -F':' -v dq='"' '
BEGIN {
maxlength = 0
}
{
order[$1] = strtonum($2)
option[$1] = $3
if (length($1) > maxlength) maxlength = length($1)
}
END {
PROCINFO["sorted_in"] = "@val_num_asc"
for (o in order)
printf("%s%s%*s%s\n", order[o] % 10 == 0 ? "\n" : "", o, maxlength - length(o) + 1, " ", option[o])
}')
les options ne commençant pas par "--" peuvent être
* log: crée un log au format igc et enregistré dans le fichier au nom comprenant date, heure et nom de l'appareil,
avec une fréquence de 1Hz
* mp[0-9]+: un serveur de multiplayer sur lequel se connecter, le callsign sera aussi configuré avec celui trouvé dans autosave,
par exemple mp01 pour une connexion sur mpserver01.flightgear.org:5000
* un appareil: c172p, si l'appareil n'est pas installé mais présent dans la base de données, il sera proposé de l'installer
* un aéroport:
* sans emplacement précisé: lfbd
* avec une piste: lfbd+09, si la piste n'est pas trouvée sortie en erreur
il est possible de lister les pistes disponible avec lfbt+\\? (notez l'échappement \\ pour éviter une
interprétation du caractère \`?' par le shell:
$ fgfs ksfo+\\?
Runways KSFO:
01L
19R
01R
19L
10L
28R
10R
28L
* avec un emplacement de parking: lfbt:parking_1, si le parking n'est pas trouvé un message l'indique et il est ignoré
comme avec les pistes il est possible de lister les emplacements disponibles:
$ fgfs biis:\\?
Parkings BIIS:
Gate
Ramp_Start_1
Ramp_Start_2
Au lancement, la ligne de commande utilisée est affichée (dans l'exemple ci-dessous les options montrées mais son stipulées dans les paramètres proviennent de fgfsrc:
$ fgfs ercoupe biis
--fg-root=\$HOME/scripts/flightgear/source/fgdata --aircraft=ercoupe --fg-aircraft=\$HOME/.fgfs/flightgear-fgaddon/Aircraft --terrasync-dir=\$HOME/.fgfs/TerraSync --enable-terrasync --airport=biis --addon=\$HOME/.fgfs/flightgear-fgaddon/Addons/SpokenATC
...
OPTIONS SPÉCIFIQUES À FG:
$(ld_library_path; $FGDIR/install/flightgear/bin/fgfs $fgfs_arg --verbose 2>/dev/null | sed '1d; /: fgfs \[/,+1d')
EOH
) | pager
return
;;
--show-aircraft)
echo 32 liste les appareils (wrapper pour la même option de FG) > /dev/null
ld_library_path
$FGDIR/install/flightgear/bin/fgfs --show-aircraft --fg-aircraft=$FGADDON/Aircraft 2>/dev/null | pager
return
;;
--info)
echo 33 "donne des infos sur l'appareil en paramètre" > /dev/null
check_fgaddon || return 1
local IFS=$'\n'
function _info () {
local _info=$(sqlite3 $FGADDON/fgaddon.db <<< "select \`$1\`
from setxml
inner join aircrafts, hangars
where
aircrafts.hangar = hangars.id
and
setxml.variantof = aircrafts.id
and
setxml.file = '$file'
and
hangars.name = '${${(@s/ /)ac}[2]:1:-1}'")
if test -n "$_info"; then
printf "%s: %s\n" "$2" "$_info"
fi
}
local ac_list=($(sqlite3 $FGADDON/fgaddon.db <<< "select distinct printf('%s [%s, %s]',
aircrafts.name,
hangars.name,
date(aircrafts.date, 'unixepoch'))
from aircrafts
inner join setxml, hangars
where
aircrafts.hangar = hangars.id
and
setxml.variantof = aircrafts.id
and
setxml.file = '$2'
order by aircrafts.date desc"))
if test ${#ac_list[@]} -gt 1; then
local PS3='which aircraft ? '
select ac in ${ac_list[@]}; do
test -z "$ac" && continue
break
done
elif test ${#ac_list[@]} -eq 1; then
ac=${ac_list[1]}
else
return
fi
local file=$2
_info /sim/description "Short description"
_info /sim/long-description "Long description"
_info /sim/author "Author(s)"
_info /sim/flight-model "Flight model"
_info /sim/type "Type"
echo Ratings
for r in FDM systems cockpit model; do
_info /sim/rating/$r " $r"
done
return
;;
--show-thumbnail)
echo 32 "affiche la vignette de l'appareil en paramètre (cf. fgaddon)" > /dev/null
check_fgaddon || return 1
local PS3='which aircraft ? '
local IFS=$'\n'
local ac_list=($(sqlite3 $FGADDON/fgaddon.db <<< "select distinct printf('%s [%s, %s]',
aircrafts.name,
hangars.name,
date(aircrafts.date, 'unixepoch'))
from aircrafts
inner join setxml, hangars
where
aircrafts.hangar = hangars.id
and
setxml.variantof = aircrafts.id
and (
setxml.file like '%$2%'
or
aircrafts.name like '%$2%'
)
order by aircrafts.date desc"))
if test ${#ac_list[@]} -gt 1; then
local PS3='which aircraft ? '
select ac in ${ac_list[@]}; do
test -z "$ac" && continue
break
done
elif test ${#ac_list[@]} -eq 1; then
ac=${ac_list[1]}
else
return
fi
local url=$(sqlite3 $FGADDON/fgaddon.db <<< "select printf('%s/${${(@s/ /)ac}[1]}', url)
from hangars where name = '${${(@s/ /)ac}[2]:1:-1}'")
if test ${${(@s/ /)ac}[2]:1:-1} = 'FGMEMBERS'; then
url="https://raw.githubusercontent.com/FGMEMBERS/${${(@s/ /)ac}[1]}/master"
fi
if wget --quiet --spider "$url/thumbnail.jpg"; then
curl -s "$url/thumbnail.jpg" \
| convert - -resize '200%' -normalize -sharpen '0.0x1.0' - \
| display
else
echo "can't find or get thumbnail for ${${(@s/ /)ac}[1]} (${${(@s/ /)ac}[2]:1:-1}'s hangar)"
fi
return
;;
--search)
echo 30 "cherche un appareil dans la base de données par le nom" > /dev/null
check_fgaddon || return 1
sqlite3 $FGADDON/fgaddon.db <<< "select printf('[%s, %s] %s (%s): %s ',
hangars.name,
date(aircrafts.date, 'unixepoch'),
setxml.file,
setxml.\`/sim/flight-model\`,
setxml.\`/sim/description\`)
from setxml
inner join aircrafts, hangars
where
aircrafts.hangar = hangars.id
and
setxml.variantof = aircrafts.id
and (
setxml.file like '%$2%'
or
aircrafts.name like '%$2%'
)
order by aircrafts.date desc"
return
;;
--search-rating)
echo 31 "cherche un appareil dans la base de données par l'évaluation" > /dev/null
check_fgaddon || return 1
if test -z $(sqlite3 $FGADDON/fgaddon.db <<< "select 1 from pragma_table_info('setxml')
where name == '/sim/rating/${2:-void}'"); then
echo "rating ${2:-void} non trouvé, ratings disponibles:"
sqlite3 $FGADDON/fgaddon.db <<< "select name from pragma_table_info('setxml')
where name like '/sim/rating/%'" | sed 's,/sim/rating/, - ,'
return
fi
sqlite3 $FGADDON/fgaddon.db <<< "select printf('[%s, %s] %s (%s): %s ',
hangars.name,
date(aircrafts.date, 'unixepoch'),
setxml.file,
setxml.\`/sim/flight-model\`,
setxml.\`/sim/description\`)
from setxml
inner join aircrafts, hangars
where
aircrafts.hangar = hangars.id
and
setxml.variantof = aircrafts.id
and
setxml.\`/sim/rating/$2\` >= ${3:-4}
order by aircrafts.date desc"
return
;;
--mp-list)
echo 40 renvoie la liste des appareils visibles sur multiplayer depuis mpserver01 > /dev/null
local mplist=$(mktemp --dry-run /dev/shm/XXXXXXXXX)
declare -A installed_model fgaddon_model unknown_model
local ac_name=
local MPSERVER=${MPSERVER:-mpserver01.flightgear.org}
local MPPORT=${MPPORT:-5001}
echo data from $MPSERVER:$MPPORT
telnet $MPSERVER $MPPORT 2>/dev/null > $mplist
grep 'pilot(s) online' $mplist
echo
local IFS=$'\n'
for model in $(awk '/@/{a[$NF]++}END{for (i in a) printf("%s (%i)\n", i, a[i])}' $mplist); do
if test -r $FGADDON/${model% *} \
-o -r $FGDIR/source/fgdata/${model% *}; then
((++installed_model[${${(s:/:)model}[2]} ${model#* }]))
elif test -r $FGDIR/source/fgdata/AI/${model% *}; then
((++installed_model[*${${(s:/:)model}[2]} ${model#* }]))
elif test -n "$(command -v sqlite3)" -a -r $FGADDON/fgaddon.db; then
ac_name=$(sqlite3 $FGADDON/fgaddon.db <<< 'select printf("%s/%s", aircrafts.name, setxml.file)
from aircrafts
inner join setxml
where aircrafts.id = setxml.variantof
and setxml.`/sim/model/path` = "'${model% *}'"
limit 1')
if test -n "$ac_name"; then
((++fgaddon_model[${ac_name} ${model#* }]))
else
((++unknown_model[${model}]))
fi
else
((++unknown_model[${model}]))
fi
done
if test ${#installed_model[@]} -gt 0; then
echo "${(j:\n:)${(Ok)installed_model[@]}}" > $mplist
echo -e "${#installed_model[@]} models installed (*AI model only):\n$(column -c$(tput cols) $mplist)\n"
fi
if test ${#fgaddon_model[@]} -gt 0; then
echo "${(j:\n:)${(Ok)fgaddon_model[@]}}" > $mplist
echo -e "${#fgaddon_model[@]} models available in FGADDON:\n$(column -c$(tput cols) $mplist)\n"
fi
if test ${#unknown_model[@]} -gt 0; then
echo "${(j:\n:)${(Ok)unknown_model[@]}}" > $mplist
echo -e "${#unknown_model[@]} unknown models:\n$(column -c$(tput cols) $mplist)"
fi
unset installed_model unknown_model fgaddon_model
rm $mplist
return
;;
--install)
echo 35 "installe l'appareil donné en paramètre" > /dev/null
check_fgaddon || return 1
local PS3='which aircraft ? '
local IFS=$'\n'
select ac in $(sqlite3 $FGADDON/fgaddon.db <<< "select distinct printf('%s [%s, %s]',
aircrafts.name,
hangars.name,
date(aircrafts.date, 'unixepoch'))
from aircrafts
inner join setxml, hangars
where
aircrafts.hangar = hangars.id
and
setxml.variantof = aircrafts.id
and (
setxml.file like '%$2%'
or
aircrafts.name like '%$2%'
)
order by aircrafts.date desc"); do
test -z "$ac" && continue
done
test -z "$ac" && return
declare -A hangar
eval $(sqlite3 $FGADDON/fgaddon.db <<< "select printf('hangar[type]=%s;hangar[url]=%s;', type, url)
from hangars where name = '${${(@s/ /)ac}[2]:1:-1}'")
case ${hangar[type]} in
git)
git -C $FGADDON/Aircraft clone ${hangar[url]}/${${(@s/ /)ac}[1]}.git;;
svn)
svn checkout ${hangar[url]}/${${(@s/ /)ac}[1]} $FGADDON/Aircraft/${${(@s/ /)ac}[1]};;
esac
unset hangar
return
;;
--mumble)
echo 90 lance FG avec mumble > /dev/null
if pgrep -u $USER mumble > /dev/null; then
echo "there is already a mumble instance launched"
else
mumble_desktop_entry=($(if test -n "$XDG_DATA_DIRS"; then find "${(s/:/)XDG_DATA_DIRS}" -type f,l -iname "*mumble*desktop"; fi))
if test ${#mumble_desktop_entry[@]} -gt 0; then
echo lauching ${mumble_desktop_entry[1]}
nohup gtk-launch ${mumble_desktop_entry[1]##*/} > /dev/null 2>&1 &
else
echo "no desktop entry found for mumble (XDG_DATA_DIRS=$XDG_DATA_DIRS)"
return 1
fi
fi
;&
--fgcom)
echo 91 lance FG avec fgcom-mumble > /dev/null
if test -r $fgfs_source/fgcom-mumble/client/fgfs-addon/addon-metadata.xml; then
fgfs_args+=("--addon=$fgfs_source/fgcom-mumble/client/fgfs-addon")
else
echo "can't find addon fgcom-mumble"
return 1
fi
;;
--map|--lnm)
echo 92 lance LittleNavMap en parallèle ainsi que la liaison avec FG > /dev/null
if ! pgrep -u $USER -f "python3 ./fgconnect.py" > /dev/null; then
if test -d $FGADDON/Addons/littlenavmap -a -x $fgfs_source/fgconnect/fgconnect.py; then
( cd $fgfs_source/fgconnect; python3 ./fgconnect.py -s )&
else
echo "can't find FGconnect or littlenavmap addon"
return 1
fi
else
echo "FGconnect already lauched"
fi
fgfs_args+=("--addon=$FGADDON/Addons/littlenavmap")
;;
--addon=*)
echo 99 lance FG avec un addon spécifique installé > /dev/null
addon_path="${fgfs_arg#*=}"
if test -d "$addon_path"; then
fgfs_args+=("--addon=$addon_path")
elif test -d "$FGADDON/Addons/$addon_path"; then
fgfs_args+=("--addon=$FGADDON/Addons/$addon_path")
else
echo "can't find requested addon in $addon_path or $FGADDON/$addon_path !"
fi
;;
--ws3)
echo 80 utilise World Scenery 3.0 > /dev/null
fgfs_args+=("--prop:bool:/scenery/use-vpb=true")
fgfs_args+=("--prop:int:/sim/rendering/max-paged-lod=300")
fgfs_args+=("--prop:double:/sim/rendering/plod-minimum-expiry-time-secs=30")
;;
--ortho)
echo 81 utilise Orthoscenery > /dev/null
fgfs_args+=("--prop:bool:/sim/rendering/photoscenery/enabled=true")
;;
--hdr)
echo 82 utilise le compositor HDR > /dev/null
local compositor=Compositor/HDR/hdr
if test -r $fgfs_source/fgdata/$compositor.xml; then
fgfs_args+=("--compositor=$compositor")
fgfs_args+=("--prop:bool:/sim/rendering/osm-buildings=false")
fgfs_args+=("--prop:bool:/sim/rendering/random-buildings=false")
else
echo "Compositor $compositor inaccessible"
fi
;;
*)
completion_source="$FGDIR/install/flightgear/share/zsh/site-functions/_fgfs"
if test -r "$completion_source"; then
if egrep --quiet "^\s*'(${fgfs_arg%=*}=?|)\[" "$completion_source" \
|| [[ ${fgfs_arg} =~ ^--prop(:(string|double|float|long|int|bool))?:/[[:print:]]+= ]]; then
fgfs_args+=($fgfs_arg)
else
echo unknown option: ${fgfs_arg%=*}
return 1
fi
else
fgfs_args+=($fgfs_arg)
fi
;;
esac
fi
done
unset fgfs_arg
if [[ -n "$log_requested" && -z "${fgfs_args[(r)--igc=*]}" ]]; then
fgfs_args+=(--igc=file,out,1,$(date +%Y%m%d-%H%M-${${${fgfs_args[(r)--aircraft=*]}#--aircraft=}:-$(sed -rn 's|^.+aircraft>(.+)</aircraft.+$|\1|p' $FGDIR/source/fgdata/defaults.xml)}.igc))
fi
ld_library_path
fgfsrc=$HOME/.fgfs/fgfsrc
echo ${fgfs_args[@]//$HOME/\$HOME} $(test -r $fgfsrc && sed -r "/^\s*(#|$)/d;s|$HOME|\$HOME|" $fgfsrc | tr '\n' ' ')
primusrun $FGDIR/install/flightgear/bin/fgfs ${fgfs_args[@]}
if grep -q $HOME/.fgfs/terrafs.d /proc/mounts; then
fusermount -u $HOME/.fgfs/terrafs.d
fi
unset fgfs_args
}