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