Skip to content

Commit 3aec45d

Browse files
committed
Support prebuilt airplanes.live images in update and runtime scripts
Adds a parallel image-install branch to update.sh, gated on both the boot config file and an executable airplanes-feeder. On image installs, update.sh sources config from the boot partition, skips the readsb compile, and orders its systemd units after airplanes-first-run.service; manual installs follow the existing path unchanged. Runtime scripts and the apl-feed CLI gain matching multi-source config handling, and both unit files now set RestartPreventExitStatus=64 so a config-fatal exit no longer respawns.
1 parent 7fe0466 commit 3aec45d

14 files changed

Lines changed: 770 additions & 97 deletions

.github/workflows/ci.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,3 +91,31 @@ jobs:
9191
-v "$PWD:/workspace:ro" \
9292
"$IMAGE" \
9393
bash /workspace/test/installer-smoke.sh
94+
95+
image-rootfs-smoke:
96+
name: image rootfs smoke
97+
runs-on: ubuntu-24.04
98+
timeout-minutes: 20
99+
steps:
100+
- name: Checkout feed
101+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
102+
with:
103+
persist-credentials: false
104+
path: feed
105+
106+
- name: Checkout image updater
107+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
108+
with:
109+
persist-credentials: false
110+
repository: airplanes-live/airplanes-update
111+
path: airplanes-update
112+
113+
- name: Run image rootfs smoke
114+
run: |
115+
docker run --rm \
116+
-e AIRPLANES_FEED_DIR=/feed \
117+
-e AIRPLANES_UPDATE_DIR=/airplanes-update \
118+
-v "$PWD/feed:/feed:ro" \
119+
-v "$PWD/airplanes-update:/airplanes-update:ro" \
120+
debian:13-slim \
121+
bash /feed/test/image-rootfs-smoke.sh

scripts/airplanes-feed.service

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ ExecStart=/usr/local/share/airplanes/airplanes-feed.sh
1111
Type=simple
1212
Restart=always
1313
RestartSec=30
14+
RestartPreventExitStatus=64
1415
StartLimitInterval=1
1516
StartLimitBurst=100
1617
SyslogIdentifier=airplanes-feed

scripts/airplanes-feed.sh

Lines changed: 51 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,31 @@
11
#!/bin/bash
22

3-
if grep -qs -e 'LATITUDE' /boot/adsb-config.txt &>/dev/null && [[ -f /boot/airplanes-env ]]; then
4-
source /boot/adsb-config.txt
5-
source /boot/airplanes-env
3+
AIRPLANES_ROOT="${AIRPLANES_ROOT:-/}"
4+
airplanes_path() {
5+
local path="$1"
6+
if [[ "$AIRPLANES_ROOT" == "/" ]]; then
7+
printf '%s' "$path"
8+
else
9+
printf '%s%s' "${AIRPLANES_ROOT%/}" "$path"
10+
fi
11+
}
12+
13+
BOOT_CONFIG="$(airplanes_path /boot/airplanes-config.txt)"
14+
BOOT_ENV="$(airplanes_path /boot/airplanes-env)"
15+
FEED_ENV="$(airplanes_path /etc/airplanes/feed.env)"
16+
IMAGE_FEED_BIN="$(airplanes_path /usr/bin/airplanes-feeder)"
17+
18+
IMAGE_INSTALL=0
19+
if [[ -f "$BOOT_CONFIG" && -x "$IMAGE_FEED_BIN" ]]; then
20+
IMAGE_INSTALL=1
21+
source "$BOOT_CONFIG"
22+
[[ -f "$BOOT_ENV" ]] && source "$BOOT_ENV"
623
else
7-
source /etc/airplanes/feed.env
24+
source "$FEED_ENV"
825
fi
926

10-
if ! [[ -d /run/airplanes-feed/ ]]; then
11-
mkdir -p /run/airplanes-feed
12-
fi
27+
RUN_DIR="$(airplanes_path /run/airplanes-feed)"
28+
mkdir -p "$RUN_DIR"
1329

1430
if [[ -z $INPUT ]]; then
1531
INPUT="127.0.0.1:30005"
@@ -27,21 +43,38 @@ UAT_IP=$(echo $UAT_INPUT | cut -d: -f1)
2743
UAT_PORT=$(echo $UAT_INPUT | cut -d: -f2)
2844
UAT_SOURCE="--net-connector $UAT_IP,$UAT_PORT,uat_in,silent_fail"
2945

