scripts / flightgear / fgfs_function /
Newer Older
552 lines | 29.971kb
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 () {
fixe problème avec bibliothè...
Sébastien MARQUE authored on 2022-03-02
92
        for component in $(<$fgfs_source/.flightgear); do
93
            if test -d $fgfs_install/$component/lib; then
94
                lib="$fgfs_install/$component/lib"
95
                egrep -q "(^|:)$lib(:|$)" <<< "${LD_LIBRARY_PATH}" || LD_LIBRARY_PATH="${lib}${LD_LIBRARY_PATH:+:}${LD_LIBRARY_PATH}"
96
            fi
déplacement depuis dépôt con...
Sébastien MARQUE authored on 2021-05-28
97
        done
98
        export LD_LIBRARY_PATH
99
    }
100
    local aircrafts="$FGADDON/Aircraft"
101
    local fgfs_args=("--fg-root=$FGDIR/source/fgdata")
102
    local aircraft=
103
    local airport=
104
    if [[ -o BASH_REMATCH ]]; then
105
        local bash_rematch_set=1
106
    fi
107

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            
541
    ld_library_path
542

            
543
    fgfsrc=$HOME/.fgfs/fgfsrc
544
    echo ${fgfs_args[@]//$HOME/\$HOME} $(test -r $fgfsrc && egrep -v '^\s*(#|$)' $fgfsrc | tr '\n' ' ')
545
# TODO: ne lancer avec primusrun que si c'est nécesaire, d'autres solution existent ?
546
    primusrun $FGDIR/install/flightgear/bin/fgfs ${fgfs_args[@]}
547
    
548
    if grep -q $HOME/.fgfs/terrafs.d /proc/mounts; then
549
        fusermount -u $HOME/.fgfs/terrafs.d
550
    fi
551
    unset fgfs_args
552
}