From aafdd1a84216dd92fc77a940decabc9beea92b31 Mon Sep 17 00:00:00 2001 From: CanbiZ <47820557+MickLesk@users.noreply.github.com> Date: Thu, 7 Nov 2024 20:03:35 +0100 Subject: [PATCH] [Bug] | [Change]: Homarr (+Script harmonized) --- ct/homarr.sh | 46 +++++++++++++++++++++++++++------------ install/homarr-install.sh | 13 +++++++---- 2 files changed, 41 insertions(+), 18 deletions(-) diff --git a/ct/homarr.sh b/ct/homarr.sh index dcb55148..e62ce175 100644 --- a/ct/homarr.sh +++ b/ct/homarr.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash source <(curl -s https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func) # Copyright (c) 2021-2024 tteck -# Author: tteck (tteckster) +# Author: MickLesk (Canbiz) # License: MIT # https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE @@ -54,20 +54,38 @@ function default_settings() { function update_script() { header_info -if [[ ! -d /opt/homarr ]]; then msg_error "No ${APP} Installation Found!"; exit; fi -msg_info "Updating $APP (Patience)" -systemctl stop homarr -cd /opt/homarr -if ! git pull; then - echo "Already up to date." - systemctl start homarr - echo "No update required." - exit +if [[ ! -d /opt/adventurelog ]]; then msg_error "No ${APP} Installation Found!"; exit; fi +if (( $(df /boot | awk 'NR==2{gsub("%","",$5); print $5}') > 80 )); then + read -r -p "Warning: Storage is dangerously low, continue anyway? " prompt + [[ ${prompt,,} =~ ^(y|yes)$ ]] || exit +fi +RELEASE=$(curl -s https://api.github.com/repos/ajnart/homarr/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }') +if [[ ! -f /opt/${APP}_version.txt ]] || [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]]; then + msg_info "Stopping Services" + systemctl stop homarr + msg_ok "Services Stopped" + + msg_info "Updating ${APP} to ${RELEASE}" + cp /opt/homarr/.env /opt/.env + wget -q "https://github.com/ajnart/homarr/archive/refs/tags/v${RELEASE}.zip" + unzip -q v${RELEASE}.zip + mv homarr-${RELEASE} /opt/homarr + mv /opt/.env /opt/homarr/.env + yarn install + yarn build + yarn db:migrate + + msg_info "Starting Services" + systemctl start homarr + msg_ok "Started Services" + + msg_info "Cleaning Up" + rm -rf v${RELEASE}.zip + msg_ok "Cleaned" + msg_ok "Updated Successfully" +else + msg_ok "No update required. ${APP} is already at ${RELEASE}" fi -yarn install -yarn build -systemctl start homarr -msg_ok "Updated $APP" exit } diff --git a/install/homarr-install.sh b/install/homarr-install.sh index 791c37a7..30a3ae6a 100644 --- a/install/homarr-install.sh +++ b/install/homarr-install.sh @@ -1,9 +1,10 @@ #!/usr/bin/env bash # Copyright (c) 2021-2024 tteck -# Author: tteck (tteckster) +# Author: MickLesk (Canbiz) # License: MIT # https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE +# Source: https://github.com/ajnart/homarr source /dev/stdin <<< "$FUNCTIONS_FILE_PATH" color @@ -17,7 +18,6 @@ msg_info "Installing Dependencies" $STD apt-get install -y curl $STD apt-get install -y sudo $STD apt-get install -y mc -$STD apt-get install -y git $STD apt-get install -y ca-certificates $STD apt-get install -y gnupg msg_ok "Installed Dependencies" @@ -31,12 +31,15 @@ msg_ok "Set up Node.js Repository" msg_info "Installing Node.js/Yarn" $STD apt-get update $STD apt-get install -y nodejs -$STD npm install -g npm@latest $STD npm install -g yarn msg_ok "Installed Node.js/Yarn" msg_info "Installing Homarr (Patience)" -$STD git clone -b dev https://github.com/ajnart/homarr.git /opt/homarr +cd /opt +RELEASE=$(curl -s https://api.github.com/repos/ajnart/homarr/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }') +wget -q "https://github.com/ajnart/homarr/archive/refs/tags/v${RELEASE}.zip" +unzip -q v${RELEASE}.zip +mv homarr-${RELEASE} /opt/homarr cat </opt/homarr/.env DATABASE_URL="file:./database/db.sqlite" NEXTAUTH_URL="http://localhost:3000" @@ -48,6 +51,7 @@ cd /opt/homarr $STD yarn install $STD yarn build $STD yarn db:migrate +echo "${RELEASE}" >"/opt/${APPLICATION}_version.txt" msg_ok "Installed Homarr" msg_info "Creating Service" @@ -72,6 +76,7 @@ motd_ssh customize msg_info "Cleaning up" +rm -rf /opt/v${RELEASE}.zip $STD apt-get -y autoremove $STD apt-get -y autoclean msg_ok "Cleaned"