Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,43 @@ jobs:

- name: Run bats suite
run: bats test/

installer-smoke:
name: installer smoke (${{ matrix.image }}, ${{ matrix.path }})
runs-on: ubuntu-24.04
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
timeout-minutes: 45
strategy:
fail-fast: false
matrix:
image:
- debian:13-slim
- ubuntu:24.04
path:
- bundled
- standalone
steps:
- name: Checkout
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
with:
persist-credentials: false

- name: Pin local branch ref to HEAD
env:
BRANCH: ${{ github.event.pull_request.head.ref || github.ref_name }}
run: |
git -C "$PWD" branch -f "$BRANCH" HEAD

- name: Run installer smoke
env:
FEED_BRANCH: ${{ github.event.pull_request.head.ref || github.ref_name }}
IMAGE: ${{ matrix.image }}
TEST_PATH: ${{ matrix.path }}
run: |
docker run --rm \
-e AIRPLANES_FEED_REPO=file:///workspace \
-e AIRPLANES_FEED_BRANCH="$FEED_BRANCH" \
-e AIRPLANES_TEST_PATH="$TEST_PATH" \
-v "$PWD:/workspace:ro" \
"$IMAGE" \
bash /workspace/test/installer-smoke.sh
1 change: 1 addition & 0 deletions .shellcheckrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
disable=SC1090,SC2034
36 changes: 25 additions & 11 deletions configure.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,12 @@

set -e
trap 'echo "[ERROR] Error in line $LINENO when executing: $BASH_COMMAND"' ERR
renice 10 $$ &>/dev/null
renice 10 $$ &>/dev/null || true

SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
# shellcheck source=scripts/lib/install-update-common.sh
source "$SCRIPT_DIR/scripts/lib/install-update-common.sh"
airplanes_init_paths

