From e5d4265dbe09c8fb10c09b9354bd55b05cedd091 Mon Sep 17 00:00:00 2001 From: alban Date: Fri, 6 May 2022 18:40:59 +0200 Subject: [PATCH] feat: init --- .gitignore | 3 +++ README.md | 3 +++ install.sh | 79 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 85 insertions(+) create mode 100644 .gitignore create mode 100644 README.md create mode 100755 install.sh diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..06df7ba --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +.*swp* +*__pycache__ +www/config.js diff --git a/README.md b/README.md new file mode 100644 index 0000000..3ebe8f8 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# Home Assistant + Grafana + +WIP diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..99fef5a --- /dev/null +++ b/install.sh @@ -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 < /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