config / .fgfs / fgfs_function /
Newer Older
446 lines | 24.218kb
ajout fonction pour lancemen...
Sébastien MARQUE authored on 2020-04-16
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
ajout de gestion de bdd pour...
Sébastien MARQUE authored on 2020-08-24
11
            fgaddon)
12
                DB=$FGADDON/fgaddon.db $HOME/.fgfs/fgaddon
code rearrangement
Sébastien MARQUE authored on 2020-09-27
13
                ;;
14
            check)
15
                test -r $HOME/.fgfs/jenkins-status && bash $HOME/.fgfs/jenkins-status
16
                ;;
add RSS reader for FG code
Sébastien MARQUE authored on 2020-10-19
17
            rss)
18
                test -r $HOME/.fgfs/fgcoderss && bash $HOME/.fgfs/fgcoderss
19
                ;;
ajout fonction pour lancemen...
Sébastien MARQUE authored on 2020-04-16
20
            data)
ajout de gestion de bdd pour...
Sébastien MARQUE authored on 2020-08-24
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
ajout fonction pour lancemen...
Sébastien MARQUE authored on 2020-04-16
30
                ;;
31
            source)
code rearrangement
Sébastien MARQUE authored on 2020-09-27
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
ajout fonction pour lancemen...
Sébastien MARQUE authored on 2020-04-16
41
                done
42
                ;;
43
            build)
44
                local simultaneous=$(nproc)
45
                local previously_installed=()
46
                mkdir -p $fgfs_install
make possible to compile dif...
Sébastien MARQUE authored on 2020-09-23
47
                for component in $(<$fgfs_source/.$2); do
code rearrangement
Sébastien MARQUE authored on 2020-09-27
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
ajout fonction pour lancemen...
Sébastien MARQUE authored on 2020-04-16
53

            
code rearrangement
Sébastien MARQUE authored on 2020-09-27
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")
ajout fonction pour lancemen...
Sébastien MARQUE authored on 2020-04-16
63

            
some cosmetics
Sébastien MARQUE authored on 2020-11-07
64
                        title="*** ${component:u}${branch:+ [$branch]} ***"
65
                        printf "\n%s\n%s\n%s\n" "${(l:${#title}::*:)}" "$title" "${(l:${#title}::*:)}"
code rearrangement
Sébastien MARQUE authored on 2020-09-27
66
                        mkdir -p $fgfs_build/$component
67
                        cd $fgfs_build/$component
ajout fonction pour lancemen...
Sébastien MARQUE authored on 2020-04-16
68

            
code rearrangement
Sébastien MARQUE authored on 2020-09-27
69
                        echo cmake ${cmake_options[@]} $fgfs_source/$component
70

            
71
                        cmake ${cmake_options[@]} $fgfs_source/$component > /dev/null \
72
                        && make -j$simultaneous > /dev/null \
filter installation log
Sébastien MARQUE authored on 2020-12-05
73
                        && {
74
                            make install | grep --color=always -v '^-- Up-to-date:'
75
                        } \
code rearrangement
Sébastien MARQUE authored on 2020-09-27
76
                        || {
77
                            echo "erreur construction $component"
78
                            cd $FGDIR
79
                            return
80
                        }
fix return to path
Sébastien MARQUE authored on 2020-11-07
81

            
82
                        cd - > /dev/null
code rearrangement
Sébastien MARQUE authored on 2020-09-27
83
                    fi
ajout fonction pour lancemen...
Sébastien MARQUE authored on 2020-04-16
84

            
85
                    previously_installed+=($component)
86
                done
87
                unset component
88
                ;;
89
        esac
90
    }
91
    function ld_library_path () {
smarter use of IFS
Sébastien MARQUE authored on 2020-09-23
92
        local IFS=$'\n'
fix multiple instances on LD...
Sébastien MARQUE authored on 2020-07-01
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
ajout fonction pour lancemen...
Sébastien MARQUE authored on 2020-04-16
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

            
small fix
Sébastien MARQUE authored on 2020-11-14
119
############ APPAREIL DISPONIBLE DANS UN HANGAR CONNU ?
ajout de gestion de bdd pour...
Sébastien MARQUE authored on 2020-08-24
120
            elif which sqlite3 > /dev/null 2>&1 \
121
            && test -r $FGADDON/fgaddon.db \
allow installation of aircra...
Sébastien MARQUE authored on 2020-11-13
122
            && test $(sqlite3 $FGADDON/fgaddon.db <<< "select count(file) from setxml where file is '${fgfs_arg}'") -gt 0; then
123
                local PS3='which aircraft ? (Ctrl-D to quit) '
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)
small fix
Sébastien MARQUE authored on 2020-11-14
146
                                git -C $FGADDON/Aircraft clone ${hangar[url]}/${${(@s/ /)ac}[1]}.git;;
