scripts / flightgear / fgfs_function /
Newer Older
542 lines | 29.514kb
déplacement depuis dépôt con...
Sébastien MARQUE authored on 2021-05-28
1
#!/bin/zsh
2

            
3
#FGDIR=$HOME/scripts/flightgear
4
#FGADDON=$HOME/.fgfs/flightgear-fgaddon
5
function fgfs () {
6
    local fgfs_source=$FGDIR/source
7
    local fgfs_build=$FGDIR/build
8
    local fgfs_install=$FGDIR/install
9
    function update_fg () {
10
        case $1 in
11
            fgaddon)
just cosmetic
Sébastien MARQUE authored on 2021-12-19
12
                test -r $HOME/.fgfs/fgaddon && DB="$FGADDON/fgaddon.db" bash $HOME/.fgfs/fgaddon
déplacement depuis dépôt con...
Sébastien MARQUE authored on 2021-05-28
13
                ;;
14
            check)
15
                test -r $HOME/.fgfs/jenkins-status && bash $HOME/.fgfs/jenkins-status
16
                ;;
17
            rss)
18
                test -r $HOME/.fgfs/fgcoderss && bash $HOME/.fgfs/fgcoderss
19
                ;;
20
            data)
21
                for control_system update_command in ${(kv)control_system_data}; do
22
                    find $FGADDON \
23
                        -maxdepth 3 \
24
                        -mindepth 1 \
25
                        -type d \
26
                        -name .${control_system} \
27
                        -printf "\n[ %h ]\n" \
28
                        -execdir ${control_system} ${update_command} \;
29
                done
30
                ;;
31
            source)
32
                for component in $(<$fgfs_source/.$2); do
33
                    for control_system update_command in ${(kv)control_system_data}; do
34
                        find $fgfs_source/$component \
35
                            -maxdepth 1 \
36
                            -type d \
37
                            -name .${control_system} \
38
                            -printf "\n[ %h ]\n" \
39
                            -execdir ${control_system} ${update_command} \;
40
                    done
41
                done
42
                ;;
43
            build)
44
                local simultaneous=$(nproc)
45
                local previously_installed=()
46
                mkdir -p $fgfs_install
47
                for component in $(<$fgfs_source/.$2); do
48
                    if test -d $fgfs_source/$component/.git; then
49
                        local branch=$(git -C $fgfs_source/$component name-rev --name-only --no-undefined --always HEAD)
50
                    elif test -d $fgfs_source/${component}/.svn; then
51
                        local branch=${${(s:/:)$(svn info --show-item relative-url $fgfs_source/$component)}[2]}
52
                    fi
53

            
54
# TODO: prendre en compte les cas sans cmake
55
                    if test -r $fgfs_source/$component/CMakeLists.txt; then
56
                        local cmake_options=("-DCMAKE_BUILD_TYPE=Release" "-DCMAKE_INSTALL_PREFIX=$fgfs_install/$component")
57
                        test -e $fgfs_source/${component}.specific && source $fgfs_source/${component}.specific
