homeassistant-core-install.sh 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. #!/usr/bin/env bash
  2. # Copyright (c) 2021-2023 tteck
  3. # Author: tteck (tteckster)
  4. # License: MIT
  5. # https://github.com/tteck/Proxmox/raw/main/LICENSE
  6. source /dev/stdin <<< "$FUNCTIONS_FILE_PATH"
  7. color
  8. verb_ip6
  9. catch_errors
  10. setting_up_container
  11. network_check
  12. update_os
  13. msg_info "Installing Dependencies (Patience)"
  14. $STD apt-get install -y \
  15. make \
  16. build-essential \
  17. libjpeg-dev \
  18. libpcap-dev \
  19. libssl-dev \
  20. zlib1g-dev \
  21. libbz2-dev \
  22. libreadline-dev \
  23. libsqlite3-dev \
  24. libmariadb-dev-compat \
  25. autoconf \
  26. git \
  27. curl \
  28. sudo \
  29. mc \
  30. llvm \
  31. libncursesw5-dev \
  32. xz-utils \
  33. tzdata \
  34. bluez \
  35. tk-dev \
  36. libxml2-dev \
  37. libxmlsec1-dev \
  38. libffi-dev \
  39. libopenjp2-7 \
  40. libtiff5 \
  41. libturbojpeg0-dev \
  42. liblzma-dev
  43. msg_ok "Installed Dependencies"
  44. msg_info "Installing Linux D-Bus Message Broker"
  45. cat <<EOF >>/etc/apt/sources.list
  46. deb http://deb.debian.org/debian bullseye-backports main contrib non-free
  47. deb-src http://deb.debian.org/debian bullseye-backports main contrib non-free
  48. EOF
  49. $STD apt-get update
  50. $STD apt-get -t bullseye-backports install -y dbus-broker
  51. $STD systemctl enable --now dbus-broker.service
  52. msg_ok "Installed Linux D-Bus Message Broker"
  53. msg_info "Installing pyenv"
  54. $STD git clone https://github.com/pyenv/pyenv.git ~/.pyenv
  55. set +e
  56. echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc
  57. echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc
  58. echo -e 'if command -v pyenv 1>/dev/null 2>&1; then\n eval "$(pyenv init --path)"\nfi' >> ~/.bashrc
  59. msg_ok "Installed pyenv"
  60. . ~/.bashrc
  61. set -e
  62. msg_info "Installing Python 3.11.2"
  63. $STD pyenv install 3.11.2
  64. pyenv global 3.11.2
  65. msg_ok "Installed Python 3.11.2"
  66. msg_info "Installing Home Assistant-Core"
  67. mkdir /srv/homeassistant
  68. cd /srv/homeassistant
  69. python3 -m venv .
  70. source bin/activate
  71. $STD pip install --upgrade pip
  72. $STD python3 -m pip install wheel
  73. $STD pip install mysqlclient
  74. $STD pip install psycopg2-binary
  75. $STD pip install homeassistant
  76. mkdir -p /root/.homeassistant
  77. msg_ok "Installed Home Assistant-Core"
  78. msg_info "Creating Service"
  79. cat <<EOF >/etc/systemd/system/homeassistant.service
  80. [Unit]
  81. Description=Home Assistant
  82. After=network-online.target
  83. [Service]
  84. Type=simple
  85. WorkingDirectory=/root/.homeassistant
  86. ExecStart=/srv/homeassistant/bin/hass -c "/root/.homeassistant"
  87. RestartForceExitStatus=100
  88. [Install]
  89. WantedBy=multi-user.target
  90. EOF
  91. $STD systemctl enable --now homeassistant
  92. msg_ok "Created Service"
  93. motd_ssh
  94. root
  95. msg_info "Cleaning up"
  96. $STD apt-get autoremove
  97. $STD apt-get autoclean
  98. msg_ok "Cleaned"