function abort() {
echo ------------
Expand Down Expand Up @@ -62,21 +67,31 @@ fi

#((-90 <= RECEIVERLATITUDE <= 90))
LAT_OK=0
until [ $LAT_OK -eq 1 ]; do
until [ "$LAT_OK" -eq 1 ]; do
RECEIVERLATITUDE=$(whiptail --backtitle "$BACKTITLETEXT" --title "Antenna Latitude ${RECEIVERLATITUDE}" --nocancel --inputbox "\nEnter the latitude of your antenna in degrees with 5 decimal places.\n(Example: 32.36291)" 12 78 3>&1 1>&2 2>&3) || abort
LAT_OK=`awk -v LAT="$RECEIVERLATITUDE" 'BEGIN {printf (LAT<90 && LAT>-90 ? "1" : "0")}'`
if [[ "$RECEIVERLATITUDE" =~ ^[+-]?[0-9]+([.][0-9]+)?$ ]]; then
LAT_OK=`awk -v LAT="$RECEIVERLATITUDE" 'BEGIN {printf (LAT<90 && LAT>-90 ? "1" : "0")}'`
else
LAT_OK=0
whiptail --backtitle "$BACKTITLETEXT" --title "Invalid latitude" --msgbox "Latitude must be a decimal number." 10 60 || abort
fi
done


#((-180<= RECEIVERLONGITUDE <= 180))
LON_OK=0
until [ $LON_OK -eq 1 ]; do
until [ "$LON_OK" -eq 1 ]; do
RECEIVERLONGITUDE=$(whiptail --backtitle "$BACKTITLETEXT" --title "Antenna Longitude ${RECEIVERLONGITUDE}" --nocancel --inputbox "\nEnter the longitude of your antenna in degrees with 5 decimal places.\n(Example: -64.71492)" 12 78 3>&1 1>&2 2>&3) || abort
LON_OK=`awk -v LON="$RECEIVERLONGITUDE" 'BEGIN {printf (LON<180 && LON>-180 ? "1" : "0")}'`
if [[ "$RECEIVERLONGITUDE" =~ ^[+-]?[0-9]+([.][0-9]+)?$ ]]; then
LON_OK=`awk -v LON="$RECEIVERLONGITUDE" 'BEGIN {printf (LON<180 && LON>-180 ? "1" : "0")}'`
else
LON_OK=0
whiptail --backtitle "$BACKTITLETEXT" --title "Invalid longitude" --msgbox "Longitude must be a decimal number." 10 60 || abort
fi
done

ALT=0
until [[ "$NOSPACENAME" == 0 ]] || [[ $ALT =~ ^(-?[0-9]*)ft$ ]] || [[ $ALT =~ ^(-?[0-9]*)m$ ]]; do
until [[ "$NOSPACENAME" == 0 ]] || [[ $ALT =~ ^-?[0-9]+ft$ ]] || [[ $ALT =~ ^-?[0-9]+m$ ]]; do
ALT=$(whiptail --backtitle "$BACKTITLETEXT" --title "Altitude above sea level (at the antenna):" \
--nocancel --inputbox \
"\nEnter the altitude of your antenna, above sea level, including the unit with no spaces:\n\n\
Expand All @@ -85,12 +100,12 @@ or in meters like this: 78m\n" \
12 78 3>&1 1>&2 2>&3) || abort
done

if [[ $ALT =~ ^-(.*)ft$ ]]; then
if [[ $ALT =~ ^-([0-9]+)ft$ ]]; then
NUM=${BASH_REMATCH[1]}
NEW_ALT=`echo "$NUM" "3.28" | awk '{printf "-%0.2f", $1 / $2 }'`
ALT=$NEW_ALT
fi
if [[ $ALT =~ ^-(.*)m$ ]]; then
if [[ $ALT =~ ^-([0-9]+)m$ ]]; then
NEW_ALT="-${BASH_REMATCH[1]}"
ALT=$NEW_ALT
fi
Expand All @@ -111,8 +126,8 @@ if [[ "$HOSTNAME_VAL" == "radarcape" ]] || { command -v pgrep &>/dev/null && pgr
INPUT_TYPE="radarcape_gps"
fi

mkdir -p /etc/airplanes
tee /etc/airplanes/feed.env >/dev/null <<EOF
mkdir -p "$ETC_AIRPLANES"
tee "$FEED_ENV" >/dev/null <<EOF
INPUT="$INPUT"
REDUCE_INTERVAL="0.5"

Expand Down Expand Up @@ -143,4 +158,3 @@ TARGET="--net-connector feed.airplanes.live,30004,beast_reduce_plus_out,feed.air
NET_OPTIONS="--net-heartbeat 60 --net-ro-size 1280 --net-ro-interval 0.2 --net-ro-port 0 --net-sbs-port 0 --net-bi-port 30187 --net-bo-port 0 --net-ri-port 0 --write-json-every 1 --uuid-file /usr/local/share/airplanes/airplanes-uuid"
JSON_OPTIONS="--max-range 450 --json-location-accuracy 2 --range-outline-hours 24"
EOF

28 changes: 18 additions & 10 deletions create-uuid.sh
Original file line number Diff line number Diff line change
@@ -1,27 +1,35 @@
#!/bin/bash

if [ -f /boot/airplanes-config.txt ]; then
UUID_FILE="/boot/airplanes-uuid"
set -e

SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
# shellcheck source=scripts/lib/install-update-common.sh
source "$SCRIPT_DIR/scripts/lib/install-update-common.sh"
airplanes_init_paths

if [ -f "$BOOT_CONFIG" ]; then
UUID_FILE="$(airplanes_path /boot/airplanes-uuid)"
else
mkdir -p /usr/local/share/airplanes
UUID_FILE="/usr/local/share/airplanes/airplanes-uuid"
mkdir -p "$IPATH"
UUID_FILE="$IPATH/airplanes-uuid"
# move old file position
if [ -f /boot/airplanes-uuid ]; then
mv -f /boot/airplanes-uuid $UUID_FILE
BOOT_UUID="$(airplanes_path /boot/airplanes-uuid)"
if [ -f "$BOOT_UUID" ]; then
mv -f "$BOOT_UUID" "$UUID_FILE"
fi
fi

function generateUUID() {
rm -f $UUID_FILE
rm -f "$UUID_FILE"
sleep 0.$RANDOM; sleep 0.$RANDOM
UUID=$(cat /proc/sys/kernel/random/uuid)
echo New UUID: $UUID
echo $UUID > $UUID_FILE
echo "$UUID" > "$UUID_FILE"
}

# Check for a (valid) UUID...
if [ -f $UUID_FILE ]; then
UUID=$(cat $UUID_FILE)
if [ -f "$UUID_FILE" ]; then
UUID=$(cat "$UUID_FILE")
if ! [[ $UUID =~ ^\{?[A-F0-9a-f]{8}-[A-F0-9a-f]{4}-[A-F0-9a-f]{4}-[A-F0-9a-f]{4}-[A-F0-9a-f]{12}\}?$ ]]; then
# Data in UUID file is invalid. Regenerate it!
echo "WARNING: Data in UUID file was invalid. Regenerating UUID."
Expand Down
119 changes: 89 additions & 30 deletions install.sh
Original file line number Diff line number Diff line change
@@ -1,35 +1,94 @@
#!/bin/bash
set -e

REPO="https://github.com/airplanes-live/feed.git"
BRANCH="main"
IPATH=/usr/local/share/airplanes
mkdir -p $IPATH

if [ "$(id -u)" != "0" ]; then
echo -e "\033[33m"
echo "This script must be ran using sudo or as root."
echo -e "\033[37m"
exit 1
fi
SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"

if [[ -f "$SCRIPT_DIR/scripts/lib/install-update-common.sh" ]]; then
# shellcheck source=scripts/lib/install-update-common.sh
source "$SCRIPT_DIR/scripts/lib/install-update-common.sh"
else
AIRPLANES_ROOT="${AIRPLANES_ROOT:-/}"
AIRPLANES_FEED_REPO="${AIRPLANES_FEED_REPO:-https://github.com/airplanes-live/feed.git}"
AIRPLANES_FEED_BRANCH="${AIRPLANES_FEED_BRANCH:-main}"

airplanes_path() {
local path="$1"
if [[ "$AIRPLANES_ROOT" == "/" ]]; then
printf '%s' "$path"
else
printf '%s%s' "${AIRPLANES_ROOT%/}" "$path"
fi
}

airplanes_init_paths() {
IPATH="$(airplanes_path /usr/local/share/airplanes)"
GIT="$IPATH/git"
}

airplanes_require_root() {
if [[ "${AIRPLANES_SKIP_ROOT_CHECK:-0}" == "1" ]]; then
return 0
fi
if [[ "$(id -u)" != "0" ]]; then
echo -e "\033[33m"
echo "This script must be ran using sudo or as root."
echo -e "\033[37m"
exit 1
fi
}

if ! command -v git &>/dev/null || ! command -v wget &>/dev/null || ! command -v unzip &>/dev/null || ! command -v whiptail &>/dev/null; then
apt-get update || true; apt-get install -y --no-install-recommends --no-install-suggests git wget unzip whiptail || true
airplanes_install_bootstrap_deps() {
if ! command -v git &>/dev/null || ! command -v wget &>/dev/null || ! command -v unzip &>/dev/null || ! command -v whiptail &>/dev/null || ! command -v awk &>/dev/null; then
apt-get update || true
apt-get install -y --no-install-recommends --no-install-suggests git wget unzip whiptail mawk || true
fi
}

getGIT() {
local repo branch target tmp previous_dir
if [[ -z "$1" ]] || [[ -z "$2" ]] || [[ -z "$3" ]]; then
echo "getGIT wrong usage, check your script or tell the author!" 1>&2
return 1
fi
repo="$1"
branch="$2"
target="$3"
previous_dir="$(pwd)"
tmp="/tmp/getGIT-tmp.$RANDOM.$RANDOM"

if cd "$target" &>/dev/null && [[ "$(git remote get-url origin)" == "$repo" ]] && git fetch --depth 1 origin "$branch" && git reset --hard FETCH_HEAD; then
cd "$previous_dir" || return 1
return 0
fi

cd "$previous_dir" || return 1
if ! cd /tmp || ! rm -rf "$target"; then
return 1
fi
if git clone --depth 1 --single-branch --branch "$branch" "$repo" "$target"; then
cd "$previous_dir" || return 1
return 0
fi
if wget -O "$tmp" "${repo%".git"}/archive/$branch.zip" && unzip "$tmp" -d "$tmp.folder"; then
local entries
mapfile -t entries < <(find "$tmp.folder" -mindepth 1 -maxdepth 1 -print)
if [[ "${#entries[@]}" -eq 1 ]] && mv -fT "${entries[0]}" "$target"; then
rm -rf "$tmp" "$tmp.folder"
cd "$previous_dir" || return 1
return 0
fi
fi
rm -rf "$tmp" "$tmp.folder"
cd "$previous_dir" || return 1
return 1
}
fi
function getGIT() {
# getGIT $REPO $BRANCH $TARGET (directory)
if [[ -z "$1" ]] || [[ -z "$2" ]] || [[ -z "$3" ]]; then echo "getGIT wrong usage, check your script or tell the author!" 1>&2; return 1; fi
REPO="$1"; BRANCH="$2"; TARGET="$3"; pushd .; tmp=/tmp/getGIT-tmp.$RANDOM.$RANDOM
if cd "$TARGET" &>/dev/null && [[ $(git remote get-url origin) == "$REPO" ]] && git fetch --depth 1 origin "$BRANCH" && git reset --hard FETCH_HEAD; then popd && return 0; fi
popd; if ! cd /tmp || ! rm -rf "$TARGET"; then return 1; fi
if git clone --depth 1 --single-branch --branch "$2" "$1" "$3"; then return 0; fi
if wget -O "$tmp" "${REPO%".git"}/archive/$BRANCH.zip" && unzip "$tmp" -d "$tmp.folder"; then
if mv -fT "$tmp.folder/$(ls $tmp.folder)" "$TARGET"; then rm -rf "$tmp" "$tmp.folder"; return 0; fi
fi
rm -rf "$tmp" "$tmp.folder"; return 1
}

getGIT "$REPO" "$BRANCH" "$IPATH/git"

cd "$IPATH/git"
bash "$IPATH/git/setup.sh"

airplanes_init_paths
airplanes_require_root
mkdir -p "$IPATH"
airplanes_install_bootstrap_deps
getGIT "$AIRPLANES_FEED_REPO" "$AIRPLANES_FEED_BRANCH" "$GIT"

cd "$GIT"
bash "$GIT/setup.sh"
Loading
Loading