Skip to content

Instantly share code, notes, and snippets.

@hdoverobinson
Last active March 23, 2022 05:43
Show Gist options
  • Save hdoverobinson/82e3f08c34052d36c92e8db5a027d129 to your computer and use it in GitHub Desktop.
Save hdoverobinson/82e3f08c34052d36c92e8db5a027d129 to your computer and use it in GitHub Desktop.
Builds Open Satellite Project xritdemod and goesdump from source
#!/bin/bash
###AUTHOR###
#Harry Dove-Robinson 12/14/2017
#[email protected]
#https://gist.github.com/hdoverobinson
#https://github.com/hdoverobinson
###CONTENTS OF TARGET_DIR WILL BE CLEARED AT EACH RUN###
TARGET_DIR="/root/osp-build"
BUILD_DIR="$TARGET_DIR/build"
RUN_DIR="$TARGET_DIR/bin"
LUT_FILE="/root/falsecolor-hdoverobinson.png"
ARCH="x86"
MONO_BRANCH="Release"
MONO_CONFIG="$(printf "$MONO_BRANCH|$ARCH")"
GOESDUMP_BRANCH="master"
GOESDUMP_WEB_URL="https://github.com/opensatelliteproject/goesdump/releases/download/1.0.2-beta/goesdump-web.zip"
BUILD_PACKAGES="build-essential ca-certificates ca-certificates-mono cmake git nuget software-properties-common unzip wget"
RUN_PACKAGES="libaec0 libaec-dev libairspy-dev libhackrf0 libhackrf-dev libusb-1.0-0-dev mono-complete monodevelop screen tzdata"
if [ "$EUID" -ne 0 ]
then echo "This script must be run as root!"
exit 1
fi &&
echo "$(tput setaf 1)ANY FILES WITHIN $TARGET_DIR WILL BE DESTROYED. CONTINUE? (yes/no)$(tput sgr0)" &&
read -r REPLY &&
REPLY=${REPLY,,} &&
if [[ $REPLY =~ ^(yes|y) ]]
then
sleep 2s &&
#create target dir, clear it out if it already exists
echo "$(tput setaf 2)Preparing target directory...$(tput sgr0)" &&
mkdir -p "$TARGET_DIR" &&
cd "$TARGET_DIR" &&
rm -rf * &&
mkdir -p "$BUILD_DIR" &&
mkdir -p "$RUN_DIR" &&
cd "$BUILD_DIR" &&
echo "$(tput setaf 2)Getting dependencies...$(tput sgr0)" &&
apt-get update &&
apt-get --no-install-recommends -y install $BUILD_PACKAGES &&
add-apt-repository ppa:myriadrf/drivers -y &&
add-apt-repository ppa:myriadrf/gnuradio -y &&
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF &&
echo "deb http://download.mono-project.com/repo/ubuntu xenial main" | sudo tee /etc/apt/sources.list.d/mono-official.list &&
apt-get update &&
apt-get --no-install-recommends -y install $RUN_PACKAGES &&
echo "$(tput setaf 2)Building xritdemod...$(tput sgr0)" &&
git clone https://github.com/opensatelliteproject/xritdemod.git &&
cd xritdemod/ &&
make libcorrect &&
make libcorrect-install &&
git clone https://github.com/opensatelliteproject/libsathelper.git &&
cd libsathelper &&
#comment out below line if you have Haswell or newer
sed -i '/ADD_CXX_COMPILER_FLAG_IF_AVAILABLE(-mfma HAVE_FMA)/s/^/#/' CMakeLists.txt &&
mkdir build &&
cd build &&
cmake .. &&
make &&
make install &&
cd ../../ &&
make librtlsdr &&
make librtlsdr-install &&
make &&
make test &&
echo "$(tput setaf 2)Build complete for xritdemod!$(tput sgr0)" &&
cd "$BUILD_DIR" &&
echo "$(tput setaf 2)Building goesdump...$(tput sgr0)" &&
git clone -b "$GOESDUMP_BRANCH" https://github.com/opensatelliteproject/goesdump.git &&
cd goesdump &&
git clone https://github.com/opensatelliteproject/decompressor.git &&
cd decompressor &&
apt-get -y install libaec0 libaec-dev &&
mkdir build &&
cd build &&
cmake .. &&
make &&
make install &&
ldconfig &&
cd "$BUILD_DIR/goesdump" &&
if [[ -f "$LUT_FILE" ]]
then
echo "$(tput setaf 2)Using $LUT_FILE as color LUT...$(tput sgr0)" &&
cp "$LUT_FILE" XRIT/LUT/falsecolor.png
fi &&
nuget restore goesdump.sln &&
mdtool build goesdump.sln -c:"$MONO_CONFIG" &&
cd "goesdump/bin/$MONO_BRANCH" &&
mkbundle --simple goesdump.exe XRIT.dll -o goesdump &&
echo "$(tput setaf 2)Build complete for goesdump!$(tput sgr0)" &&
echo "$(tput setaf 2)Setting up run environment...$(tput sgr0)" &&
mkdir -p "$RUN_DIR/xritdemod" &&
mkdir -p "$RUN_DIR/goesdump" &&
cd "$RUN_DIR/goesdump" &&
cp -r "$BUILD_DIR/goesdump/goesdump/bin/$MONO_BRANCH"/* . &&
chmod +x goesdump.exe goesdump &&
cd "$RUN_DIR/xritdemod" &&
cp "$BUILD_DIR/xritdemod/decoder/build/xritDecoder" . &&
cp "$BUILD_DIR/xritdemod/demodulator/build/xritDemodulator" . &&
chmod +x * &&
echo "$(tput setaf 2)Getting goesdump web components...$(tput sgr0)" &&
cd "$RUN_DIR/goesdump" &&
wget "$GOESDUMP_WEB_URL" &&
unzip goesdump-web.zip &&
mv build web &&
rm goesdump-web.zip &&
echo "$(tput setaf 2)Finished! You can now run the binaries from $RUN_DIR.$(tput sgr0)" &&
exit 0 ||
echo "$(tput setaf 2)Something went wrong!$(tput sgr0)" &&
exit 1
else
echo "$(tput setaf 1)Aborting!$(tput sgr0)" &&
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment