homeassistant-core-install.sh 2.7 KB

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