#!/bin/sh

sudo rpm -iv --force --replacepkgs libpng12-1.2.50-10.el7.x86_64.rpm
sudo rpm -iv --force --replacepkgs libjpeg8-2.1.0-alt1.1.x86_64.rpm
sudo rpm -iv --force --replacepkgs streambox_spectra_control-0.1.53-1.x86_64.rpm
sudo rpm -iv --force --replacepkgs streambox-encoder-spectra-102.51.D07-1.x86_64.rpm
sudo rpm -iv --force --replacepkgs update-streambox-live-ip-0.9-1.x86_64.rpm
sudo cp com.streambox.spectra.desktop /home/$USER/Desktop/
sudo chown -R $USER /home/$USER/Desktop/com.streambox.spectra.desktop 
sudo sed -i 's|use_preset_xml_file = yes|use_preset_xml_file = no|g' /opt/Spectra/bin/encassist.ini

sudo chmod +x /opt/Spectra/bin/*.D07.exe
#set VideoBlocks
sudo ./check_gpu

sudo cp SpectraPlugin.ofx /usr/OFX/Plugins/SpectraPlugin.ofx.bundle/Contents/Linux-x86-64/SpectraPlugin.ofx
sudo chmod +x /usr/OFX/Plugins/SpectraPlugin.ofx.bundle/Contents/Linux-x86-64/SpectraPlugin.ofx

sudo sed -i '/spectra_local_ver_file/d' /opt/Spectra/bin/encassist.ini
sudo sed -i '/quickstartguide-url/d' /opt/Spectra/bin/encassist.ini
sudo sed -i '/quickstartguide-zip-url/d' /opt/Spectra/bin/encassist.ini
sudo sed -i '/quickstartguide-ver-url/d' /opt/Spectra/bin/encassist.ini
sudo sh -c 'echo spectra_local_ver_file=/opt/Spectra/lib/version.txt >>/opt/Spectra/bin/encassist.ini'
sudo sh -c 'echo quickstartguide-url=https://streambox-spectra.s3-us-west-2.amazonaws.com/latest/linux/spectra_quickstart_linux.pdf >>/opt/Spectra/bin/encassist.ini'
sudo sh -c 'echo spectra-zip-url=https://streambox-spectra.s3-us-west-2.amazonaws.com/latest/linux/spectra.zip >>/opt/Spectra/bin/encassist.ini'
sudo sh -c 'echo spectra-ver-url=https://streambox-spectra.s3-us-west-2.amazonaws.com/latest/linux/version.txt >>/opt/Spectra/bin/encassist.ini'

sudo sh -c 'echo 0.11.0.0 >/opt/Spectra/lib/version.txt'

rm -f /tmp/speclog.txt
