4
0
Fork 0
mirror of https://github.com/Robertofon/bienenchaos.git synced 2024-06-01 03:36:24 +02:00
bienenchaos/install.sh

55 lines
1.4 KiB
Bash
Raw Normal View History

2020-06-18 22:20:47 +02:00
#!/bin/bash
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-20 22:35:46 +02:00
apt -y install python3
2020-06-18 22:20:47 +02:00
# wir brauchen pip3
2020-06-20 22:35:46 +02:00
apt -y 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-20 23:20:07 +02:00
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 23:20:07 +02:00
# / ersetzen durch \/
Var=${GRAFANA_URL//\//\\/}
# & ersetzen durch \&
Var=${Var//[&]/\\&}
cat src/$f | sed 's/%GRAFANA_URL%/'$Var'/' > /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
2020-06-20 22:45:08 +02:00
cp src/systemd/temp-feuchte-sammler.service /etc/systemd/system/temp-feuchte-sammler.service
2020-06-19 17:39:41 +02:00
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
2020-06-20 22:45:08 +02:00
systemctl enable temp-feuchte-sammler
2020-06-19 17:39:41 +02:00
systemctl enable weight-sammler
# und starten
2020-06-20 22:45:08 +02:00
systemctl start temp-feuchte-sammler
2020-06-19 17:39:41 +02:00
systemctl start weight-sammler