allow installation of aircra...
Sébastien MARQUE authored on 2020-11-13
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
ajout de gestion de bdd pour...
Sébastien MARQUE authored on 2020-08-24
158

            
ajout fonction pour lancemen...
Sébastien MARQUE authored on 2020-04-16
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")
fix some fgfs options
Sébastien MARQUE authored on 2020-06-21
162
                fgfs_args+=("--callsign=f-zakh")
ajout fonction pour lancemen...
Sébastien MARQUE authored on 2020-04-16
163
                test -z "$bash_rematch_set" && set +o BASH_REMATCH
164

            
ajout trace de vol
Sébastien MARQUE authored on 2020-04-18
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

            
ajout fonction pour lancemen...
Sébastien MARQUE authored on 2020-04-16
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 [[ -a "${airport_data}.threshold.xml" ]]; then
191
                    fgfs_args+=(--airport=$candidate_airport)
192
                    if [[ -a "${airport_data}.groundnet.xml" && -n "$candidate_parking" ]]; then
193
                        if test $candidate_parking = '?'; then
194
                          echo "Parkings ${candidate_airport:u}:"
195
                          sed -rn "/<parkingList/,/parkingList>/s/^.* name=\"([^\"]+).*$/\1/p" ${airport_data}.groundnet.xml
196
                          return
197
                        elif sed -rn "/<parkingList/,/parkingList>/p" ${airport_data}.groundnet.xml | grep -q "name=\"${candidate_parking}\""; then
fix some fgfs options
Sébastien MARQUE authored on 2020-06-21
198
                            fgfs_args+=("--parkpos='$candidate_parking'")
ajout fonction pour lancemen...
Sébastien MARQUE authored on 2020-04-16
199
                        fi
200
                    elif test -n "$candidate_runway"; then
201
                        if test $candidate_runway = '?'; then
202
                            echo "Runways ${candidate_airport:u}:"
203
                            sed -rn 's|^.*<rwy>(.+)</rwy>.*$|\1|p' ${airport_data}.threshold.xml
204
                            return
205
                        elif grep -q "<rwy>${candidate_runway}</rwy>" ${airport_data}.threshold.xml; then
206
                            fgfs_args+=("--runway=$candidate_runway")
207
                        fi
208
                    fi
209
                fi
210
            fi
211

            
212
######## AUTRE OPTION
213
        else
214
            case $fgfs_arg in
code rearrangement
Sébastien MARQUE authored on 2020-09-27
215
                --update(-data|-source|-build|))
216
                    if test -z "$2" || test ! -r $fgfs_source/.$2; then
217
                        echo "${2:+unknown set $2\n}usage: --update|--update-data|--update-source|--update-build <set>"