58
                        if test ${#previously_installed[@]} -gt 0; then
59
                            cmake_options+=(${(j. .)${:--DCMAKE_PREFIX_PATH=$fgfs_install/${^previously_installed}}})
60
                            cmake_options+=(${(j. .)${:--DCMAKE_INCLUDE_PATH=$fgfs_install/${^previously_installed}/include}})
61
                        fi
62
                        cmake_options+=("-j$simultaneous")
63

            
64
                        title="*** ${component:u}${branch:+ [$branch]} ***"
65
                        printf "\n%s\n%s\n%s\n" "${(l:${#title}::*:)}" "$title" "${(l:${#title}::*:)}"
66
                        mkdir -p $fgfs_build/$component
67
                        cd $fgfs_build/$component
68

            
69
                        echo cmake ${cmake_options[@]//$HOME/\$HOME} ${fgfs_source/#$HOME/\$HOME}/$component
70

            
71
                        cmake ${cmake_options[@]} $fgfs_source/$component > /dev/null \
72
                        && make -j$simultaneous > /dev/null \
73
                        && {
74
                            make install | grep --color=always -v '^-- Up-to-date:'
75
                        } \
76
                        || {
77
                            echo "erreur construction $component"
78
                            cd $FGDIR
79
                            return
80
                        }
81

            
82
                        cd - > /dev/null
83
                    fi
84

            
85
                    previously_installed+=($component)
86
                done
87
                unset component
88
                ;;
89
        esac
90
    }
91
    function ld_library_path () {
92
        local IFS=$'\n'
93
        for lib in $(ls -d $FGDIR/install/*/lib); do
94
            egrep -q "(^|:)$lib(:|$)" <<< "${LD_LIBRARY_PATH}" || LD_LIBRARY_PATH="${lib}${LD_LIBRARY_PATH:+:}${LD_LIBRARY_PATH}"
95
        done
96
        export LD_LIBRARY_PATH
97
    }
98
    local aircrafts="$FGADDON/Aircraft"
99
    local fgfs_args=("--fg-root=$FGDIR/source/fgdata")
100
    local aircraft=
101
    local airport=
102
    if [[ -o BASH_REMATCH ]]; then
103
        local bash_rematch_set=1
104
    fi
105

            
106
    for fgfs_arg in $@; do
107
        if test ${fgfs_arg#--} = ${fgfs_arg}; then
108
############ APPAREIL DANS FGADDON ?
109
            if test -n "$(find $aircrafts -maxdepth 2 -type f -name ${fgfs_arg}-set.xml -print -quit)"; then
110
                fgfs_args+=("--aircraft=$fgfs_arg")
111
                fgfs_args+=("--fg-aircraft=$FGADDON/Aircraft")
112

            
113
############ APPAREIL DANS FGDIR/source/fgdata ?
114
            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
115
                fgfs_args+=("--aircraft=$fgfs_arg")
116
                fgfs_args+=("--aircraft-dir=$official_aircraft")
117
                unset official_aircraft
118

            
119
############ APPAREIL DISPONIBLE DANS UN HANGAR CONNU ?
120
            elif which sqlite3 > /dev/null 2>&1 \
121
            && test -r $FGADDON/fgaddon.db \
122
            && test $(sqlite3 $FGADDON/fgaddon.db <<< "select count(file) from setxml where file is '${fgfs_arg}'") -gt 0; then
123
                local PS3='which aircraft ? '
124
                local IFS=$'\n'
125
                select ac in $(sqlite3 $FGADDON/fgaddon.db <<< "select distinct printf('%s [%s, %s]',
126
                                                               aircrafts.name,
127
                                                               hangars.name,
128
                                                               date(aircrafts.date, 'unixepoch'))
129
                                                 from aircrafts
130
                                                 inner join setxml, hangars
131
                                                 where
132
                                                   aircrafts.hangar = hangars.id
133
                                                 and
134
                                                   setxml.variantof = aircrafts.id
135
                                                 and
136
                                                     setxml.file = '${fgfs_arg}'
137
                                                 order by aircrafts.date desc"); do
138
                    test -z "$ac" && continue
139
                    read -q "REPLY?download ${${(@s/ /)ac}[1]} ? (y/N) "
140
                    if test -n "$REPLY" && test ${REPLY:l} = "y"; then
141
                        declare -A hangar
142
                        eval $(sqlite3 $FGADDON/fgaddon.db <<< "select printf('hangar[type]=%s;hangar[url]=%s;', type, url)
143
                                                                from hangars where name = '${${(@s/ /)ac}[2]:1:-1}'")
144
                        case ${hangar[type]} in
145
                            git)
146
                                git -C $FGADDON/Aircraft clone ${hangar[url]}/${${(@s/ /)ac}[1]}.git;;
147
                            svn)
148
                                svn checkout ${hangar[url]}/${${(@s/ /)ac}[1]} $FGADDON/Aircraft/${${(@s/ /)ac}[1]};;
149
                        esac
150
                        fgfs_args+=("--aircraft=$fgfs_arg")
151
                        fgfs_args+=("--fg-aircraft=$FGADDON/Aircraft")
152
                        unset -v hangar
153
                    else
154
                        echo "falling back to default"
155
                    fi
156
                    break
157
                done
158

            
159
############ SERVEUR MULTIPLAY ?
160
            elif set -o BASH_REMATCH && [[ $fgfs_arg =~ "^mp([0-9]+)$" ]]; then
161
                fgfs_args+=("--multiplay=out,10,mpserver${BASH_REMATCH[2]}.flightgear.org,5000")
162
                fgfs_args+=("--callsign=f-zakh")
163
                test -z "$bash_rematch_set" && set +o BASH_REMATCH
164

            
165
############ DEMANDE DE TRACE DE VOL ?
166
            elif [[ $fgfs_arg == "log" ]]; then
167
                # option construite plus tard avec nom de l'appareil
168
                local log_requested=1
169

            
170
############ AEROPORT ?
171
            else 
172
                local candidate_airport=${fgfs_arg%:*}; [[ $candidate_airport == $fgfs_arg ]] && candidate_airport=${fgfs_arg%+*}
173
                local candidate_parking=${fgfs_arg#*:}; [[ $candidate_parking == $fgfs_arg ]] && unset candidate_parking
174
                local candidate_runway=${fgfs_arg#*+};  [[ $candidate_runway  == $fgfs_arg ]] && unset candidate_runway
175
                local terrafs=${candidate_airport#-}
176

            
177
                if [[ $terrafs != $candidate_airport && -x $HOME/.fgfs/terrafs && -d $HOME/.fgfs/terrafs.d ]]; then
178
                    candidate_airport=$terrafs
179
                    $HOME/.fgfs/terrafs $HOME/.fgfs/terrafs.d
180
                    fgfs_args+=(--fg-scenery=$HOME/.fgfs/terrafs.d)
181
                    fgfs_args+=(--disable-terrasync)
182
                    local scenes_dir=$HOME/.fgfs/terrafs.d
183
                else
184
                    fgfs_args+=(--terrasync-dir=$HOME/.fgfs/TerraSync)
185
                    fgfs_args+=(--enable-terrasync)
186
                    local scenes_dir=$HOME/.fgfs/TerraSync
187
                fi
188

            
189
                local airport_data="$scenes_dir/Airports/$candidate_airport[1]:u/$candidate_airport[2]:u/$candidate_airport[3]:u/${candidate_airport:u}"
190
                if ! test -r "${airport_data}.threshold.xml"; then
191
                    echo "airport ${candidate_airport:u} not found !"
192
                fi
193

            
194
                if test -n "$candidate_parking" && test "$candidate_parking" = '?'; then
195
                    if test -r "${airport_data}.groundnet.xml"; then
196
                        echo "Parkings ${candidate_airport:u}:"
197
                        sed -rn "/<parkingList/,/parkingList>/s/^.* name=\"([^\"]+).*$/\1/p" "${airport_data}.groundnet.xml"
198
                    else
199
                        echo "no information for parkings available on ${candidate_airport:u}"
200
                    fi
201
                    return
202
                elif test -n "$candidate_runway" && test "$candidate_runway" = '?'; then
203
                    if test -r "${airport_data}.threshold.xml"; then
204
                        echo "Runways ${candidate_airport:u}:"
205
                        sed -rn 's|^.*<rwy>(.+)</rwy>.*$|\1|p' "${airport_data}.threshold.xml"
206
                    else
207
                        echo "no information for runways available on ${candidate_airport:u}"
208
                    fi
209
                    return
210
                fi
211

            
212
                if test -r "${airport_data}.threshold.xml"; then
213
                    fgfs_args+=(--airport=$candidate_airport)
214
                    if [[ -a "${airport_data}.groundnet.xml" && -n "$candidate_parking" ]]; then
215
                        if sed -rn "/<parkingList/,/parkingList>/p" "${airport_data}.groundnet.xml" | grep -q "name=\"${candidate_parking}\""; then
216
                            fgfs_args+=("--parkpos='$candidate_parking'")
217
                        else
218
                            echo "$candidate_parking isn't a valid parking position"
219
                        fi
220
                    elif test -n "$candidate_runway"; then
221
                        if grep -q "<rwy>${candidate_runway}</rwy>" "${airport_data}.threshold.xml"; then
222
                            fgfs_args+=("--runway=$candidate_runway")
223
                        else
224
                            echo "$candidate_runway isn't a valid runway"
225
                        fi
226
                    fi
227
                fi
228
            fi
229

            
230
######## AUTRE OPTION
231
        else
232
            case $fgfs_arg in
233
                --update(-data|-source|-build|))
234
                    if test ! -r $fgfs_source/.${2:-flightgear}; then
235
                        echo "${2:+unknown set $2\n}usage: --update|--update-data|--update-source|--update-build <set>"
236
                        echo "available sets :" ${$(find $fgfs_source -maxdepth 1 -type f -name ".*" -printf "%f ")//#.}
237
                        return 1
238
                    fi
239
                    for component in $(<$fgfs_source/.${2:-flightgear}); do
240
                        if ! test -d $fgfs_source/$component; then
241
                            echo component $component not found
242
                            return 1
243
                        fi
244
                    done
245
                    typeset -A control_system_data=(
246
                        git pull
247
                        svn up
248
                    )
249
                    for up in ${${=${fgfs_arg#--update}:-data source build}#-}; do
250
                        update_fg $up ${2:-flightgear}
251
                    done
252
                    unset control_system_data control_system update_command up
253
                    return
254
                    ;;
255
                --update-(fgaddon|check|rss))
256
                    update_fg ${fgfs_arg#--update-}
257
                    return
258
                    ;;
259
                --(show-aircraft|help))
260
                    local -A complement=(
261
                        --show-aircraft --fg-aircraft=$FGADDON/Aircraft
262
                        --help          --verbose
263
                    )
264
                    ld_library_path
265
                    $FGDIR/install/flightgear/bin/fgfs $fgfs_arg ${complement[$fgfs_arg]} 2>/dev/null | pager
266
                    return
267
                    ;;
268
                --info)
269
                    local IFS=$'\n'
270
                    function _info () {
271
                        local _info=$(sqlite3 $FGADDON/fgaddon.db <<< "select \`$1\`
272
                                                     from setxml
273
                                                     inner join aircrafts, hangars
274
                                                     where
275
                                                       aircrafts.hangar = hangars.id
276
                                                     and
277
                                                       setxml.variantof = aircrafts.id
278
                                                     and
279
                                                       setxml.file = '$file'
280
                                                     and
281
                                                       hangars.name = '${${(@s/ /)ac}[2]:1:-1}'")
282
                        if test -n "$_info"; then
283
                            printf "%s: %s\n" "$2" "$_info"
284
                        fi
285
                    }
improve aircraft selection f...
Sébastien MARQUE authored on 2022-01-16
286
                    local ac_list=($(sqlite3 $FGADDON/fgaddon.db <<< "select distinct printf('%s [%s, %s]',
déplacement depuis dépôt con...
Sébastien MARQUE authored on 2021-05-28
287
                                                                   aircrafts.name,
288
                                                                   hangars.name,
289
                                                                   date(aircrafts.date, 'unixepoch'))
290
                                                     from aircrafts
291
                                                     inner join setxml, hangars
292
                                                     where
293
                                                       aircrafts.hangar = hangars.id
294
                                                     and
295
                                                       setxml.variantof = aircrafts.id
296
                                                     and
297
                                                         setxml.file = '$2'
improve aircraft selection f...
Sébastien MARQUE authored on 2022-01-16
298
                                                     order by aircrafts.date desc"))
299
                    if test ${#ac_list[@]} -gt 1; then
300
                        local PS3='which aircraft ? '
301
                        select ac in ${ac_list[@]}; do
302
                            test -z "$ac" && continue
303
                            break
déplacement depuis dépôt con...
Sébastien MARQUE authored on 2021-05-28
304
                        done
improve aircraft selection f...
Sébastien MARQUE authored on 2022-01-16
305
                    elif test ${#ac_list[@]} -eq 1; then
306
                        ac=${ac_list[1]}
307
                    else
déplacement depuis dépôt con...
Sébastien MARQUE authored on 2021-05-28
308
                        return
improve aircraft selection f...
Sébastien MARQUE authored on 2022-01-16
309
                    fi
310
                    local file=$2
311
                    _info /sim/description      "Short description"
312
                    _info /sim/long-description "Long description"
313
                    _info /sim/author           "Author(s)"
314
                    _info /sim/flight-model     "Flight model"
315
                    _info /sim/type             "Type"
316
                    echo Ratings
317
                    for r in FDM systems cockpit model; do
318
                        _info /sim/rating/$r "  $r"
déplacement depuis dépôt con...
Sébastien MARQUE authored on 2021-05-28
319
                    done
320
                    return
321
                    ;;
322
                --show-thumbnail)
323
                    local PS3='which aircraft ? '
324
                    local IFS=$'\n'
improve aircraft selection f...
Sébastien MARQUE authored on 2022-01-16
325
                    local ac_list=($(sqlite3 $FGADDON/fgaddon.db <<< "select distinct printf('%s [%s, %s]',
déplacement depuis dépôt con...
Sébastien MARQUE authored on 2021-05-28
326
                                                                   aircrafts.name,
327
                                                                   hangars.name,
328
                                                                   date(aircrafts.date, 'unixepoch'))
329
                                                     from aircrafts
330
                                                     inner join setxml, hangars
331
                                                     where
332
                                                       aircrafts.hangar = hangars.id
333
                                                     and
334
                                                       setxml.variantof = aircrafts.id
335
                                                     and (
336
                                                         setxml.file like '%$2%'
337
                                                       or
338
                                                         aircrafts.name like '%$2%'
339
                                                     )
improve aircraft selection f...
Sébastien MARQUE authored on 2022-01-16
340
                                                     order by aircrafts.date desc"))
341
                    if test ${#ac_list[@]} -gt 1; then
342
                        local PS3='which aircraft ? '
343
                        select ac in ${ac_list[@]}; do
344
                            test -z "$ac" && continue
345
                            break
346
                        done
347
                    elif test ${#ac_list[@]} -eq 1; then
348
                        ac=${ac_list[1]}
349
                    else
350
                        return
351
                    fi
352
                    local url=$(sqlite3 $FGADDON/fgaddon.db <<< "select printf('%s/${${(@s/ /)ac}[1]}', url)
353
                                                                 from hangars where name = '${${(@s/ /)ac}[2]:1:-1}'")
354
                    if test ${${(@s/ /)ac}[2]:1:-1} = 'FGMEMBERS'; then
355
                        url="https://raw.githubusercontent.com/FGMEMBERS/${${(@s/ /)ac}[1]}/master"
356
                    fi
357
                    if wget --quiet --spider "$url/thumbnail.jpg"; then
358
                        curl -s "$url/thumbnail.jpg" \
359
                        | convert - -resize '200%' -normalize -sharpen '0.0x1.0' - \
360
                        | display
361
                    else
362
                        echo "can't find or get thumbnail for ${${(@s/ /)ac}[1]} (${${(@s/ /)ac}[2]:1:-1}'s hangar)"
363
                    fi
déplacement depuis dépôt con...
Sébastien MARQUE authored on 2021-05-28
364
                    return
365
                    ;;
366
                --search)
367
                    command -v sqlite3 > /dev/null || return
368
                    sqlite3 $FGADDON/fgaddon.db <<< "select printf('[%s, %s] %s (%s): %s ',
369
                                                                   hangars.name,
370
                                                                   date(aircrafts.date, 'unixepoch'),
371
                                                                   setxml.file,
372
                                                                   setxml.\`/sim/flight-model\`,
373
                                                                   setxml.\`/sim/description\`)
374
                                                     from setxml
375
                                                     inner join aircrafts, hangars
376
                                                     where
377
                                                       aircrafts.hangar = hangars.id
378
                                                     and
379
                                                       setxml.variantof = aircrafts.id
380
                                                     and (
381
                                                         setxml.file like '%$2%'
382
                                                       or
383
                                                         aircrafts.name like '%$2%'
384
                                                     )
385
                                                     order by aircrafts.date desc"
386
                    return
387
                    ;;
388
                --mp-list)
389
                    local mplist=$(mktemp --dry-run /dev/shm/XXXXXXXXX)
390
                    declare -A installed_model fgaddon_model unknown_model
391
                    local ac_name=
392
                    telnet mpserver01.flightgear.org 5001 2>/dev/null > $mplist
393
                    grep 'pilot(s) online' $mplist
394
                    echo
395
                    local IFS=$'\n'
396
                    for model in $(awk '/@/{a[$NF]++}END{for (i in a) printf("%s (%i)\n", i, a[i])}' $mplist); do
397
                        if test -r $FGADDON/${model% *} \
398
                             -o -r $FGDIR/source/fgdata/${model% *}; then
399

            
400
                            ((++installed_model[${${(s:/:)model}[2]} ${model#* }]))
401

            
402
                        elif test -r $FGDIR/source/fgdata/AI/${model% *}; then
403

            
404
                            ((++installed_model[*${${(s:/:)model}[2]} ${model#* }]))
405

            
406
                        elif test -n "$(command -v sqlite3)" -a -r $FGADDON/fgaddon.db; then
407
                            ac_name=$(sqlite3 $FGADDON/fgaddon.db <<< 'select     printf("%s/%s", aircrafts.name, setxml.file)
408
                                                                       from       aircrafts
409
                                                                       inner join setxml
410
                                                                       where      aircrafts.id = setxml.variantof
411
                                                                       and        setxml.`/sim/model/path` = "'${model% *}'"
412
                                                                       limit      1')
413
                            if test -n "$ac_name"; then
414
                                ((++fgaddon_model[${ac_name} ${model#* }]))
415
                            else
416
                                ((++unknown_model[${model}]))
417
                            fi
418

            
419
                        else
420
                            ((++unknown_model[${model}]))
421
                        fi
422
                    done
423
                    if test ${#installed_model[@]} -gt 0; then
424
                        echo "${(j:\n:)${(Ok)installed_model[@]}}" > $mplist
425
                        echo -e "${#installed_model[@]} models installed (*AI model only):\n$(column -c$(tput cols) $mplist)\n"
426
                    fi
427
                    if test ${#fgaddon_model[@]} -gt 0; then
428
                        echo "${(j:\n:)${(Ok)fgaddon_model[@]}}" > $mplist
429
                        echo -e "${#fgaddon_model[@]} models available in FGADDON:\n$(column -c$(tput cols) $mplist)\n"
430
                    fi
431
                    if test ${#unknown_model[@]} -gt 0; then
432
                        echo "${(j:\n:)${(Ok)unknown_model[@]}}" > $mplist
433
                        echo -e "${#unknown_model[@]} unknown models:\n$(column -c$(tput cols) $mplist)"
434
                    fi
435
                    unset installed_model unknown_model fgaddon_model
436
                    rm $mplist
437
                    return
438
                    ;;
439
                --install)
440
                    local PS3='which aircraft ? '
441
                    local IFS=$'\n'
442
                    select ac in $(sqlite3 $FGADDON/fgaddon.db <<< "select distinct printf('%s [%s, %s]',
443
                                                                   aircrafts.name,
444
                                                                   hangars.name,
445
                                                                   date(aircrafts.date, 'unixepoch'))
446
                                                     from aircrafts
447
                                                     inner join setxml, hangars
448
                                                     where
449
                                                       aircrafts.hangar = hangars.id
450
                                                     and
451
                                                       setxml.variantof = aircrafts.id
452
                                                     and (
453
                                                         setxml.file like '%$2%'
454
                                                       or
455
                                                         aircrafts.name like '%$2%'
456
                                                     )
457
                                                     order by aircrafts.date desc"); do
458
                        test -z "$ac" && continue
459
                    done
460
                    test -z "$ac" && return
461
                    declare -A hangar
462
                    eval $(sqlite3 $FGADDON/fgaddon.db <<< "select printf('hangar[type]=%s;hangar[url]=%s;', type, url)
463
                                                            from hangars where name = '${${(@s/ /)ac}[2]:1:-1}'")
464
                    case ${hangar[type]} in
465
                        git)
466
                            git -C $FGADDON/Aircraft clone ${hangar[url]}/${${(@s/ /)ac}[1]}.git;;
467
                        svn)
468
                            svn checkout ${hangar[url]}/${${(@s/ /)ac}[1]} $FGADDON/Aircraft/${${(@s/ /)ac}[1]};;
469
                    esac
470
                    unset hangar
471
                    return
472
                    ;;
473
                --fgcom)
474
                    if test \
475
                        -r $FGADDON/Addons/fgcom-mumble/FGData/Protocol/fgcom-mumble.xml \
476
                     -a -r $HOME/.local/share/Mumble/Mumble/Plugins/fgcom-mumble.so \
477
                     -a -h $fgfs_install/mumble/lib/libPocoZip.so \
478
                     -a -x $fgfs_install/mumble/bin/mumble; then
479
                        nohup sh -c "LD_LIBRARY_PATH=$fgfs_install/mumble/lib $fgfs_install/mumble/bin/mumble" > /dev/null 2>&1 &
480
                        fgfs_args+=("--addon=$FGADDON/Addons/fgcom-mumble")
481
                        fgfs_args+=("--generic=socket,out,10,localhost,16661,udp,fgcom-mumble")
482
                    else
483
                        echo "can't find protocol definition, or fgcom-mumble plugin"
484
                        return 1
485
                    fi
486
                    ;;
487
                --map|--lnm)
remplacement de littlefgconn...
Sébastien MARQUE authored on 2022-01-16
488
                    if ! pgrep -u $USER -fx "python3 ./fgconnect.py" > /dev/null; then
489
                        if test -d $FGADDON/Addons/littlenavmap -a -x $fgfs_source/fgconnect/fgconnect.py; then
490
                            nohup sh -c "cd $fgfs_source/fgconnect; python3 ./fgconnect.py" > /dev/null 2>&1 &
déplacement depuis dépôt con...
Sébastien MARQUE authored on 2021-05-28
491
                        else
remplacement de littlefgconn...
Sébastien MARQUE authored on 2022-01-16
492
                            echo "can't find FGconnect or littlenavmap addon"
déplacement depuis dépôt con...
Sébastien MARQUE authored on 2021-05-28
493
                            return 1
494
                        fi
495
                    else
remplacement de littlefgconn...
Sébastien MARQUE authored on 2022-01-16
496
                        echo "FGconnect already lauched"
déplacement depuis dépôt con...
Sébastien MARQUE authored on 2021-05-28
497
                    fi
498
                    fgfs_args+=("--addon=$FGADDON/Addons/littlenavmap")
499
                    ;;
500
                --addon=*)
501
                    addon_path="${fgfs_arg#*=}"
502
                    if test -d "$addon_path"; then
503
                        fgfs_args+=("--addon=$addon_path")
504
                    elif test -d "$FGADDON/Addons/$addon_path"; then
505
                        fgfs_args+=("--addon=$FGADDON/Addons/$addon_path")
506
                    else
507
                        echo "can't find requested addon in $addon_path or $FGADDON/$addon_path !"
508
                    fi
509
                    ;;
510
                *)
améliore la vérification des...
Sébastien MARQUE authored on 2021-11-12
511
                    completion_source="$FGDIR/install/flightgear/share/zsh/site-functions/_fgfs"
512
                    if test -r "$completion_source"; then
513
                        if egrep --quiet "^\s*'${fgfs_arg%=*}=?\[" "$completion_source"; then
514
                            fgfs_args+=($fgfs_arg)
515
                        else
516
                            echo unknown option: ${fgfs_arg%=*}
517
                            return 1
518
                        fi
519
                    else
520
                        fgfs_args+=($fgfs_arg)
521
                    fi
522
                    ;;
déplacement depuis dépôt con...
Sébastien MARQUE authored on 2021-05-28
523
            esac
524
        fi
525
    done
526
    unset fgfs_arg
527
    if [[ -n "$log_requested" && -z "${fgfs_args[(r)--igc=*]}" ]]; then
528
        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))
529
    fi
530

            
531
    ld_library_path
532

            
533
    fgfsrc=$HOME/.fgfs/fgfsrc
534
    echo ${fgfs_args[@]//$HOME/\$HOME} $(test -r $fgfsrc && egrep -v '^\s*(#|$)' $fgfsrc | tr '\n' ' ')
535
# TODO: ne lancer avec primusrun que si c'est nécesaire, d'autres solution existent ?
536
    primusrun $FGDIR/install/flightgear/bin/fgfs ${fgfs_args[@]}
537
    
538
    if grep -q $HOME/.fgfs/terrafs.d /proc/mounts; then
539
        fusermount -u $HOME/.fgfs/terrafs.d
540
    fi
541
    unset fgfs_args
542
}