30-
if [ -f /boot/airplanes-config.txt ]; then
31-
UUID_FILE="/boot/airplanes-uuid"
46+
if [[ -f "$BOOT_CONFIG" ]]; then
47+
UUID_FILE="$(airplanes_path /boot/airplanes-uuid)"
48+
else
49+
UUID_FILE="$(airplanes_path /usr/local/share/airplanes/airplanes-uuid)"
50+
fi
51+
52+
REDUCE_INTERVAL="${REDUCE_INTERVAL:-0.5}"
53+
JSON_OPTIONS="${JSON_OPTIONS:-"--json-location-accuracy 2"}"
54+
MODEAC_OPTION=""
55+
if [[ "${MODEAC:-}" == "yes" ]]; then
56+
MODEAC_OPTION="--modeac"
57+
fi
58+
59+
if [[ "$IMAGE_INSTALL" == "1" ]]; then
60+
FEED_BIN="${AIRPLANES_FEED_BIN:-$IMAGE_FEED_BIN}"
61+
TARGET="${TARGET:-"--net-connector feed.airplanes.live,30004,beast_reduce_plus_out,feed2.airplanes.live,64004"}"
62+
FEED_NET_OPTIONS="${FEED_NET_OPTIONS:-"--net-ro-interval 0.2"}"
63+
FEED_IMAGE_OPTIONS="${FEED_IMAGE_OPTIONS:-"--db-file=none --max-range 450"}"
3264
else
33-
UUID_FILE="/usr/local/share/airplanes/airplanes-uuid"
65+
FEED_BIN="${AIRPLANES_FEED_BIN:-$(airplanes_path /usr/local/share/airplanes/feed-airplanes)}"
66+
FEED_NET_OPTIONS="${FEED_NET_OPTIONS:-$NET_OPTIONS}"
67+
FEED_IMAGE_OPTIONS=""
3468
fi
35-
36-
exec /usr/local/share/airplanes/feed-airplanes --net --net-only --quiet \
37-
--uuid-file=$UUID_FILE \
38-
--write-json /run/airplanes-feed \
69+
70+
exec "$FEED_BIN" --net --net-only --quiet \
71+
"--uuid-file=$UUID_FILE" \
72+
--write-json "$RUN_DIR" \
73+
$FEED_IMAGE_OPTIONS \
3974
--net-beast-reduce-interval $REDUCE_INTERVAL \
40-
$TARGET $NET_OPTIONS \
75+
$TARGET $FEED_NET_OPTIONS \
4176
--lat "$LATITUDE" --lon "$LONGITUDE" \
4277
$JSON_OPTIONS \
4378
$UAT_SOURCE \
4479
$SOURCE \
45-
46-
47-
80+
$MODEAC_OPTION

scripts/airplanes-mlat.service

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ ExecStart=/usr/local/share/airplanes/airplanes-mlat.sh
1111
Type=simple
1212
Restart=always
1313
RestartSec=30
14+
RestartPreventExitStatus=64
1415
StartLimitInterval=1
1516
StartLimitBurst=100
1617
SyslogIdentifier=airplanes-mlat

scripts/airplanes-mlat.sh

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,32 @@
11
#!/bin/bash
22

3-
if grep -qs -e 'LATITUDE' /boot/adsb-config.txt &>/dev/null && [[ -f /boot/airplanes-env ]]; then
4-
source /boot/adsb-config.txt
5-
source /boot/airplanes-env
3+
AIRPLANES_ROOT="${AIRPLANES_ROOT:-/}"
4+
airplanes_path() {
5+
local path="$1"
6+
if [[ "$AIRPLANES_ROOT" == "/" ]]; then
7+
printf '%s' "$path"
8+
else
9+
printf '%s%s' "${AIRPLANES_ROOT%/}" "$path"
10+
fi
11+
}
12+
13+
BOOT_CONFIG="$(airplanes_path /boot/airplanes-config.txt)"
14+
BOOT_ENV="$(airplanes_path /boot/airplanes-env)"
15+
FEED_ENV="$(airplanes_path /etc/airplanes/feed.env)"
16+
17+
if [[ -f "$BOOT_CONFIG" && -x "$(airplanes_path /usr/bin/airplanes-feeder)" ]]; then
18+
source "$BOOT_CONFIG"
19+
[[ -f "$BOOT_ENV" ]] && source "$BOOT_ENV"
20+
else
21+
source "$FEED_ENV"
22+
fi
23+
24+
if [[ "${MLAT_MARKER:-}" == "no" ]]; then
25+
PRIVACY="--privacy"
26+
elif [[ -n "${MLAT_MARKER:-}" ]]; then
27+
PRIVACY=""
628
else
7-
source /etc/airplanes/feed.env
29+
PRIVACY="${PRIVACY:-}"
830
fi
931

1032
if [[ "$LATITUDE" == 0 ]] || [[ "$LONGITUDE" == 0 ]] || [[ "$USER" == 0 ]] || [[ "$USER" == "disable" ]]; then
@@ -23,7 +45,7 @@ while ! nc -z "$INPUT_IP" "$INPUT_PORT" && command -v nc &>/dev/null; do
2345
sleep 10
2446
done
2547

