-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathinstall.sh
executable file
·70 lines (55 loc) · 1.53 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/env bash
fail () {
echo "$1"
exit $2
}
## Python 2:
sudo apt-get update
sudo apt-get install python-pip python-prometheus-client
retVal=$?
if [ $retVal -ne 0 ]; then
fail "Error installing python-pip python-prometheus-client" $retVal
fi
sudo python -m pip install --upgrade pip setuptools wheel
retVal=$?
if [ $retVal -ne 0 ]; then
fail "Error installing setuptools wheel" $retVal
fi
sudo pip install Adafruit_DHT
retVal=$?
if [ $retVal -ne 0 ]; then
fail "Error installing Adafruit_DHT" $retVal
fi
# TODO: detect python version
## Python 3:
#sudo apt-get update
#sudo apt-get install python3-pip python3-prometheus-client
#sudo python3 -m pip install --upgrade pip setuptools wheel
#sudo pip3 install Adafruit_DHT
read -p " Enter GPIO pin number the sensor is connected to: " GPIO_PINS
read -p " Enter room name: " ROOMS
# echo $GPIO_PINS
# echo $ROOMS
export GPIO_PINS
export ROOMS
export REFRESH_EVERY_S
cat dht_exporter.service | envsubst | sudo tee /etc/systemd/system/dht_exporter.service
retVal=$?
if [ $retVal -ne 0 ]; then
echo "Error creating /etc/systemd/system/dht_exporter.service"
fi
sudo mkdir -p /opt/dht_exporter
retVal=$?
if [ $retVal -ne 0 ]; then
echo "Error creating folder /opt/dht_exporter"
fi
sudo cp -r dht_exporter.py /opt/dht_exporter/dht_exporter.py
retVal=$?
if [ $retVal -ne 0 ]; then
echo "Error copying to /opt/dht_exporter/dht_exporter.py"
fi
sudo systemctl enable dht_exporter.service
retVal=$?
if [ $retVal -ne 0 ]; then
echo "Error enabling dht_exporter.service"
fi