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