26-
exec /usr/local/share/airplanes/venv/bin/mlat-client \
48+
exec "$(airplanes_path /usr/local/share/airplanes/venv/bin/mlat-client)" \
2749
--input-type "$INPUT_TYPE" --no-udp \
2850
--input-connect "$INPUT" \
2951
--server "$MLATSERVER" \
@@ -32,5 +54,5 @@ exec /usr/local/share/airplanes/venv/bin/mlat-client \
3254
--lon "$LONGITUDE" \
3355
--alt "$ALTITUDE" \
3456
$PRIVACY \
35-
$UUID_FILE \
57+
${UUID_FILE:-} \
3658
$RESULTS $RESULTS1 $RESULTS2 $RESULTS3 $RESULTS4

scripts/apl-feed/common.sh

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,25 @@ secret_version_path() {
7878
}
7979

8080
feed_env_path() {
81+
if [[ -f "$(root_path '/boot/airplanes-config.txt')" && -x "$(root_path '/usr/bin/airplanes-feeder')" ]]; then
82+
root_path '/boot/airplanes-config.txt'
83+
return
84+
fi
8185
root_path '/etc/airplanes/feed.env'
8286
}
8387

88+
feed_env_paths() {
89+
if [[ -f "$(root_path '/boot/airplanes-config.txt')" && -x "$(root_path '/usr/bin/airplanes-feeder')" ]]; then
90+
root_path '/boot/airplanes-config.txt'
91+
printf '\n'
92+
root_path '/boot/airplanes-env'
93+
printf '\n'
94+
return
95+
fi
96+
feed_env_path
97+
printf '\n'
98+
}
99+
84100
require_jq() {
85101
command -v jq >/dev/null 2>&1 || die "jq is required"
86102
}
@@ -149,14 +165,19 @@ read_version_file() {
149165

150166
feed_env_get() {
151167
local key="$1"
152-
local path
153-
path="$(feed_env_path)"
154-
[[ -f "$path" ]] || return 1
155-
sed -n \
156-
-e "s/^${key}=\"\\(.*\\)\"[[:space:]]*$/\\1/p" \
157-
-e "s/^${key}='\\(.*\\)'[[:space:]]*$/\\1/p" \
158-
-e "s/^${key}=\\([^#[:space:]]*\\).*$/\\1/p" \
159-
"$path" | tail -n 1
168+
local path output
169+
output="$(
170+
while IFS= read -r path; do
171+
[[ -f "$path" ]] || continue
172+
sed -n \
173+
-e "s/^${key}=\"\\(.*\\)\"[[:space:]]*$/\\1/p" \
174+
-e "s/^${key}='\\(.*\\)'[[:space:]]*$/\\1/p" \
175+
-e "s/^${key}=\\([^#[:space:]]*\\).*$/\\1/p" \
176+
"$path"
177+
done < <(feed_env_paths)
178+
)"
179+
[[ -n "$output" ]] || return 1
180+
printf '%s\n' "$output" | tail -n 1
160181
}
161182

162183
read_uuid() {

scripts/lib/install-update-common.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,14 @@ airplanes_init_paths() {
2929
SYSTEMD_DIR="$(airplanes_path /lib/systemd/system)"
3030
}
3131

32+
airplanes_is_image_install() {
33+
[[ -f "$BOOT_CONFIG" && -x "$(airplanes_path /usr/bin/airplanes-feeder)" ]]
34+
}
35+
36+
airplanes_image_target_default() {
37+
printf '%s' '--net-connector feed.airplanes.live,30004,beast_reduce_plus_out,feed2.airplanes.live,64004'
38+
}
39+
3240
airplanes_require_root() {
3341
if [[ "${AIRPLANES_SKIP_ROOT_CHECK:-0}" == "1" ]]; then
3442
return 0

scripts/second-mlat.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ Nice=-1
3939
WantedBy=default.target
4040
EOF
4141

42-
if [[ -f /boot/adsb-config.txt ]]; then
42+
if [[ -f /boot/airplanes-config.txt ]]; then
43+
sed -i -e 's#EnvironmentFile.*#EnvironmentFile=/boot/airplanes-env\nEnvironmentFile=/boot/airplanes-config.txt#' "$SERVICE"
44+
elif [[ -f /boot/adsb-config.txt ]]; then
4345
sed -i -e 's#EnvironmentFile.*#EnvironmentFile=/boot/airplanes-env\nEnvironmentFile=/boot/adsb-config.txt#' "$SERVICE"
4446
fi
4547

0 commit comments

Comments
 (0)