podman-homeassistant.sh 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. #!/usr/bin/env bash
  2. source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func)
  3. # Copyright (c) 2021-2023 tteck
  4. # Author: tteck (tteckster)
  5. # License: MIT
  6. # https://github.com/tteck/Proxmox/raw/main/LICENSE
  7. function header_info {
  8. clear
  9. cat <<"EOF"
  10. ____ __
  11. / __ \____ ____/ /___ ___ ____ _____
  12. / /_/ / __ \/ __ / __ __ \/ __ / __ \
  13. / ____/ /_/ / /_/ / / / / / / /_/ / / / /
  14. __ __ /_/ \____/\__,_/_/ /_/ /_/\__,_/_/ /_/__ __
  15. / / / /___ ____ ___ ___ / | __________(_)____/ /_____ _____ / /_
  16. / /_/ / __ \/ __ __ \/ _ \ / /| | / ___/ ___/ / ___/ __/ __ / __ \/ __/
  17. / __ / /_/ / / / / / / __/ / ___ |(__ |__ ) (__ ) /_/ /_/ / / / / /_
  18. /_/ /_/\____/_/ /_/ /_/\___/ /_/ |_/____/____/_/____/\__/\__,_/_/ /_/\__/
  19. EOF
  20. }
  21. header_info
  22. echo -e "Loading..."
  23. APP="Podman-Home Assistant"
  24. var_disk="16"
  25. var_cpu="2"
  26. var_ram="2048"
  27. var_os="debian"
  28. var_version="11"
  29. variables
  30. color
  31. catch_errors
  32. function default_settings() {
  33. CT_TYPE="1"
  34. PW=""
  35. CT_ID=$NEXTID
  36. HN=$NSAPP
  37. DISK_SIZE="$var_disk"
  38. CORE_COUNT="$var_cpu"
  39. RAM_SIZE="$var_ram"
  40. BRG="vmbr0"
  41. NET=dhcp
  42. GATE=""
  43. DISABLEIP6="no"
  44. MTU=""
  45. SD=""
  46. NS=""
  47. MAC=""
  48. VLAN=""
  49. SSH="no"
  50. VERB="no"
  51. echo_default
  52. }
  53. function update_script() {
  54. if [[ ! -f /etc/systemd/system/homeassistant.service ]]; then msg_error "No ${APP} Installation Found!"; exit; fi
  55. UPD=$(whiptail --title "UPDATE" --radiolist --cancel-button Exit-Script "Spacebar = Select" 11 58 4 \
  56. "1" "Update Podman" ON \
  57. "2" "Install HACS" OFF \
  58. "3" "Install FileBrowser" OFF \
  59. 3>&1 1>&2 2>&3)
  60. header_info
  61. if [ "$UPD" == "1" ]; then
  62. msg_info "Updating ${APP} LXC"
  63. apt-get update &>/dev/null
  64. apt-get -y upgrade &>/dev/null
  65. msg_ok "Updated ${APP} LXC"
  66. msg_ok "Update Successfull"
  67. exit
  68. fi
  69. if [ "$UPD" == "2" ]; then
  70. msg_info "Installing Home Assistant Comunity Store (HACS)"
  71. apt update &>/dev/null
  72. apt install unzip &>/dev/null
  73. cd /var/lib/containers/storage/volumes/hass_config/_data
  74. bash <(curl -fsSL https://get.hacs.xyz) &>/dev/null
  75. msg_ok "Installed Home Assistant Comunity Store (HACS)"
  76. echo -e "\n Reboot Home Assistant and clear browser cache then Add HACS integration.\n"
  77. exit
  78. fi
  79. if [ "$UPD" == "3" ]; then
  80. IP=$(hostname -I | awk '{print $1}')
  81. msg_info "Installing FileBrowser"
  82. curl -fsSL https://raw.githubusercontent.com/filebrowser/get/master/get.sh | bash &>/dev/null
  83. filebrowser config init -a '0.0.0.0' &>/dev/null
  84. filebrowser config set -a '0.0.0.0' &>/dev/null
  85. filebrowser users add admin changeme --perm.admin &>/dev/null
  86. msg_ok "Installed FileBrowser"
  87. msg_info "Creating Service"
  88. service_path="/etc/systemd/system/filebrowser.service"
  89. echo "[Unit]
  90. Description=Filebrowser
  91. After=network-online.target
  92. [Service]
  93. User=root
  94. WorkingDirectory=/root/
  95. ExecStart=/usr/local/bin/filebrowser -r /
  96. [Install]
  97. WantedBy=default.target" >$service_path
  98. systemctl enable --now filebrowser.service &>/dev/null
  99. msg_ok "Created Service"
  100. msg_ok "Completed Successfully!\n"
  101. echo -e "FileBrowser should be reachable by going to the following URL.
  102. ${BL}http://$IP:8080${CL} admin|changeme\n"
  103. exit
  104. fi
  105. }
  106. start
  107. build_container
  108. description
  109. msg_ok "Completed Successfully!\n"
  110. echo -e "${APP} should be reachable by going to the following URL.
  111. ${BL}http://${IP}:8123${CL} \n"