2023-03-23 01:48:20 +01:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
# Copyright (c) 2021-2023 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 \
|
2023-05-29 22:47:56 +02:00
|
|
|
git \
|
|
|
|
curl \
|
|
|
|
sudo \
|
|
|
|
mc \
|
2023-03-23 01:48:20 +01:00
|
|
|
build-essential \
|
|
|
|
libssl-dev \
|
|
|
|
zlib1g-dev \
|
|
|
|
libbz2-dev \
|
|
|
|
libreadline-dev \
|
|
|
|
libsqlite3-dev \
|
|
|
|
libncursesw5-dev \
|
|
|
|
xz-utils \
|
|
|
|
tk-dev \
|
2023-05-29 22:47:56 +02:00
|
|
|
llvm \
|
2023-03-23 01:48:20 +01:00
|
|
|
libxml2-dev \
|
|
|
|
libxmlsec1-dev \
|
|
|
|
libffi-dev \
|
2023-05-29 22:47:56 +02:00
|
|
|
liblzma-dev \
|
|
|
|
bluez \
|
|
|
|
libmariadb-dev-compat \
|
|
|
|
libjpeg-dev \
|
|
|
|
autoconf \
|
2023-03-23 01:48:20 +01:00
|
|
|
libopenjp2-7 \
|
|
|
|
libtiff5 \
|
|
|
|
libturbojpeg0-dev \
|
2023-05-29 22:47:56 +02:00
|
|
|
liblapack3 \
|
|
|
|
liblapack-dev \
|
|
|
|
libatlas-base-dev
|
2023-03-23 01:48:20 +01:00
|
|
|
msg_ok "Installed Dependencies"
|
|
|
|
|
|
|
|
msg_info "Installing pyenv"
|
|
|
|
$STD git clone https://github.com/pyenv/pyenv.git ~/.pyenv
|
|
|
|
set +e
|
|
|
|
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc
|
|
|
|
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc
|
|
|
|
echo -e 'if command -v pyenv 1>/dev/null 2>&1; then\n eval "$(pyenv init --path)"\nfi' >> ~/.bashrc
|
|
|
|
msg_ok "Installed pyenv"
|
|
|
|
. ~/.bashrc
|
|
|
|
set -e
|
2023-05-29 22:47:56 +02:00
|
|
|
msg_info "Installing Python 3.11.2 (Patience)"
|
2023-04-16 14:24:39 +02:00
|
|
|
$STD pyenv install 3.11.2
|
|
|
|
pyenv global 3.11.2
|
|
|
|
msg_ok "Installed Python 3.11.2"
|
2023-03-23 01:48:20 +01:00
|
|
|
|
|
|
|
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 mysqlclient
|
|
|
|
$STD pip install psycopg2-binary
|
|
|
|
$STD pip install homeassistant
|
|
|
|
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"
|
2023-05-13 16:02:02 +02:00
|
|
|
Restart=always
|
2023-03-23 01:48:20 +01:00
|
|
|
RestartForceExitStatus=100
|
|
|
|
[Install]
|
|
|
|
WantedBy=multi-user.target
|
|
|
|
EOF
|
|
|
|
$STD systemctl enable --now homeassistant
|
|
|
|
msg_ok "Created Service"
|
|
|
|
|
|
|
|
motd_ssh
|
2023-05-15 13:39:30 +02:00
|
|
|
customize
|
2023-03-23 01:48:20 +01:00
|
|
|
|
|
|
|
msg_info "Cleaning up"
|
|
|
|
$STD apt-get autoremove
|
|
|
|
$STD apt-get autoclean
|
|
|
|
msg_ok "Cleaned"
|