diff --git a/wingbits/wingbits_installer.sh b/wingbits/wingbits_installer.sh index 7e1c55b..4209c2a 100644 --- a/wingbits/wingbits_installer.sh +++ b/wingbits/wingbits_installer.sh @@ -1,10 +1,51 @@ #!/usr/bin/env bash set -e -arch="$(dpkg --print-architecture)" -echo System Architecture: $arch +function setup_wingbits_client() { + case "$(uname -s)" in + Linux) + GOOS="linux" + ;; + Darwin) + GOOS="darwin" + ;; + *) + echo "Unsupported OS" + exit 1 + ;; + esac -cd /tmp + # Determine the architecture + 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 latest.json "https://install.wingbits.com/$GOOS-$GOARCH.json" + version=$(grep -o '"Version": "[^"]*"' latest.json | cut -d'"' -f4) + curl -o $WINGBITS_PATH/wingbits.gz "https://install.wingbits.com/$version/$GOOS-$GOARCH.gz" + rm $WINGBITS_PATH/wingbits + gunzip $WINGBITS_PATH/wingbits.gz + chmod +x $WINGBITS_PATH/wingbits + curl -o $WINGBITS_PATH/config.json "https://install.wingbits.com/config.json" + curl -o /lib/systemd/system/wingbits.service "https://install.wingbits.com/wingbits.service" + sed -i -e "s/STATION_ID/$device_id/" $WINGBITS_PATH/config.json +} -bash -c "$(curl -L https://setup.vector.dev)" -apt-get -y install vector +setup_wingbits_client