Files
Proxmox-tteck/install/homeassistant-core-install.sh
T
2024-02-01 21:57:34 -05:00

107 lines
2.4 KiB
Bash

#!/usr/bin/env bash
# Copyright (c) 2021-2024 tteck
# Author: tteck (tteckster)
# License: MIT
# https://github.com/tteck/Proxmox/raw/main/LICENSE
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
color
verb_ip6
catch_errors
setting_up_container
network_check
update_os
msg_info "Installing Dependencies (Patience)"
$STD apt-get install -y \
git \
curl \
sudo \
mc \
bluez \
libffi-dev \
libssl-dev \
libjpeg-dev \
zlib1g-dev \
autoconf \
build-essential \
libopenjp2-7 \
libturbojpeg0-dev \
ffmpeg \
liblapack3 \
liblapack-dev \
dbus-broker \
libpcap-dev \
libmariadb-dev-compat \
checkinstall \
libreadline-dev \
libncursesw5-dev \
libsqlite3-dev \
tk-dev \
libgdbm-dev \
libc6-dev \
libbz2-dev \
libatlas-base-dev
msg_ok "Installed Dependencies"
read -r -p "Would you like to build Python 3.12.1 (default 3.11.2)? <y/N> " prompt
if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then
msg_info "Installing Python 3.12.1 (Patience, building from source.)"
$STD apt-get remove -y python3
curl -sL https://www.python.org/ftp/python/3.12.1/Python-3.12.1.tar.xz | tar xJf -
cd Python-3.12.1
$STD ./configure --enable-optimizations
$STD make -j $(nproc)
$STD make altinstall
$STD update-alternatives --install /usr/bin/python3 python3 /usr/local/bin/python3.12 1
cd ~
rm -rf Python-3.12.1
msg_ok "Installed Python 3.12.1"
else
msg_info "Updating Python3"
$STD apt-get install -y \
python3-dev \
python3-pip \
python3-venv
msg_ok "Updated Python3"
fi
msg_info "Installing Home Assistant-Core"
mkdir /srv/homeassistant
cd /srv/homeassistant
python3 -m venv .
source bin/activate
$STD pip install --upgrade pip
$STD python3 -m pip install wheel
$STD pip install homeassistant
$STD pip install mysqlclient
$STD pip install psycopg2-binary
mkdir -p /root/.homeassistant
msg_ok "Installed Home Assistant-Core"
msg_info "Creating Service"
cat <<EOF >/etc/systemd/system/homeassistant.service
[Unit]
Description=Home Assistant
After=network-online.target
[Service]
Type=simple
WorkingDirectory=/root/.homeassistant
ExecStart=/srv/homeassistant/bin/hass -c "/root/.homeassistant"
Restart=always
RestartForceExitStatus=100
[Install]
WantedBy=multi-user.target
EOF
$STD systemctl enable --now homeassistant
msg_ok "Created Service"
motd_ssh
customize
msg_info "Cleaning up"
$STD apt-get autoremove
$STD apt-get autoclean
msg_ok "Cleaned"