218
                        echo "available sets :" ${$(find $fgfs_source -maxdepth 1 -type f -name ".*" -printf "%f ")//#.}
219
                        return 1
220
                    fi
221
                    for component in $(<$fgfs_source/.$2); do
222
                        if ! test -d $fgfs_source/$component; then
223
                            echo component $component not found
224
                            return 1
225
                        fi
226
                    done
227
                    typeset -A control_system_data=(
228
                        git pull
229
                        svn up
230
                    )
ajout fonction pour lancemen...
Sébastien MARQUE authored on 2020-04-16
231
                    for up in ${${=${fgfs_arg#--update}:-data source build}#-}; do
make possible to compile dif...
Sébastien MARQUE authored on 2020-09-23
232
                        update_fg $up ${2:-flightgear}
ajout fonction pour lancemen...
Sébastien MARQUE authored on 2020-04-16
233
                    done
code rearrangement
Sébastien MARQUE authored on 2020-09-27
234
                    unset control_system_data control_system update_command up
235
                    return
236
                    ;;
add RSS reader for FG code
Sébastien MARQUE authored on 2020-10-19
237
                --update-(fgaddon|check|rss))
code rearrangement
Sébastien MARQUE authored on 2020-09-27
238
                    update_fg ${fgfs_arg#--update-}
ajout fonction pour lancemen...
Sébastien MARQUE authored on 2020-04-16
239
                    return
240
                    ;;
241
                --(show-aircraft|help))
ajout trace de vol
Sébastien MARQUE authored on 2020-04-18
242
                    local -A complement=(
ajout fonction pour lancemen...
Sébastien MARQUE authored on 2020-04-16
243
                        --show-aircraft --fg-aircraft=$FGADDON/Aircraft
244
                        --help          --verbose
245
                    )
fix multiple instances on LD...
Sébastien MARQUE authored on 2020-07-01
246
                    ld_library_path
ajout fonction pour lancemen...
Sébastien MARQUE authored on 2020-04-16
247
                    $FGDIR/install/flightgear/bin/fgfs $fgfs_arg ${complement[$fgfs_arg]} 2>/dev/null | pager
248
                    return
249
                    ;;
add --show-thumbnail
Sébastien MARQUE authored on 2020-11-07
250
                --show-thumbnail)
251
                    local PS3='which aircraft ? (Ctrl-D to quit) '
252
                    local IFS=$'\n'
253
                    select ac in $(sqlite3 $FGADDON/fgaddon.db <<< "select distinct printf('%s [%s, %s]',
254
                                                                   aircrafts.name,
255
                                                                   hangars.name,
256
                                                                   date(aircrafts.date, 'unixepoch'))
257
                                                     from aircrafts
258
                                                     inner join setxml, hangars
259
                                                     where
260
                                                       aircrafts.hangar = hangars.id
261
                                                     and
262
                                                       setxml.variantof = aircrafts.id
263
                                                     and (
264
                                                         setxml.file like '%$2%'
265
                                                       or
266
                                                         aircrafts.name like '%$2%'
267
                                                     )
268
                                                     order by aircrafts.date desc"); do
269
                        test -z "$ac" && continue
270
                        local url=$(sqlite3 $FGADDON/fgaddon.db <<< "select printf('%s/${${(@s/ /)ac}[1]}', url)
271
                                                                     from hangars where name = '${${(@s/ /)ac}[2]:1:-1}'")
272
                        if test ${${(@s/ /)ac}[2]:1:-1} = 'FGMEMBERS'; then
273
                            url="https://raw.githubusercontent.com/FGMEMBERS/${${(@s/ /)ac}[1]}/master"
274
                        fi
275
                        if wget --quiet --spider "$url/thumbnail.jpg"; then
276
                            curl -s "$url/thumbnail.jpg" \
277
                            | convert - -resize '200%' -normalize -sharpen '0.0x1.0' - \
278
                            | display
279
                        else
280
                            echo "can't find or get thumbnail for ${${(@s/ /)ac}[1]} (${${(@s/ /)ac}[2]:1:-1}'s hangar)"
281
                        fi
282
                    done
283
                    return
284
                    ;;
add --search and --mp-list o...
Sébastien MARQUE authored on 2020-09-27
285
                --search)
286
                    command -v sqlite3 > /dev/null || return
some cosmetics
Sébastien MARQUE authored on 2020-11-07
287
                    sqlite3 $FGADDON/fgaddon.db <<< "select printf('[%s, %s] %s (%s): %s ',
288
                                                                   hangars.name,
289
                                                                   date(aircrafts.date, 'unixepoch'),
290
                                                                   setxml.file,
291
                                                                   setxml.\`/sim/flight-model\`,
292
                                                                   setxml.\`/sim/description\`)
293
                                                     from setxml
294
                                                     inner join aircrafts, hangars
295
                                                     where
296
                                                       aircrafts.hangar = hangars.id
297
                                                     and
298
                                                       setxml.variantof = aircrafts.id
299
                                                     and (
300
                                                         setxml.file like '%$2%'
301
                                                       or
302
                                                         aircrafts.name like '%$2%'
303
                                                     )
304
                                                     order by aircrafts.date desc"
add --search and --mp-list o...
Sébastien MARQUE authored on 2020-09-27
305
                    return
306
                    ;;
307
                --mp-list)
308
                    local mplist=$(mktemp --dry-run /dev/shm/XXXXXXXXX)
309
                    declare -A installed_model fgaddon_model unknown_model
310
                    local ac_name=
311
                    telnet mpserver01.flightgear.org 5001 2>/dev/null > $mplist
print number of online pilot...
Sébastien MARQUE authored on 2020-09-28
312
                    grep 'pilot(s) online' $mplist
313
                    echo
show connected pilots for ea...
Sébastien MARQUE authored on 2020-10-25
314
                    local IFS=$'\n'
315
                    for model in $(awk '/@/{a[$NF]++}END{for (i in a) printf("%s (%i)\n", i, a[i])}' $mplist); do
316
                        if test -r $FGADDON/${model% *} \
317
                             -o -r $FGDIR/source/fgdata/${model% *}; then
318

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

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

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

            
separation AI/real models, a...
Sébastien MARQUE authored on 2020-09-28
325
                        elif test -n "$(command -v sqlite3)" -a -r $FGADDON/fgaddon.db; then
add --search and --mp-list o...
Sébastien MARQUE authored on 2020-09-27
326
                            ac_name=$(sqlite3 $FGADDON/fgaddon.db <<< 'select     printf("%s/%s", aircrafts.name, setxml.file)
327
                                                                       from       aircrafts
328
                                                                       inner join setxml
329
                                                                       where      aircrafts.id = setxml.variantof
show connected pilots for ea...
Sébastien MARQUE authored on 2020-10-25
330
                                                                       and        setxml.`/sim/model/path` = "'${model% *}'"
add --search and --mp-list o...
Sébastien MARQUE authored on 2020-09-27
331
                                                                       limit      1')
332
                            if test -n "$ac_name"; then
show connected pilots for ea...
Sébastien MARQUE authored on 2020-10-25
333
                                ((++fgaddon_model[${ac_name} ${model#* }]))
add --search and --mp-list o...
Sébastien MARQUE authored on 2020-09-27
334
                            else
show connected pilots for ea...
Sébastien MARQUE authored on 2020-10-25
335
                                ((++unknown_model[${model}]))
add --search and --mp-list o...
Sébastien MARQUE authored on 2020-09-27
336
                            fi
show connected pilots for ea...
Sébastien MARQUE authored on 2020-10-25
337

            
separation AI/real models, a...
Sébastien MARQUE authored on 2020-09-28
338
                        else
show connected pilots for ea...
Sébastien MARQUE authored on 2020-10-25
339
                            ((++unknown_model[${model}]))
add --search and --mp-list o...
Sébastien MARQUE authored on 2020-09-27
340
                        fi
341
                    done
342
                    if test ${#installed_model[@]} -gt 0; then
improve output
Sébastien MARQUE authored on 2020-09-27
343
                        echo "${(j:\n:)${(Ok)installed_model[@]}}" > $mplist
improve mplist output
Sébastien MARQUE authored on 2020-10-19
344
                        echo -e "${#installed_model[@]} models installed (*AI model only):\n$(column -c$(tput cols) $mplist)\n"
add --search and --mp-list o...
Sébastien MARQUE authored on 2020-09-27
345
                    fi
346
                    if test ${#fgaddon_model[@]} -gt 0; then
improve output
Sébastien MARQUE authored on 2020-09-27
347
                        echo "${(j:\n:)${(Ok)fgaddon_model[@]}}" > $mplist
improve mplist output
Sébastien MARQUE authored on 2020-10-19
348
                        echo -e "${#fgaddon_model[@]} models available in FGADDON:\n$(column -c$(tput cols) $mplist)\n"
add --search and --mp-list o...
Sébastien MARQUE authored on 2020-09-27
349
                    fi
350
                    if test ${#unknown_model[@]} -gt 0; then
improve output
Sébastien MARQUE authored on 2020-09-27
351
                        echo "${(j:\n:)${(Ok)unknown_model[@]}}" > $mplist
improve mplist output
Sébastien MARQUE authored on 2020-10-19
352
                        echo -e "${#unknown_model[@]} unknown models:\n$(column -c$(tput cols) $mplist)"
add --search and --mp-list o...
Sébastien MARQUE authored on 2020-09-27
353
                    fi
354
                    unset installed_model unknown_model fgaddon_model
355
                    rm $mplist
356
                    return
357
                    ;;
add --install option
Sébastien MARQUE authored on 2020-11-23
358
                --install)
359
                    local PS3='which aircraft ? (Ctrl-D to quit) '
360
                    local IFS=$'\n'
361
                    select ac in $(sqlite3 $FGADDON/fgaddon.db <<< "select distinct printf('%s [%s, %s]',
362
                                                                   aircrafts.name,
363
                                                                   hangars.name,
364
                                                                   date(aircrafts.date, 'unixepoch'))
365
                                                     from aircrafts
366
                                                     inner join setxml, hangars
367
                                                     where
368
                                                       aircrafts.hangar = hangars.id
369
                                                     and
370
                                                       setxml.variantof = aircrafts.id
371
                                                     and (
372
                                                         setxml.file like '%$2%'
373
                                                       or
374
                                                         aircrafts.name like '%$2%'
375
                                                     )
376
                                                     order by aircrafts.date desc"); do
377
                        test -z "$ac" && continue
378
                    done
379
                    test -z "$ac" && return
380
                    declare -A hangar
381
                    eval $(sqlite3 $FGADDON/fgaddon.db <<< "select printf('hangar[type]=%s;hangar[url]=%s;', type, url)
382
                                                            from hangars where name = '${${(@s/ /)ac}[2]:1:-1}'")
383
                    case ${hangar[type]} in
384
                        git)
385
                            git -C $FGADDON/Aircraft clone ${hangar[url]}/${${(@s/ /)ac}[1]}.git;;
386
                        svn)
387
                            svn checkout ${hangar[url]}/${${(@s/ /)ac}[1]} $FGADDON/Aircraft/${${(@s/ /)ac}[1]};;
388
                    esac
389
                    unset hangar
390
                    return
391
                    ;;
add --fgcom option to launch...
Sébastien MARQUE authored on 2020-11-22
392
                --fgcom)
393
                    if test \
use fgcom-mumble addon direc...
Sébastien MARQUE authored on 2021-02-13
394
                        -r $FGADDON/Addons/fgcom-mumble/FGData/Protocol/fgcom-mumble.xml \
add --fgcom option to launch...
Sébastien MARQUE authored on 2020-11-22
395
                     -a -r $HOME/.local/share/Mumble/Mumble/Plugins/fgcom-mumble.so \
396
                     -a -h $fgfs_install/mumble/lib/libPocoZip.so \
397
                     -a -x $fgfs_install/mumble/bin/mumble; then
398
                        nohup sh -c "LD_LIBRARY_PATH=$fgfs_install/mumble/lib $fgfs_install/mumble/bin/mumble" > /dev/null 2>&1 &
use fgcom-mumble addon direc...
Sébastien MARQUE authored on 2021-02-13
399
                        fgfs_args+=("--addon=$FGADDON/Addons/fgcom-mumble")
add --fgcom option to launch...
Sébastien MARQUE authored on 2020-11-22
400
                        fgfs_args+=("--generic=socket,out,10,localhost,16661,udp,fgcom-mumble")
401
                    else
402
                        echo "can't find protocol definition, or fgcom-mumble plugin"
403
                        return 1
404
                    fi
add Little Navmap connector
Sébastien MARQUE authored on 2021-01-29
405
                    ;;
406
                --map|--lnm)
407
                    if test \
408
                        -x $fgfs_install/littlefgconnect/"Little FGconnect"/littlefgconnect \
409
                     -a -r $FGADDON/Addons/littlenavmap/FGData/Protocol/littlenavmap.xml; then
410
                            nohup sh -c "$fgfs_install/littlefgconnect/Little\ FGconnect/littlefgconnect" > /dev/null 2>&1 &
411
                            fgfs_args+=("--addon=$FGADDON/Addons/littlenavmap")
412
                    else
413
                        echo "can't find Little FGconnect"
414
                        return 1
415
                    fi
add --fgcom option to launch...
Sébastien MARQUE authored on 2020-11-22
416
                    ;;
ajout fonction pour lancemen...
Sébastien MARQUE authored on 2020-04-16
417
                *)
418
                    fgfs_args+=($fgfs_arg);;
419
            esac
420
        fi
421
    done
422
    unset fgfs_arg
ajout trace de vol
Sébastien MARQUE authored on 2020-04-18
423
    if [[ -n "$log_requested" && -z "${fgfs_args[(r)--igc=*]}" ]]; then
ajout trace de vol (2)
Sébastien MARQUE authored on 2020-04-18
424
        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))
ajout trace de vol
Sébastien MARQUE authored on 2020-04-18
425
    fi
426

            
fix multiple instances on LD...
Sébastien MARQUE authored on 2020-07-01
427
    ld_library_path
ajout fonction pour lancemen...
Sébastien MARQUE authored on 2020-04-16
428

            
workaround for bumblebee iss...
Sébastien MARQUE authored on 2020-12-06
429
    (
430
        nmcli radio all off
431
        while test $(lsmod | grep -c nvidia) -eq 0; do
432
            sleep 1
433
        done
434
        nmcli radio wifi on
435
    )&
436

            
improve options output
Sébastien MARQUE authored on 2020-11-07
437
    fgfsrc=$HOME/.fgfs/fgfsrc
438
    echo ${fgfs_args[@]//$HOME/\$HOME} $(test -r $fgfsrc && egrep -v '^\s*(#|$)' $fgfsrc | tr '\n' ' ')
ajout fonction pour lancemen...
Sébastien MARQUE authored on 2020-04-16
439
# TODO: ne lancer avec primusrun que si c'est nécesaire, d'autres solution existent ?
440
    primusrun $FGDIR/install/flightgear/bin/fgfs ${fgfs_args[@]}
441
    
442
    if grep -q $HOME/.fgfs/terrafs.d /proc/mounts; then
443
        fusermount -u $HOME/.fgfs/terrafs.d
444
    fi
445
    unset fgfs_args
446
}