homeassistant-core-install.sh 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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. git \
  16. curl \
  17. sudo \
  18. mc \
  19. build-essential \
  20. libssl-dev \
  21. zlib1g-dev \
  22. libbz2-dev \
  23. libpcap-dev \
  24. libreadline-dev \
  25. libsqlite3-dev \
  26. libncursesw5-dev \
  27. xz-utils \
  28. tk-dev \
  29. llvm \
  30. libxml2-dev \
  31. libxmlsec1-dev \
  32. libffi-dev \
  33. liblzma-dev \
  34. dbus-broker \
  35. bluez \
  36. libmariadb-dev-compat \
  37. libjpeg-dev \
  38. autoconf \
  39. libopenjp2-7 \
  40. libtiff5 \
  41. libturbojpeg0-dev \
  42. liblapack3 \
  43. liblapack-dev \
  44. libatlas-base-dev
  45. msg_ok "Installed Dependencies"
  46. msg_info "Installing pyenv"
  47. $STD git clone https://github.com/pyenv/pyenv.git ~/.pyenv
  48. set +e
  49. echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc
  50. echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc
  51. echo -e 'if command -v pyenv 1>/dev/null 2>&1; then\n eval "$(pyenv init --path)"\nfi' >> ~/.bashrc
  52. msg_ok "Installed pyenv"
  53. . ~/.bashrc
  54. set -e
  55. msg_info "Installing Python 3.11.3 (Patience)"
  56. $STD pyenv install 3.11.3
  57. pyenv global 3.11.3
  58. msg_ok "Installed Python 3.11.3"
  59. msg_info "Installing Home Assistant-Core"
  60. mkdir /srv/homeassistant
  61. cd /srv/homeassistant
  62. python3 -m venv .
  63. source bin/activate
  64. $STD pip install --upgrade pip
  65. $STD python3 -m pip install wheel
  66. $STD pip install mysqlclient
  67. $STD pip install psycopg2-binary
  68. $STD pip install homeassistant
  69. mkdir -p /root/.homeassistant
  70. msg_ok "Installed Home Assistant-Core"
  71. msg_info "Creating Service"
  72. cat <<EOF >/etc/systemd/system/homeassistant.service
  73. [Unit]
  74. Description=Home Assistant
  75. After=network-online.target
  76. [Service]
  77. Type=simple
  78. WorkingDirectory=/root/.homeassistant
  79. ExecStart=/srv/homeassistant/bin/hass -c "/root/.homeassistant"
  80. Restart=always
  81. RestartForceExitStatus=100
  82. [Install]
  83. WantedBy=multi-user.target
  84. EOF
  85. $STD systemctl enable --now homeassistant
  86. msg_ok "Created Service"
  87. motd_ssh
  88. customize
  89. msg_info "Cleaning up"
  90. $STD apt-get autoremove
  91. $STD apt-get autoclean
  92. msg_ok "Cleaned"