#!/bin/zsh #FGDIR=$HOME/scripts/flightgear #FGADDON=$HOME/.fgfs/flightgear-fgaddon function fgfs () { local fgfs_source=$FGDIR/source local fgfs_build=$FGDIR/build local fgfs_install=$FGDIR/install function update_fg () { case $1 in fgaddon) test -r $HOME/.fgfs/fgaddon && DB="$FGADDON/fgaddon.db" bash $HOME/.fgfs/fgaddon ;; check) test -r $HOME/.fgfs/jenkins-status && bash $HOME/.fgfs/jenkins-status ;; rss) test -r $HOME/.fgfs/fgcoderss && bash $HOME/.fgfs/fgcoderss ;; data) for control_system update_command in ${(kv)control_system_data}; do find $FGADDON \ -maxdepth 3 \ -mindepth 1 \ -type d \ -name .${control_system} \ -printf "\n[ %h ]\n" \ -execdir ${control_system} ${update_command} \; done ;; source) for component in $(<$fgfs_source/.$2); do for control_system update_command in ${(kv)control_system_data}; do find $fgfs_source/$component \ -maxdepth 1 \ -type d \ -name .${control_system} \ -printf "\n[ %h ]\n" \ -execdir ${control_system} ${update_command} \; done done ;; build) local simultaneous=$(nproc) local previously_installed=() mkdir -p $fgfs_install for component in $(<$fgfs_source/.$2); do if test -d $fgfs_source/$component/.git; then local branch=$(git -C $fgfs_source/$component name-rev --name-only --no-undefined --always HEAD) elif test -d $fgfs_source/${component}/.svn; then local branch=${${(s:/:)$(svn info --show-item relative-url $fgfs_source/$component)}[2]} fi # TODO: prendre en compte les cas sans cmake if test -r $fgfs_source/$component/CMakeLists.txt; then local cmake_options=("-DCMAKE_BUILD_TYPE=Release" "-DCMAKE_INSTALL_PREFIX=$fgfs_install/$component") test -e $fgfs_source/${component}.specific && source $fgfs_source/${component}.specific if test ${#previously_installed[@]} -gt 0; then cmake_options+=(${(j. .)${:--DCMAKE_PREFIX_PATH=$fgfs_install/${^previously_installed}}}) cmake_options+=(${(j. .)${:--DCMAKE_INCLUDE_PATH=$fgfs_install/${^previously_installed}/include}}) fi title="*** ${component:u}${branch:+ [$branch]} ***" printf "\n%s\n%s\n%s\n" "${(l:${#title}::*:)}" "$title" "${(l:${#title}::*:)}" mkdir -p $fgfs_build/$component cd $fgfs_build/$component echo cmake ${cmake_options[@]//$HOME/\$HOME} ${fgfs_source/#$HOME/\$HOME}/$component cmake ${cmake_options[@]} $fgfs_source/$component > /dev/null \ && make -j$simultaneous > /dev/null \ && { make install | sed -r "s,$HOME,\$HOME,; /^-- Up-to-date:/d" } \ || { echo "erreur construction $component" cd $FGDIR return } cd - > /dev/null fi previously_installed+=($component) done unset component ;; esac } function ld_library_path () { for component in $(<$fgfs_source/.flightgear); do if test -d $fgfs_install/$component/lib; then lib="$fgfs_install/$component/lib" egrep -q "(^|:)$lib(:|$)" <<< "${LD_LIBRARY_PATH}" || LD_LIBRARY_PATH="${lib}${LD_LIBRARY_PATH:+:}${LD_LIBRARY_PATH}" fi done export LD_LIBRARY_PATH } function check_fgaddon () { if ! test -r $FGADDON/fgaddon.db; then echo "aircraft DB not found at $FGADDON/fgaddon.db" echo "please run $0 --update-fgaddon" return 1 fi if ! command -v sqlite3 > /dev/null; then which sqlite3 return 1 fi } local aircrafts="$FGADDON/Aircraft" local fgfs_args=("--fg-root=$FGDIR/source/fgdata") local aircraft= local airport= if [[ -o BASH_REMATCH ]]; then local bash_rematch_set=1 fi for fgfs_arg in $@; do if test ${fgfs_arg#--} = ${fgfs_arg}; then ############ APPAREIL DANS FGADDON ? if test -n "$(find $aircrafts -maxdepth 2 -type f -name ${fgfs_arg}-set.xml -print -quit)"; then fgfs_args+=("--aircraft=$fgfs_arg") fgfs_args+=("--fg-aircraft=$FGADDON/Aircraft") ############ APPAREIL DANS FGDIR/source/fgdata ? 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 fgfs_args+=("--aircraft=$fgfs_arg") fgfs_args+=("--aircraft-dir=$official_aircraft") unset official_aircraft ############ APPAREIL DISPONIBLE DANS UN HANGAR CONNU ? elif which sqlite3 > /dev/null 2>&1 \ && test -r $FGADDON/fgaddon.db \ && test $(sqlite3 $FGADDON/fgaddon.db <<< "select count(file) from setxml where file is '${fgfs_arg}'") -gt 0; then local PS3='which aircraft ? ' local IFS=$'\n' select ac in $(sqlite3 $FGADDON/fgaddon.db <<< "select distinct printf('%s [%s, %s]', aircrafts.name, hangars.name, date(aircrafts.date, 'unixepoch')) from aircrafts inner join setxml, hangars where aircrafts.hangar = hangars.id and setxml.variantof = aircrafts.id and setxml.file = '${fgfs_arg}' order by aircrafts.date desc"); do test -z "$ac" && continue read -q "REPLY?download ${${(@s/ /)ac}[1]} ? (y/N) " if test -n "$REPLY" && test ${REPLY:l} = "y"; then declare -A hangar eval $(sqlite3 $FGADDON/fgaddon.db <<< "select printf('hangar[type]=%s;hangar[url]=%s;', type, url) from hangars where name = '${${${(@s/ /)ac}[2]}:1:-1}'") case ${hangar[type]} in git) git -C $FGADDON/Aircraft clone ${hangar[url]}/${${(@s/ /)ac}[1]}.git;; svn) svn checkout ${hangar[url]}/${${(@s/ /)ac}[1]} $FGADDON/Aircraft/${${(@s/ /)ac}[1]};; esac fgfs_args+=("--aircraft=$fgfs_arg") fgfs_args+=("--fg-aircraft=$FGADDON/Aircraft") unset -v hangar else echo "falling back to default" fi break done ############ SERVEUR MULTIPLAY ? elif set -o BASH_REMATCH && [[ $fgfs_arg =~ "^mp([0-9]+)$" ]]; then fgfs_args+=("--multiplay=out,10,mpserver${BASH_REMATCH[2]}.flightgear.org,5000") if test -n "$(ls -rt1 $HOME/.fgfs/autosave_*.xml | tail -1)"; then callsign=$(sed -rn 's/^.*(.+)<.callsign>.*$/\1/p' $(ls -rt1 $HOME/.fgfs/autosave_*.xml | tail -1)) fi if test -n "$callsign"; then fgfs_args+=("--callsign=$callsign") fi test -z "$bash_rematch_set" && set +o BASH_REMATCH ############ DEMANDE DE TRACE DE VOL ? elif [[ $fgfs_arg == "log" ]]; then # option construite plus tard avec nom de l'appareil local log_requested=1 ############ AEROPORT ? else local candidate_airport=${fgfs_arg%:*}; [[ $candidate_airport == $fgfs_arg ]] && candidate_airport=${fgfs_arg%+*} local candidate_parking=${fgfs_arg#*:}; [[ $candidate_parking == $fgfs_arg ]] && unset candidate_parking local candidate_runway=${fgfs_arg#*+}; [[ $candidate_runway == $fgfs_arg ]] && unset candidate_runway if [[ -x $HOME/.fgfs/terrafs && -d $HOME/.fgfs/terrafs.d ]]; then if test $(grep -Ec "^terrafs\s+$HOME/.fgfs/terrafs.d" /proc/mounts) -eq 0 \ && echo "$HOME/.fgfs/terrafs.d present but not mounted !" \ && test -x $HOME/.fgfs/mount.terrafs \ && read -q "mount_terrafs?go to mount it ? (y/N) " \ && [[ "${mount_terrafs:-n}" = "y" ]]; then $HOME/.fgfs/mount.terrafs || return 1 else echo "mount it manually, or remove it to use TerraSync" return 1 fi fgfs_args+=(--fg-scenery=$HOME/.fgfs/terrafs.d) fgfs_args+=(--disable-terrasync) local scenes_dir=$HOME/.fgfs/terrafs.d else fgfs_args+=(--terrasync-dir=$HOME/.fgfs/TerraSync) fgfs_args+=(--enable-terrasync) local scenes_dir=$HOME/.fgfs/TerraSync fi local airport_data="$scenes_dir/Airports/$candidate_airport[1]:u/$candidate_airport[2]:u/$candidate_airport[3]:u/${candidate_airport:u}" if ! test -r "${airport_data}.threshold.xml"; then echo "airport ${candidate_airport:u} not found !" fi if test -n "$candidate_parking" && test "$candidate_parking" = '?'; then if test -r "${airport_data}.groundnet.xml"; then echo "Parkings ${candidate_airport:u}:" sed -rn "//s/^.* name=\"([^\"]+).*$/\1/p" "${airport_data}.groundnet.xml" else echo "no information for parkings available on ${candidate_airport:u}" fi return elif test -n "$candidate_runway" && test "$candidate_runway" = '?'; then if test -r "${airport_data}.threshold.xml"; then echo "Runways ${candidate_airport:u}:" sed -rn 's|^.*(.+).*$|\1|p' "${airport_data}.threshold.xml" else echo "no information for runways available on ${candidate_airport:u}" fi return fi if test -r "${airport_data}.threshold.xml"; then fgfs_args+=(--airport=$candidate_airport) if [[ -a "${airport_data}.groundnet.xml" && -n "$candidate_parking" ]]; then if sed -rn "//p" "${airport_data}.groundnet.xml" | grep -q "name=\"${candidate_parking}\""; then fgfs_args+=("--parkpos='$candidate_parking'") else echo "$candidate_parking isn't a valid parking position" fi elif test -n "$candidate_runway"; then if grep -q "${candidate_runway}" "${airport_data}.threshold.xml"; then fgfs_args+=("--runway=$candidate_runway") else echo "$candidate_runway isn't a valid runway" fi fi fi fi ######## AUTRE OPTION else case $fgfs_arg in --update(-data|-source|-build|)) echo 10 met à jour les data, les sources, ou compile. Prend en option le projet > /dev/null if test ! -r $fgfs_source/.${2:-flightgear}; then echo "${2:+unknown set $2\n}usage: --update|--update-data|--update-source|--update-build " echo "available sets :" ${$(find $fgfs_source -maxdepth 1 -type f -name ".*" -printf "%f ")//#.} return 1 fi for component in $(<$fgfs_source/.${2:-flightgear}); do if ! test -d $fgfs_source/$component; then echo component $component not found return 1 fi done typeset -A control_system_data=( git pull svn up ) for up in ${${=${fgfs_arg#--update}:-data source build}#-}; do update_fg $up ${2:-flightgear} done unset control_system_data control_system update_command up return ;; --update-(fgaddon|check|rss)) echo 11 utilise les scripts externe fgaddon, check ou rss > /dev/null update_fg ${fgfs_arg#--update-} return ;; --help) echo 1 affiche cette aide et quitte > /dev/null ( cat << EOH VARIABLES IMPORTANTES: FGDIR = ${FGDIR:-/!\\ ATTENTION FGDIR VIDE /!\\} FGADDON = ${FGADDON:-/!\\ ATTENTION FGADDON VIDE /!\\} OPTIONS SPÉCIFIQUES AU SCRIPT: les options commençant par "--" sont: $(declare -f $0 \ | sed -rn "s|^\s*\((--.+)\) echo ([0-9]+) \"?(.+)\"? > /dev/null$|\1:\2:\3|p" \ | sed 's/"$//' \ | awk -F':' -v dq='"' ' BEGIN { maxlength = 0 } { order[$1] = strtonum($2) option[$1] = $3 if (length($1) > maxlength) maxlength = length($1) } END { PROCINFO["sorted_in"] = "@val_num_asc" for (o in order) printf("%s%s%*s%s\n", order[o] % 10 == 0 ? "\n" : "", o, maxlength - length(o) + 1, " ", option[o]) }') les options ne commençant pas par "--" peuvent être * log: crée un log au format igc et enregistré dans le fichier au nom comprenant date, heure et nom de l'appareil, avec une fréquence de 1Hz * mp[0-9]+: un serveur de multiplayer sur lequel se connecter, le callsign sera aussi configuré avec celui trouvé dans autosave, par exemple mp01 pour une connexion sur mpserver01.flightgear.org:5000 * 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 * un aéroport: * sans emplacement précisé: lfbd * avec une piste: lfbd+09, si la piste n'est pas trouvée sortie en erreur il est possible de lister les pistes disponible avec lfbt+\\? (notez l'échappement \\ pour éviter une interprétation du caractère \`?' par le shell: $ fgfs ksfo+\\? Runways KSFO: 01L 19R 01R 19L 10L 28R 10R 28L * avec un emplacement de parking: lfbt:parking_1, si le parking n'est pas trouvé un message l'indique et il est ignoré comme avec les pistes il est possible de lister les emplacements disponibles: $ fgfs biis:\\? Parkings BIIS: Gate Ramp_Start_1 Ramp_Start_2 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: $ fgfs ercoupe biis --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 ... OPTIONS SPÉCIFIQUES À FG: $(ld_library_path; $FGDIR/install/flightgear/bin/fgfs $fgfs_arg --verbose 2>/dev/null | sed '1d; /: fgfs \[/,+1d') EOH ) | pager return ;; --show-aircraft) echo 32 liste les appareils (wrapper pour la même option de FG) > /dev/null ld_library_path $FGDIR/install/flightgear/bin/fgfs --show-aircraft --fg-aircraft=$FGADDON/Aircraft 2>/dev/null | pager return ;; --info) echo 33 "donne des infos sur l'appareil en paramètre" > /dev/null check_fgaddon || return 1 local IFS=$'\n' function _info () { local _info=$(sqlite3 $FGADDON/fgaddon.db <<< "select \`$1\` from setxml inner join aircrafts, hangars where aircrafts.hangar = hangars.id and setxml.variantof = aircrafts.id and setxml.file = '$file' and hangars.name = '${${${(@s/ /)ac}[2]}:1:-1}'") if test -n "$_info"; then printf "%s: %s\n" "$2" "$_info" fi } local ac_list=($(sqlite3 $FGADDON/fgaddon.db <<< "select distinct printf('%s [%s, %s]', aircrafts.name, hangars.name, date(aircrafts.date, 'unixepoch')) from aircrafts inner join setxml, hangars where aircrafts.hangar = hangars.id and setxml.variantof = aircrafts.id and setxml.file = '$2' order by aircrafts.date desc")) if test ${#ac_list[@]} -gt 1; then local PS3='which aircraft ? ' select ac in ${ac_list[@]}; do test -z "$ac" && continue break done elif test ${#ac_list[@]} -eq 1; then ac=${ac_list[1]} else return fi local file=$2 _info /sim/description "Short description" _info /sim/long-description "Long description" _info /sim/author "Author(s)" _info /sim/flight-model "Flight model" _info /sim/type "Type" echo Ratings for r in FDM systems cockpit model; do _info /sim/rating/$r " $r" done return ;; --show-thumbnail) echo 32 "affiche la vignette de l'appareil en paramètre (cf. fgaddon)" > /dev/null check_fgaddon || return 1 local PS3='which aircraft ? ' local IFS=$'\n' local ac_list=($(sqlite3 $FGADDON/fgaddon.db <<< "select distinct printf('%s [%s, %s]', aircrafts.name, hangars.name, date(aircrafts.date, 'unixepoch')) from aircrafts inner join setxml, hangars where aircrafts.hangar = hangars.id and setxml.variantof = aircrafts.id and ( setxml.file like '%$2%' or aircrafts.name like '%$2%' ) order by aircrafts.date desc")) if test ${#ac_list[@]} -gt 1; then local PS3='which aircraft ? ' select ac in ${ac_list[@]}; do test -z "$ac" && continue break done elif test ${#ac_list[@]} -eq 1; then ac=${ac_list[1]} else return fi local url=$(sqlite3 $FGADDON/fgaddon.db <<< "select printf('%s/${${(@s/ /)ac}[1]}', url) from hangars where name = '${${${(@s/ /)ac}[2]}:1:-1}'") if test ${${${(@s/ /)ac}[2]}:1:-1} = 'FGMEMBERS'; then url="https://raw.githubusercontent.com/FGMEMBERS/${${(@s/ /)ac}[1]}/master" fi if wget --quiet --spider "$url/thumbnail.jpg"; then curl -s "$url/thumbnail.jpg" \ | convert - -resize '200%' -normalize -sharpen '0.0x1.0' - \ | display else echo "can't find or get thumbnail for ${${(@s/ /)ac}[1]} (${${${(@s/ /)ac}[2]}:1:-1}'s hangar)" fi return ;; --search) echo 30 "cherche un appareil dans la base de données par le nom" > /dev/null check_fgaddon || return 1 sqlite3 $FGADDON/fgaddon.db <<< "select printf('[%s, %s] %s (%s): %s ', hangars.name, date(aircrafts.date, 'unixepoch'), setxml.file, setxml.\`/sim/flight-model\`, setxml.\`/sim/description\`) from setxml inner join aircrafts, hangars where aircrafts.hangar = hangars.id and setxml.variantof = aircrafts.id and ( setxml.file like '%$2%' or aircrafts.name like '%$2%' ) order by aircrafts.date desc" return ;; --search-rating) echo 31 "cherche un appareil dans la base de données par l'évaluation" > /dev/null check_fgaddon || return 1 if test -z $(sqlite3 $FGADDON/fgaddon.db <<< "select 1 from pragma_table_info('setxml') where name == '/sim/rating/${2:-void}'"); then echo "rating ${2:-void} non trouvé, ratings disponibles:" sqlite3 $FGADDON/fgaddon.db <<< "select name from pragma_table_info('setxml') where name like '/sim/rating/%'" | sed 's,/sim/rating/, - ,' return fi sqlite3 $FGADDON/fgaddon.db <<< "select printf('[%s, %s] %s (%s): %s ', hangars.name, date(aircrafts.date, 'unixepoch'), setxml.file, setxml.\`/sim/flight-model\`, setxml.\`/sim/description\`) from setxml inner join aircrafts, hangars where aircrafts.hangar = hangars.id and setxml.variantof = aircrafts.id and setxml.\`/sim/rating/$2\` >= ${3:-4} order by aircrafts.date desc" return ;; --mp-list) echo 40 renvoie la liste des appareils visibles sur multiplayer depuis mpserver01 > /dev/null local mplist=$(mktemp --dry-run /dev/shm/XXXXXXXXX) declare -A installed_model fgaddon_model unknown_model local ac_name= local MPSERVER=${MPSERVER:-mpserver01.flightgear.org} local MPPORT=${MPPORT:-5001} echo data from $MPSERVER:$MPPORT telnet $MPSERVER $MPPORT 2>/dev/null > $mplist grep 'pilot(s) online' $mplist echo local IFS=$'\n' for model in $(awk '/@/{a[$NF]++}END{for (i in a) printf("%s (%i)\n", i, a[i])}' $mplist); do if test -r $FGADDON/${model% *} \ -o -r $FGDIR/source/fgdata/${model% *}; then ((++installed_model[${${(s:/:)model}[2]} ${model#* }])) elif test -r $FGDIR/source/fgdata/AI/${model% *}; then ((++installed_model[*${${(s:/:)model}[2]} ${model#* }])) elif test -n "$(command -v sqlite3)" -a -r $FGADDON/fgaddon.db; then ac_name=$(sqlite3 $FGADDON/fgaddon.db <<< 'select printf("%s/%s", aircrafts.name, setxml.file) from aircrafts inner join setxml where aircrafts.id = setxml.variantof and setxml.`/sim/model/path` = "'${model% *}'" limit 1') if test -n "$ac_name"; then ((++fgaddon_model[${ac_name} ${model#* }])) else ((++unknown_model[${model}])) fi else ((++unknown_model[${model}])) fi done if test ${#installed_model[@]} -gt 0; then echo "${(j:\n:)${(Ok)installed_model[@]}}" > $mplist echo -e "${#installed_model[@]} models installed (*AI model only):\n$(column -c$(tput cols) $mplist)\n" fi if test ${#fgaddon_model[@]} -gt 0; then echo "${(j:\n:)${(Ok)fgaddon_model[@]}}" > $mplist echo -e "${#fgaddon_model[@]} models available in FGADDON:\n$(column -c$(tput cols) $mplist)\n" fi if test ${#unknown_model[@]} -gt 0; then echo "${(j:\n:)${(Ok)unknown_model[@]}}" > $mplist echo -e "${#unknown_model[@]} unknown models:\n$(column -c$(tput cols) $mplist)" fi unset installed_model unknown_model fgaddon_model rm $mplist return ;; --install) echo 35 "installe l'appareil donné en paramètre" > /dev/null check_fgaddon || return 1 local PS3='which aircraft ? ' local IFS=$'\n' select ac in $(sqlite3 $FGADDON/fgaddon.db <<< "select distinct printf('%s [%s, %s]', aircrafts.name, hangars.name, date(aircrafts.date, 'unixepoch')) from aircrafts inner join setxml, hangars where aircrafts.hangar = hangars.id and setxml.variantof = aircrafts.id and ( setxml.file like '%$2%' or aircrafts.name like '%$2%' ) order by aircrafts.date desc"); do test -z "$ac" && continue done test -z "$ac" && return declare -A hangar eval $(sqlite3 $FGADDON/fgaddon.db <<< "select printf('hangar[type]=%s;hangar[url]=%s;', type, url) from hangars where name = '${${${(@s/ /)ac}[2]}:1:-1}'") case ${hangar[type]} in git) git -C $FGADDON/Aircraft clone ${hangar[url]}/${${(@s/ /)ac}[1]}.git;; svn) svn checkout ${hangar[url]}/${${(@s/ /)ac}[1]} $FGADDON/Aircraft/${${(@s/ /)ac}[1]};; esac unset hangar return ;; --mumble) echo 90 lance FG avec mumble > /dev/null if pgrep -u $USER mumble > /dev/null; then echo "there is already a mumble instance launched" else mumble_desktop_entry=($(if test -n "$XDG_DATA_DIRS"; then find "${(s/:/)XDG_DATA_DIRS}" -type f,l -iname "*mumble*desktop"; fi)) if test ${#mumble_desktop_entry[@]} -gt 0; then echo lauching ${mumble_desktop_entry[1]} nohup gtk-launch ${mumble_desktop_entry[1]##*/} > /dev/null 2>&1 & else echo "no desktop entry found for mumble (XDG_DATA_DIRS=$XDG_DATA_DIRS)" return 1 fi fi ;& # on continue avec l'addon fgcom --fgcom) echo 91 lance FG avec fgcom-mumble > /dev/null if test -r $fgfs_source/fgcom-mumble/client/fgfs-addon/addon-metadata.xml; then fgfs_args+=("--addon=$fgfs_source/fgcom-mumble/client/fgfs-addon") else echo "can't find addon fgcom-mumble" return 1 fi ;; --map|--lnm) echo 92 lance LittleNavMap en parallèle ainsi que la liaison avec FG > /dev/null if ! pgrep -u $USER -f "python3 ./fgconnect.py" > /dev/null; then if test -d $FGADDON/Addons/littlenavmap -a -x $fgfs_source/fgconnect/fgconnect.py; then ( cd $fgfs_source/fgconnect; python3 ./fgconnect.py -s )& else echo "can't find FGconnect or littlenavmap addon" return 1 fi else echo "FGconnect already lauched" fi fgfs_args+=("--addon=$FGADDON/Addons/littlenavmap") ;; --addon=*) echo 99 lance FG avec un addon spécifique installé > /dev/null addon_path="${fgfs_arg#*=}" if test -d "$addon_path"; then fgfs_args+=("--addon=$addon_path") elif test -d "$FGADDON/Addons/$addon_path"; then fgfs_args+=("--addon=$FGADDON/Addons/$addon_path") else echo "can't find requested addon in $addon_path or $FGADDON/$addon_path !" fi ;; --ws3|--ws3=.*) echo 80 "utilise World Scenery 3.0 (chemin par défaut $FGADDON/WS3.0)" > /dev/null fgfs_args=("${(@)fgfs_args:#--terrasync-dir=$HOME/.fgfs/TerraSync}") fgfs_args=("${(@)fgfs_args:#--enable-terrasync}") if test "${fgfs_arg#*=}" = "$fgfs_arg"; then fgfs_args+=("--fg-scenery=$FGADDON/WS3.0") elif test -d "${fgfs_arg#*=}/vpb"; then fgfs_args+=("--fg-scenery='${fgfs_arg#*=}'") else echo "${fgfs_arg#*=} isn't a valid WS3 directory" return 1 fi fgfs_args+=("--prop:bool:/scenery/use-vpb=true") fgfs_args+=("--prop:int:/sim/rendering/max-paged-lod=300") fgfs_args+=("--prop:double:/sim/rendering/plod-minimum-expiry-time-secs=30") fgfs_args+=("--prop:int:/sim/rendering/database-pager/threads=8") ;; --ortho) echo 81 utilise Orthoscenery > /dev/null fgfs_args+=("--prop:bool:/sim/rendering/photoscenery/enabled=true") ;; --hdr) echo 82 utilise le compositor HDR > /dev/null local compositor=Compositor/HDR/hdr if test -r $fgfs_source/fgdata/$compositor.xml; then fgfs_args+=("--compositor=$compositor") fgfs_args+=("--prop:bool:/sim/rendering/osm-buildings=false") fgfs_args+=("--prop:bool:/sim/rendering/random-buildings=false") else echo "Compositor $compositor inaccessible" fi ;; *) completion_source="$FGDIR/install/flightgear/share/zsh/site-functions/_fgfs" if test -r "$completion_source"; then if egrep --quiet "^\s*'(${fgfs_arg%=*}=?|)\[" "$completion_source" \ || [[ ${fgfs_arg} =~ ^--prop(:(string|double|float|long|int|bool))?:/[[:print:]]+= ]]; then fgfs_args+=($fgfs_arg) else echo unknown option: ${fgfs_arg%=*} return 1 fi else fgfs_args+=($fgfs_arg) fi ;; esac fi done unset fgfs_arg if [[ -n "$log_requested" && -z "${fgfs_args[(r)--igc=*]}" ]]; then fgfs_args+=(--igc=file,out,1,$(date +%Y%m%d-%H%M-${${${fgfs_args[(r)--aircraft=*]}#--aircraft=}:-$(sed -rn 's|^.+aircraft>(.+)