-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrpi_setup.sh
60 lines (48 loc) · 1.9 KB
/
rpi_setup.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/bin/bash
# 2020 Andy Fraley
# https://github.com/andrewfraley/flirc_repeater
# This script will setup flirc_repeater on a Rasperry Pi with a fresh install of Raspberry PI OS Lite 32-bit
# It may work for vanilla Linux systems as well as long as they are apt/debian based, but it's expecting a user account called "pi"
set -e
# Install dependencies
echo "Install dependencies"
apt install -y git expect python3-evdev python3-ruamel.yaml
# Install FLIRC
echo "Installing FLIRC"
rm -f /tmp/flirc_install.sh
wget apt.flirc.tv/install.sh -O /tmp/flirc_install.sh
chmod 754 /tmp/flirc_install.sh
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo "Running FLIRC install script, this may appear to hang for many minutes!!!"
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
expect <<END
spawn /tmp/flirc_install.sh
expect "Y\n"
send "\r"
wait
END
# Get our source
if [ -d "/opt/flirc_repeater" ]; then
echo 'Directory already exists, attempting a git pull instead of a clone'
cd /opt/flirc_repeater
git pull
else
git clone https://github.com/andrewfraley/flirc_repeater.git /opt/flirc_repeater
fi
# Copy config-example.yaml to config.yaml if config.yaml does not already exist
if [ ! -f "/opt/flirc_repeater/config.yaml" ]; then
cp /opt/flirc_repeater/config-example.yaml /opt/flirc_repeater/config.yaml
fi
chown -R pi:pi /opt/flirc_repeater
# Setup the service
cp /opt/flirc_repeater/flirc_repeater.service /etc/systemd/system/
systemctl daemon-reload
systemctl enable flirc_repeater
# Start the service
systemctl start flirc_repeater
echo ""
echo "Install finsihed!"
echo 'flirc_repeater service started.'
echo 'To tail the logs, do: journalctl -u flirc_repeater -f'
echo 'To restart the service do: systemctl restart flirc_service'
echo 'Note the service will automatically restart if the FLIRC is not connected, until it is connected'