#!/bin/bash if [ "$(id -u)" != "0" ]; then echo "This script must be run as root" 1>&2 exit 1 fi echo "This is the installation script for PhotonVision." echo "Installing curl..." apt-get install --yes curl echo "curl installation complete." echo "Installing avahi-daemon..." apt-get install --yes avahi-daemon echo "avahi-daemon installation complete." echo "Installing cpufrequtils..." apt-get install --yes cpufrequtils echo "cpufrequtils installation complete." echo "Setting cpufrequtils to performance mode" if [ -f /etc/default/cpufrequtils ]; then sed -i -e 's/^#\?GOVERNOR=.*$/GOVERNOR=performance/' /etc/default/cpufrequtils else echo 'GOVERNOR=performance' > /etc/default/cpufrequtils fi echo "Installing the JDK..." if [ $(dpkg-query -W -f='${Status}' openjdk-11-jdk-headless 2>/dev/null | grep -c "ok installed") -eq 0 ]; then apt-get update apt-get install --yes openjdk-11-jdk-headless fi echo "JDK installation complete." echo "Downloading latest stable release of PhotonVision..." mkdir -p /opt/photonvision cd /opt/photonvision curl -sk https://api.github.com/repos/photonvision/photonvision/releases/latest | grep "browser_download_url.*jar" | cut -d : -f 2,3 | tr -d '"' | wget -qi - -O photonvision.jar echo "Downloaded latest stable release of PhotonVision." echo "Creating the PhotonVision systemd service..." if service --status-all | grep -Fq 'photonvision'; then systemctl stop photonvision systemctl disable photonvision rm /lib/systemd/system/photonvision.service rm /etc/systemd/system/photonvision.service systemctl daemon-reload systemctl reset-failed fi cat > /lib/systemd/system/photonvision.service <