4
0
Fork 0
mirror of https://github.com/Robertofon/bienenchaos.git synced 2024-06-06 22:06:23 +02:00
bienenchaos/install/install.sh

53 lines
1.6 KiB
Bash
Raw Normal View History

2020-06-18 22:20:47 +02:00
#!/bin/bash
echo "Install skript für die Dienste um Bienentemperatur, Gewicht und Feuchte zu messen. Es werden 3 Dienste erstellt, die im Hintergrund laufen. Publiziert wird via Grafana. Daher muss die Variable GRAFANAENDP gesetzt sein mit host:port und zusätzlich GRAFANADB mit DB-name"
2020-06-19 18:02:20 +02:00
if [ -z "$GRAFANA_URL" ]
then
echo "GRAFANA_URL nicht gesetzt. Ende."
exit 1
fi
2020-06-19 17:39:41 +02:00
if [ "$EUID" -ne 0 ]
then echo "Bitte mit sudo laufen lassen!"
exit
fi
2020-06-18 22:20:47 +02:00
# generell update
2020-06-19 17:39:41 +02:00
apt-get update
apt-get upgrade
2020-06-18 22:20:47 +02:00
# wir brauchen python3
2020-06-19 17:39:41 +02:00
apt install python3
2020-06-18 22:20:47 +02:00
# wir brauchen pip3
2020-06-19 17:39:41 +02:00
apt-get install python3-pip
2020-06-18 22:20:47 +02:00
#Nö: sudo pip3 install --upgrade setuptools
# Run the following command to install the Raspberry PI GPIO library:
#Nö pip3 install RPI.GPIO
#pip3 install adafruit-blinka
2020-06-19 16:46:10 +02:00
sudo pip3 install Adafruit_DHT
2020-06-19 17:39:41 +02:00
# Skripte nach usr/bin kopieren
2020-06-19 18:02:20 +02:00
# dabei über SED drüberjagen, variablen ersetzen
#cp src/temp+feucht-DHT22.py /usr/bin/temp+feucht-DHT22.py
#cp src/weight-datageneration.py /usr/bin/weight-datageneration.py
for f in temp+feucht-DHT22.py weight-datageneration.py
do
2020-06-20 22:00:57 +02:00
cat src/$f | sed s/%GRAFANA_URL%/${GRAFANA_URL}/ > /usr/bin/$f
2020-06-19 18:02:20 +02:00
done
2020-06-19 17:39:41 +02:00
# systemd unit files kopieren und chmod
cp src/systemd/temp+feuchte-sammler.service /etc/systemd/system/temp+feuchte-sammler.service
chmod 644 /etc/systemd/system/temp+feuchte-sammler.service
cp src/systemd/weight-sammler.service /etc/systemd/system/weight-sammler.service
chmod 644 /etc/systemd/system/weight-sammler.service
# services enablen - starten so automatisch
systemctl enable temp+feuchte-sammler
systemctl enable weight-sammler
# und starten
systemctl start temp+feuchte-sammler
systemctl start weight-sammler