#!/bin/bash

if [[ $EUID -ne 0 ]]; then
   echo "This script must be run as root"
   exit 1
fi

echo 'installing dependencies...'
# the server is started in a screen session
apt-get install screen

# monitoradvanced is required for manipulating FPGA registers
cd /tmp
# git clone is very slow for this repo, therefore we download the .zip
wget https://github.com/RedPitaya/RedPitaya/archive/master.zip
unzip master.zip
cd RedPitaya-master/Test/monitoradvanced
make
cp monitoradvanced /usr/bin

# install pyrp3
cd /tmp
git clone https://github.com/hermitdemschoenenleben/pyrp3.git
cd pyrp3
python3 setup.py install

# build monitor shared library
cd monitor
make
cp libmonitor.so /usr/lib/