Skip to content

Commit

Permalink
feat: Wingbits cli prep
Browse files Browse the repository at this point in the history
Prepare for wingbits-cli with geosigner dongle
  • Loading branch information
shawaj committed Dec 1, 2024
1 parent c35c93f commit 6c021d1
Show file tree
Hide file tree
Showing 5 changed files with 106 additions and 30 deletions.
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ services:
build: ./wingbits
image: wingbits
restart: unless-stopped
privileged: true
environment:
- WINGBITS_DEVICE_ID=
- LAT=
Expand Down
16 changes: 10 additions & 6 deletions renovate.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,9 @@
{
"customType": "regex",
"fileMatch": ["(^|/)Dockerfile\\.[^/]*$"],
"matchStrings": ["WINGBITS_COMMIT_ID=(?<currentDigest>.*?)\\n"],
"currentValueTemplate": "master",
"depNameTemplate": "wingbits/config",
"packageNameTemplate": "https://gitlab.com/wingbits/config",
"datasourceTemplate": "git-refs"
"matchStrings": ["WINGBITS_COMMIT_ID=(?<currentValue>.*?)\\n"],
"depNameTemplate": "wingbits-version-json",
"datasourceTemplate": "custom.wingbits_version_json"
},
{
"customType": "regex",
Expand Down Expand Up @@ -60,11 +58,17 @@
"format": "plain"
},
"wingbits": {
"defaultRegistryUrlTemplate": "https://gitlab.com/wingbits/config/-/raw/master/download.sh",
"defaultRegistryUrlTemplate": "https://install.wingbits.com/download.sh",
"transformTemplates": [
"{ \"releases\": [{ \"version\": $trim($[0].releases.version.$match(/WINGBITS_CONFIG_VERSION=\"([^\\s]+)\"/).groups[0]) }] }"
],
"format": "plain"
},
"wingbits_version_json": {
"defaultRegistryUrlTemplate": "https://install.wingbits.com/linux-arm64.json",
"transformTemplates": [
"{\"releases\":[{\"version\": $.Version}]}"
],
}
},
"packageRules": [
Expand Down
12 changes: 5 additions & 7 deletions wingbits/Dockerfile.template
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ ENV WINGBITS_DEVICE_ID=
ENV RECEIVER_HOST=dump1090-fa
ENV RECEIVER_PORT=30005

# renovate: datasource=wingbits depName=wingbits-version versioning=loose
# renovate: datasource=custom.wingbits depName=wingbits-version versioning=loose
ENV WINGBITS_CONFIG_VERSION=0.0.8
# renovate: datasource=git-refs depName=wingbits/config versioning=loose
ENV WINGBITS_COMMIT_ID=0194f1a6b12963f63de234fd10f8338700a80a2a
# renovate: datasource=custom.wingbits_version_json depName=wingbits-version-json versioning=loose
ENV WINGBITS_COMMIT_ID=850b8746

ARG PERM_INSTALL="curl gettext-base tini ncurses-bin zlib1g"
ARG PERM_INSTALL="curl gettext-base tini ncurses-bin zlib1g jq"

RUN apt update && \
apt install -y $PERM_INSTALL && \
Expand Down Expand Up @@ -52,9 +52,7 @@ RUN chmod +x /tmp/wingbits_installer.sh && \
mkdir -p /run/wingbits-feed && \
mkdir -p /etc/wingbits && \
echo "$WINGBITS_CONFIG_VERSION" > /etc/wingbits/version && \
echo "$WINGBITS_COMMIT_ID" > /etc/wingbits/json-version && \
rm -rf /tmp/*

RUN curl -o /etc/vector/vector.yaml https://gitlab.com/wingbits/config/-/raw/$WINGBITS_COMMIT_ID/vector.yaml
RUN sed -i 's|DEVICE_ID|WINGBITS_DEVICE_ID|g' /etc/vector/vector.yaml

ENTRYPOINT ["/usr/bin/tini", "--", "/start.sh"]
71 changes: 60 additions & 11 deletions wingbits/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,59 @@ fi
echo "Settings verified, proceeding with startup."
echo " "

# Check if Wingbits is latest version

local_version=$(cat /etc/wingbits/version)
# Check if Wingbits is latest version and update if not

# Determine the architecture
GOOS="linux"
case "$(uname -m)" in
x86_64)
GOARCH="amd64"
;;
i386|i686)
GOARCH="386"
;;
armv7l)
GOARCH="arm"
;;
aarch64|arm64)
GOARCH="arm64"
;;
*)
echo "Unsupported architecture"
exit 1
;;
esac

WINGBITS_PATH="/etc/wingbits"
local_version=$(cat $WINGBITS_PATH/version)
local_json_version=$(cat $WINGBITS_PATH/json-version)
echo "Current local version: $local_version"
echo "Current local build: $local_json_version"

SCRIPT_URL="https://gitlab.com/wingbits/config/-/raw/master/download.sh"
script=$(curl $SCRIPT_URL)
SCRIPT_URL="https://install.wingbits.com/download.sh"
JSON_URL="https://install.wingbits.com/$GOOS-$GOARCH.json"
script=$(curl -s $SCRIPT_URL)
version=$(echo "$script" | grep -oP '(?<=WINGBITS_CONFIG_VERSION=")[^"]*')
echo "Latest available wingbits version: $version"

if [ "$version" != "$local_version" ] || [ -z "$version" ]; then
echo "WARNING: You are not running the latest Wingbits version. Please update at your earliest convenience."
script_json=$(curl -s $JSON_URL)
json_version=$(echo "$script_json" | jq -r '.Version')

echo "Latest available Wingbits version: $version"
echo "Latest available Wingbits build: $json_version"

if [ "$version" != "$local_version" ] || [ "$json_version" != "$local_json_version" ] || [ -z "$json_version" ] || [ -z "$version" ]; then
echo "WARNING: You are not running the latest Wingbits version. Updating..."
echo "Architecture: $GOOS-$GOARCH"
rm -rf $WINGBITS_PATH/wingbits.gz
curl -s -o $WINGBITS_PATH/wingbits.gz "https://install.wingbits.com/$json_version/$GOOS-$GOARCH.gz"
rm -rf $WINGBITS_PATH/wingbits
gunzip $WINGBITS_PATH/wingbits.gz
chmod +x $WINGBITS_PATH/wingbits
rm -rf $WINGBITS_PATH/config.json
curl -s -o $WINGBITS_PATH/config.json "https://install.wingbits.com/config.json"
echo "$version" > $WINGBITS_PATH/version
echo "$json_version" > $WINGBITS_PATH/json-version
echo "New Wingbits version installed: $version"
echo "New Wingbits build installed: $json_version"
else
echo "Wingbits is up to date"
fi
Expand All @@ -58,9 +99,17 @@ echo " "

# Variables are verified – continue with startup procedure.

# Start vector and readsb and put in the background.
/usr/bin/vector --watch-config &
# Place correct station ID in config.json and /etc/wingbits/device
station="$(jq --arg a "$WINGBITS_DEVICE_ID" '.station = $a' $WINGBITS_PATH/config.json)"
echo -E "${station}" > $WINGBITS_PATH/config.json
echo -E "${WINGBITS_DEVICE_ID}" > $WINGBITS_PATH/device

# Move to wingbits folder
cd $WINGBITS_PATH

# Start readsb and wingbits feeder and put in the background.
/usr/bin/feed-wingbits --net --net-only --debug=n --quiet --net-connector localhost,30006,json_out --write-json /run/wingbits-feed --net-beast-reduce-interval 0.5 --net-heartbeat 60 --net-ro-size 1280 --net-ro-interval 0.2 --net-ro-port 0 --net-sbs-port 0 --net-bi-port 30154 --net-bo-port 0 --net-ri-port 0 --net-connector "$RECEIVER_HOST","$RECEIVER_PORT",beast_in 2>&1 | stdbuf -o0 sed --unbuffered '/^$/d' | awk -W interactive '{print "[readsb-wingbits] " $0}' &
./wingbits feeder start 2>&1 | stdbuf -o0 sed --unbuffered '/^$/d' | awk -W interactive '{print "[wingbits-feeder] " $0}' &

# Wait for any services to exit.
wait -n
36 changes: 30 additions & 6 deletions wingbits/wingbits_installer.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,34 @@
#!/usr/bin/env bash
set -e

arch="$(dpkg --print-architecture)"
echo System Architecture: $arch
function setup_wingbits_client() {
# Determine the architecture
GOOS="linux"
case "$(uname -m)" in
x86_64)
GOARCH="amd64"
;;
i386|i686)
GOARCH="386"
;;
armv7l)
GOARCH="arm"
;;
aarch64|arm64)
GOARCH="arm64"
;;
*)
echo "Unsupported architecture"
exit 1
;;
esac
WINGBITS_PATH="/etc/wingbits"
echo "Architecture: $GOOS-$GOARCH"
mkdir -p $WINGBITS_PATH
curl -o $WINGBITS_PATH/wingbits.gz "https://install.wingbits.com/$WINGBITS_COMMIT_ID/$GOOS-$GOARCH.gz"
gunzip $WINGBITS_PATH/wingbits.gz
chmod +x $WINGBITS_PATH/wingbits
curl -o $WINGBITS_PATH/config.json "https://install.wingbits.com/config.json"
}

cd /tmp

bash -c "$(curl -L https://setup.vector.dev)"
apt-get -y install vector
setup_wingbits_client

0 comments on commit 6c021d1

Please sign in to comment.