core-update.sh 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #!/usr/bin/env bash
  2. clear
  3. if command -v pveversion >/dev/null 2>&1; then echo -e "⚠️ Can't Run from the Proxmox Shell"; exit; fi
  4. set -e
  5. YW=$(echo "\033[33m")
  6. BL=$(echo "\033[36m")
  7. RD=$(echo "\033[01;31m")
  8. BGN=$(echo "\033[4;92m")
  9. GN=$(echo "\033[1;92m")
  10. DGN=$(echo "\033[32m")
  11. CL=$(echo "\033[m")
  12. BFR="\\r\\033[K"
  13. HOLD="-"
  14. CM="${GN}✓${CL}"
  15. CROSS="${RD}✗${CL}"
  16. cat <<"EOF"
  17. _ _ _ _ ___
  18. /\ /\___ _ __ ___ ___ /_\ ___ ___(_)___| |_ __ _ _ __ | |_ / __\___ _ __ ___
  19. / /_/ / _ \| '_ ` _ \ / _ \ //_\\/ __/ __| / __| __/ _` | '_ \| __| / / / _ \| '__/ _ \
  20. / __ / (_) | | | | | | __/ / _ \__ \__ \ \__ \ || (_| | | | | |_ / /__| (_) | | | __/
  21. \/ /_/ \___/|_| |_| |_|\___| \_/ \_/___/___/_|___/\__\__,_|_| |_|\__| \____/\___/|_| \___|
  22. UPDATE
  23. EOF
  24. PY=$(ls /srv/homeassistant/lib/)
  25. IP=$(hostname -I | awk '{print $1}')
  26. if [[ "$PY" == "python3.9" ]]; then echo -e "⚠️ Python 3.9 is deprecated and will be removed in Home Assistant 2023.2"; fi
  27. sleep 2
  28. function msg_info() {
  29. local msg="$1"
  30. echo -ne " ${HOLD} ${YW}${msg}..."
  31. }
  32. function msg_ok() {
  33. local msg="$1"
  34. echo -e "${BFR} ${CM} ${GN}${msg}${CL}"
  35. }
  36. msg_info "Stopping Home Assistant"
  37. systemctl stop homeassistant
  38. msg_ok "Stopped Home Assistant"
  39. read -r -p " Use the Beta Branch? <y/N> " prompt
  40. if [[ $prompt == "y" || $prompt == "Y" || $prompt == "yes" || $prompt == "Yes" ]]; then
  41. BR="--pre "
  42. else
  43. BR=""
  44. fi
  45. msg_info "Updating Home Assistant"
  46. source /srv/homeassistant/bin/activate
  47. pip install ${BR}--upgrade homeassistant &>/dev/null
  48. msg_ok "Updated Home Assistant"
  49. msg_info "Setting Dependency Versions"
  50. sed -i "s/dbus-fast==1.75.0/dbus-fast==1.83.1/g" /srv/homeassistant/lib/$PY/site-packages/homeassistant/package_constraints.txt
  51. sed -i "s/dbus-fast==1.75.0/dbus-fast==1.83.1/g" /srv/homeassistant/lib/$PY/site-packages/homeassistant/components/bluetooth/manifest.json
  52. sed -i "s/bleak==0.19.2/bleak==0.19.5/g" /srv/homeassistant/lib/$PY/site-packages/homeassistant/package_constraints.txt
  53. sed -i "s/bleak==0.19.2/bleak==0.19.5/g" /srv/homeassistant/lib/$PY/site-packages/homeassistant/components/bluetooth/manifest.json
  54. msg_ok "Set Dependency Versions"
  55. msg_info "Starting Home Assistant"
  56. systemctl start homeassistant
  57. msg_ok "Started Home Assistant"
  58. msg_ok "Update Successful"
  59. echo -e "\n Go to http://${IP}:8123 \n"