# Running out-of-date Raspberry Pi OS

#apt-get update --allow-releaseinfo-change


# Reclaim some disk space

apt-get update

#apt-get clean


## Install prerequisite software

apt-get install -y libcec-dev

#apt-get install -y libsnmp-dev snmp-mibs-downloader libcec-dev


# Create service definition

nano /etc/systemd/system/picontrol.service

#nano /lib/systemd/system/picontrol.service


[Unit]

Description=PiControl

After=network-online.target

Wants=network-online.target


[Service]

Type=idle

ExecStart=python3 -B /srv/picontrol/picontrol.py

Restart=always

RestartSec=1s

StartLimitInterval=0


[Install]

WantedBy=multi-user.target


# Install required Python modules

mkdir -p /srv/picontrol && cd /srv/picontrol

python3 -m venv venv

source venv/bin/activate

pip install websocket-client cec flask-socketio pyserial requests

#python3 -m pip install websocket-client cec flask-socketio netifaces pyserial easysnmp


Or as root...

apt install -y python3-websocket

apt install -y python3-netifaces

apt install -y python3-flask

apt install -y python3-serial

apt install -y python3-cec

apt install -y python3-flask-socketio


# Copy Python files and dependencies

#mkdir -p /srv/picontrol && cd /srv/picontrol

curl -L https://dev.lindisfarne.nsw.edu.au/picontrol/picontrol-0.0.30d.zip -o /tmp/picontrol.zip

unzip /tmp/picontrol.zip

rm /tmp/picontrol.zip


# Enable and start service

systemctl enable picontrol && systemctl start picontrol