updateskript erstellt und weight syntax
This commit is contained in:
parent
5643ca89a3
commit
a91d7b8fd7
28
install.sh
28
install.sh
|
@ -26,29 +26,5 @@ apt -y install python3-pip
|
||||||
#pip3 install adafruit-blinka
|
#pip3 install adafruit-blinka
|
||||||
pip3 install Adafruit_DHT
|
pip3 install Adafruit_DHT
|
||||||
|
|
||||||
|
# Jetzt noch die Dateien positionieren und Services aktivieren
|
||||||
# Skripte nach usr/bin kopieren
|
./update.sh
|
||||||
# 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
|
|
||||||
# / ersetzen durch \/
|
|
||||||
Var=${GRAFANA_URL//\//\\/}
|
|
||||||
# & ersetzen durch \&
|
|
||||||
Var=${Var//[&]/\\&}
|
|
||||||
cat src/$f | sed 's/%GRAFANA_URL%/'$Var'/' > /usr/bin/$f
|
|
||||||
done
|
|
||||||
|
|
||||||
# systemd unit files kopieren und chmod
|
|
||||||
cp src/systemd/temp-feuchte-sammler.service /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
|
|
|
@ -229,7 +229,7 @@ def write_csv(res):
|
||||||
|
|
||||||
def to_grafana(res):
|
def to_grafana(res):
|
||||||
try:
|
try:
|
||||||
os.system("curl -i -XPOST '"+grafanaurl+"' --data-binary 'weight,location=bees01 value="+str(res))+"'")
|
os.system("curl -i -XPOST '"+grafanaurl+"' --data-binary 'weight,location=bees01 value="+str(res)+"'")
|
||||||
except:
|
except:
|
||||||
print("no access to grafana?")
|
print("no access to grafana?")
|
||||||
pass
|
pass
|
||||||
|
|
|
@ -0,0 +1,38 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
if [ -z "$GRAFANA_URL" ]
|
||||||
|
then
|
||||||
|
echo "GRAFANA_URL nicht gesetzt. Ende."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$EUID" -ne 0 ]
|
||||||
|
then echo "Bitte mit sudo laufen lassen!"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Skripte nach usr/bin kopieren
|
||||||
|
# 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
|
||||||
|
# / ersetzen durch \/
|
||||||
|
Var=${GRAFANA_URL//\//\\/}
|
||||||
|
# & ersetzen durch \&
|
||||||
|
Var=${Var//[&]/\\&}
|
||||||
|
cat src/$f | sed 's/%GRAFANA_URL%/'$Var'/' > /usr/bin/$f
|
||||||
|
done
|
||||||
|
|
||||||
|
# systemd unit files kopieren und chmod
|
||||||
|
cp src/systemd/temp-feuchte-sammler.service /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
|
Loading…
Reference in New Issue