-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinstall.sh
executable file
·51 lines (41 loc) · 1.73 KB
/
install.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
#!/bin/bash
# -------------------------------------------------------------
# emonpilcd install script
# -------------------------------------------------------------
# Assumes emonpi repository installed via git:
# git clone https://github.com/openenergymonitor/emonpi.git
usrdir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
# sudo apt update
sudo apt-get install -y python3-smbus i2c-tools python3-rpi.gpio python3-gpiozero
sudo apt-get install -y libopenjp2-7
pip3 install redis paho-mqtt xmltodict requests adafruit-circuitpython-ssd1306 Pillow
boot_config=/boot/config.txt
if [ -f /boot/firmware/config.txt ]; then
boot_config=/boot/firmware/config.txt
fi
# Uncomment dtparam=i2c_arm=on
sudo sed -i "s/^#dtparam=i2c_arm=on/dtparam=i2c_arm=on/" $boot_config
# Append line i2c-dev to /etc/modules
sudo sed -i -n '/i2c-dev/!p;$a i2c-dev' /etc/modules
# ---------------------------------------------------------
# Install service
# ---------------------------------------------------------
service=emonPiLCD
if [ -f /lib/systemd/system/$service.service ]; then
echo "- reinstalling $service.service"
sudo systemctl stop $service.service
sudo systemctl disable $service.service
sudo rm /lib/systemd/system/$service.service
else
echo "- installing $service.service"
fi
# ---------------------------------------------------------
# Install service
# ---------------------------------------------------------
echo "- installing emonPiLCD.service"
sudo ln -sf $usrdir/$service.service /lib/systemd/system
sudo systemctl enable $service.service
sudo systemctl restart $service.service
state=$(systemctl show $service | grep ActiveState)
echo "- Service $state"
# ---------------------------------------------------------