homeassistant-core-install.sh 2.4 KB

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