pyenv2.sh 1.0 KB

123456789101112131415161718192021222324252627282930313233343536
  1. #!/usr/bin/env bash
  2. set -e
  3. echo "Installing Python 3.10.8"
  4. pyenv install 3.10.8 &>/dev/null
  5. pyenv global 3.10.8
  6. echo "Installed Python 3.10.8"
  7. read -r -p "Would you like to install Home Assistant Beta? <y/N> " prompt
  8. if [[ $prompt == "y" || $prompt == "Y" || $prompt == "yes" || $prompt == "Yes" ]]; then
  9. HA="Y"
  10. fi
  11. if [[ $HA == "Y" ]]; then
  12. echo "Installing Home Assistant Beta"
  13. cat <<EOF >/etc/systemd/system/homeassistant.service
  14. [Unit]
  15. Description=Home Assistant
  16. After=network-online.target
  17. [Service]
  18. Type=simple
  19. WorkingDirectory=/root/.homeassistant
  20. ExecStart=/srv/homeassistant/bin/hass -c "/root/.homeassistant"
  21. RestartForceExitStatus=100
  22. [Install]
  23. WantedBy=multi-user.target
  24. EOF
  25. mkdir /srv/homeassistant
  26. cd /srv/homeassistant
  27. python3 -m venv .
  28. source bin/activate
  29. python3 -m pip install wheel &>/dev/null
  30. pip3 install psycopg2-binary &>/dev/null
  31. pip3 install --pre homeassistant &>/dev/null
  32. systemctl enable homeassistant &>/dev/null
  33. echo "Installed Home Assistant Beta"
  34. echo -e " Go to $(hostname -I | awk '{print $1}'):8123"
  35. hass
  36. fi