feat: init
This commit is contained in:
commit
e5d4265dbe
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
.*swp*
|
||||||
|
*__pycache__
|
||||||
|
www/config.js
|
79
install.sh
Executable file
79
install.sh
Executable file
@ -0,0 +1,79 @@
|
|||||||
|
#! /bin/bash
|
||||||
|
|
||||||
|
# sudo apt update
|
||||||
|
sudo apt install git vim python3 python3-pip chromium-browser
|
||||||
|
sudo apt-get install -y python3 python3-dev python3-venv python3-pip libffi-dev libssl-dev libjpeg-dev zlib1g-dev autoconf build-essential libopenjp2-7 libtiff5 libturbojpeg0-dev tzdata
|
||||||
|
sudo useradd -rm homeassistant
|
||||||
|
sudo mkdir /srv/homeassistant
|
||||||
|
sudo chown homeassistant:homeassistant /srv/homeassistant
|
||||||
|
|
||||||
|
sudo su homeassistant -c "
|
||||||
|
cd /srv/homeassistant &&
|
||||||
|
python3 -m venv . &&
|
||||||
|
source bin/activate &&
|
||||||
|
python3 -m pip install wheel &&
|
||||||
|
pip3 install homeassistant
|
||||||
|
"
|
||||||
|
|
||||||
|
cat <<EOF | sudo tee /etc/systemd/system/home-assistant@homeassistant.service
|
||||||
|
[Unit]
|
||||||
|
Description=Home Assistant
|
||||||
|
After=network-online.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=simple
|
||||||
|
User=%i
|
||||||
|
WorkingDirectory=/home/%i/.homeassistant
|
||||||
|
ExecStart=/srv/homeassistant/bin/hass -c "/home/%i/.homeassistant"
|
||||||
|
RestartForceExitStatus=100
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
|
EOF
|
||||||
|
|
||||||
|
sudo apt-get install -y apt-transport-https software-properties-common wget
|
||||||
|
wget -q -O - https://packages.grafana.com/gpg.key | sudo apt-key add -
|
||||||
|
echo "deb https://packages.grafana.com/oss/deb stable main" | sudo tee -a /etc/apt/sources.list.d/grafana.list
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install grafana
|
||||||
|
cat <<EOF > /etc/systemd/system/grafana-server.service.d/override.conf
|
||||||
|
[Service]
|
||||||
|
# Give the CAP_NET_BIND_SERVICE capability
|
||||||
|
CapabilityBoundingSet=CAP_NET_BIND_SERVICE
|
||||||
|
AmbientCapabilities=CAP_NET_BIND_SERVICE
|
||||||
|
|
||||||
|
# A private user cannot have process capabilities on the host's user
|
||||||
|
# namespace and thus CAP_NET_BIND_SERVICE has no effect.
|
||||||
|
PrivateUsers=false
|
||||||
|
EOF
|
||||||
|
sudo systemctl daemon-reload
|
||||||
|
sudo systemctl enable home-assistant@homeassistant.service
|
||||||
|
sudo systemctl start home-assistant@homeassistant.service
|
||||||
|
sudo systemctl status home-assistant@homeassistant.service
|
||||||
|
sudo systemctl enable grafana-server
|
||||||
|
sudo systemctl start grafana-server
|
||||||
|
sudo systemctl status grafana-server
|
||||||
|
|
||||||
|
echo "
|
||||||
|
# create user in home ass
|
||||||
|
# go to user profile in home ass
|
||||||
|
# get long lived access token like eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJlM2ZkY2VmZjYyODQ0OWQ5OGY2OTRlNmU2YjUxYzUyYSIsImlhdCI6MTY1MTg0ODU0NiwiZXhwIjoxOTY3MjA4NTQ2fQ.R6_My5eBUMcgompY3L3SbTUCTEIffQaNMUHyUw8sro0
|
||||||
|
"
|
||||||
|
read -p "Please provide your access token: " TOKEN
|
||||||
|
cat << EOF | sudo tee /etc/grafana/grafana.ini
|
||||||
|
metrics:
|
||||||
|
wal_directory: /var/tmp/wal
|
||||||
|
configs:
|
||||||
|
- name: integrations
|
||||||
|
scrape_configs:
|
||||||
|
- job_name: integrations/hass
|
||||||
|
metrics_path: /api/prometheus
|
||||||
|
bearer_token: "$TOKEN"
|
||||||
|
scheme: http
|
||||||
|
static_configs:
|
||||||
|
- targets: ['localhost:8123']
|
||||||
|
remote_write:
|
||||||
|
- url: http://cortex:9009/api/prom/push
|
||||||
|
EOF
|
||||||
|
|
||||||
|
sudo systemctl reload grafana-server
|
Loading…
Reference in New Issue
Block a user