#! /bin/bash # To debug, uncomment # set -x # To stop on any error, uncomment set -e # check for root if [ "$EUID" -ne 0 ] then echo "Please run as root" exit fi # @todo check distrib / version # @todo ask IP address apt update declare -a PACKAGES PACKAGES+=(apt-transport-https) PACKAGES+=(autoconf) PACKAGES+=(build-essential) #PACKAGES+=(chromium-browser) PACKAGES+=(git) PACKAGES+=(libffi-dev) PACKAGES+=(libjpeg-dev) PACKAGES+=(libopenjp2-7) PACKAGES+=(libssl-dev) PACKAGES+=(libtiff5) PACKAGES+=(libturbojpeg0-dev) PACKAGES+=(python3) PACKAGES+=(python3-dev) PACKAGES+=(python3-pip) PACKAGES+=(python3-venv) PACKAGES+=(software-properties-common) PACKAGES+=(tzdata) PACKAGES+=(vim) PACKAGES+=(wget) PACKAGES+=(zlib1g-dev) apt-get install -y ${PACKAGES[@]} ## HOMEASSISTANT INSTALL mkdir -p /srv/homeassistant getent passwd homeassistant || useradd -rm homeassistant -s /bin/bash chown homeassistant:homeassistant /srv/homeassistant su homeassistant -c "mkdir -p /home/homeassistant/.homeassistant" cat < /home/homeassistant/install.sh #!/bin/bash set -x cd /srv/homeassistant && python3 -m venv . && source /srv/homeassistant//bin/activate && python3 -m pip install wheel && pip3 install homeassistant EOF chmod +x /home/homeassistant/install.sh su homeassistant -c /home/homeassistant/install.sh 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 cat << EOF | tee /etc/grafana/grafana.ini metrics: wal_directory: /tmp/wal configs: - name: integrations scrape_configs: - job_name: prometheus metrics_path: /metrics scheme: http static_configs: - targets: ['localhost:9090'] remote_write: - url: http://cortex:9009/api/prom/push EOF systemctl enable grafana-server systemctl start grafana-server systemctl status home-assistant@homeassistant.service systemctl status grafana-server systemctl status prometheus