... | ... |
@@ -97,6 +97,17 @@ function fgfs () { |
97 | 97 |
done |
98 | 98 |
export LD_LIBRARY_PATH |
99 | 99 |
} |
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 |
+ } |
|
100 | 111 |
local aircrafts="$FGADDON/Aircraft" |
101 | 112 |
local fgfs_args=("--fg-root=$FGDIR/source/fgdata") |
102 | 113 |
local aircraft= |
... | ... |
@@ -268,6 +279,7 @@ function fgfs () { |
268 | 279 |
return |
269 | 280 |
;; |
270 | 281 |
--info) |
282 |
+ check_fgaddon || return 1 |
|
271 | 283 |
local IFS=$'\n' |
272 | 284 |
function _info () { |
273 | 285 |
local _info=$(sqlite3 $FGADDON/fgaddon.db <<< "select \`$1\` |
... | ... |
@@ -322,6 +334,7 @@ function fgfs () { |
322 | 334 |
return |
323 | 335 |
;; |
324 | 336 |
--show-thumbnail) |
337 |
+ check_fgaddon || return 1 |
|
325 | 338 |
local PS3='which aircraft ? ' |
326 | 339 |
local IFS=$'\n' |
327 | 340 |
local ac_list=($(sqlite3 $FGADDON/fgaddon.db <<< "select distinct printf('%s [%s, %s]', |
... | ... |
@@ -366,7 +379,7 @@ function fgfs () { |
366 | 379 |
return |
367 | 380 |
;; |
368 | 381 |
--search) |
369 |
- command -v sqlite3 > /dev/null || return |
|
382 |
+ check_fgaddon || return 1 |
|
370 | 383 |
sqlite3 $FGADDON/fgaddon.db <<< "select printf('[%s, %s] %s (%s): %s ', |
371 | 384 |
hangars.name, |
372 | 385 |
date(aircrafts.date, 'unixepoch'), |
... | ... |
@@ -439,6 +452,7 @@ function fgfs () { |
439 | 452 |
return |
440 | 453 |
;; |
441 | 454 |
--install) |
455 |
+ check_fgaddon || return 1 |
|
442 | 456 |
local PS3='which aircraft ? ' |
443 | 457 |
local IFS=$'\n' |
444 | 458 |
select ac in $(sqlite3 $FGADDON/fgaddon.db <<< "select distinct printf('%s [%s, %s]', |