heimdalldashboard.sh 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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. EOF
  16. }
  17. header_info
  18. echo -e "Loading..."
  19. APP="Heimdall Dashboard"
  20. var_disk="2"
  21. var_cpu="1"
  22. var_ram="512"
  23. var_os="debian"
  24. var_version="12"
  25. variables
  26. color
  27. catch_errors
  28. function default_settings() {
  29. CT_TYPE="1"
  30. PW=""
  31. CT_ID=$NEXTID
  32. HN=$NSAPP
  33. DISK_SIZE="$var_disk"
  34. CORE_COUNT="$var_cpu"
  35. RAM_SIZE="$var_ram"
  36. BRG="vmbr0"
  37. NET="dhcp"
  38. GATE=""
  39. DISABLEIP6="no"
  40. MTU=""
  41. SD=""
  42. NS=""
  43. MAC=""
  44. VLAN=""
  45. SSH="no"
  46. VERB="no"
  47. echo_default
  48. }
  49. function update_script() {
  50. header_info
  51. if [[ ! -d /opt/Heimdall ]]; then msg_error "No ${APP} Installation Found!"; exit; fi
  52. msg_info "Stopping ${APP}"
  53. systemctl disable heimdall.service &>/dev/null
  54. systemctl stop heimdall
  55. sleep 1
  56. msg_ok "Stopped ${APP}"
  57. msg_info "Backing up Data"
  58. if [ -d "/opt/Heimdall-2.4.6" ]; then
  59. cp -R /opt/Heimdall-2.4.6/database database-backup
  60. cp -R /opt/Heimdall-2.4.6/public public-backup
  61. elif [[ -d "/opt/Heimdall-2.4.7b" ]]; then
  62. cp -R /opt/Heimdall-2.4.7b/database database-backup
  63. cp -R /opt/Heimdall-2.4.7b/public public-backup
  64. elif [[ -d "/opt/Heimdall-2.4.8" ]]; then
  65. cp -R /opt/Heimdall-2.4.8/database database-backup
  66. cp -R /opt/Heimdall-2.4.8/public public-backup
  67. else
  68. cp -R /opt/Heimdall/database database-backup
  69. cp -R /opt/Heimdall/public public-backup
  70. fi
  71. sleep 1
  72. msg_ok "Backed up Data"
  73. RELEASE=$(curl -sX GET "https://api.github.com/repos/linuxserver/Heimdall/releases/latest" | awk '/tag_name/{print $4;exit}' FS='[""]')
  74. msg_info "Updating Heimdall Dashboard to ${RELEASE}"
  75. curl --silent -o ${RELEASE}.tar.gz -L "https://github.com/linuxserver/Heimdall/archive/${RELEASE}.tar.gz" &>/dev/null
  76. tar xvzf ${RELEASE}.tar.gz &>/dev/null
  77. VER=$(curl -s https://api.github.com/repos/linuxserver/Heimdall/releases/latest |
  78. grep "tag_name" |
  79. awk '{print substr($2, 3, length($2)-4) }')
  80. if [ ! -d "/opt/Heimdall" ]; then
  81. mv Heimdall-${VER} /opt/Heimdall
  82. else
  83. cp -R Heimdall-${VER}/* /opt/Heimdall
  84. fi
  85. service_path="/etc/systemd/system/heimdall.service"
  86. echo "[Unit]
  87. Description=Heimdall
  88. After=network.target
  89. [Service]
  90. Restart=always
  91. RestartSec=5
  92. Type=simple
  93. User=root
  94. WorkingDirectory=/opt/Heimdall
  95. ExecStart="/usr/bin/php" artisan serve --port 7990 --host 0.0.0.0
  96. TimeoutStopSec=30
  97. [Install]
  98. WantedBy=multi-user.target" >$service_path
  99. msg_ok "Updated Heimdall Dashboard to ${RELEASE}"
  100. msg_info "Restoring Data"
  101. cp -R database-backup/* /opt/Heimdall/database
  102. cp -R public-backup/* /opt/Heimdall/public
  103. sleep 1
  104. msg_ok "Restored Data"
  105. msg_info "Cleanup"
  106. if [ -d "/opt/Heimdall-2.4.6" ]; then
  107. rm -rf /opt/Heimdall-2.4.6
  108. rm -rf /opt/v2.4.6.tar.gz
  109. elif [[ -d "/opt/Heimdall-2.4.7b" ]]; then
  110. rm -rf /opt/Heimdall-2.4.7b
  111. rm -rf /opt/v2.4.7b.tar.gz
  112. elif [[ -d "/opt/Heimdall-2.4.8" ]]; then
  113. rm -rf /opt/Heimdall-2.4.8
  114. rm -rf /opt/v2.4.8.tar.gz
  115. fi
  116. rm -rf ${RELEASE}.tar.gz
  117. rm -rf Heimdall-${VER}
  118. rm -rf public-backup
  119. rm -rf database-backup
  120. rm -rf Heimdall
  121. sleep 1
  122. msg_ok "Cleaned"
  123. msg_info "Starting ${APP}"
  124. systemctl enable --now heimdall.service &>/dev/null
  125. sleep 2
  126. msg_ok "Started ${APP}"
  127. msg_ok "Updated Successfully"
  128. exit
  129. }
  130. start
  131. build_container
  132. description
  133. msg_ok "Completed Successfully!\n"
  134. echo -e "${APP} should be reachable by going to the following URL.
  135. ${BL}http://${IP}:7990${CL} \n"