From 1fb93b326fd028b7fb15fd7d6a6e5f245e787be6 Mon Sep 17 00:00:00 2001 From: tteckster Date: Sun, 21 Apr 2024 23:11:42 -0400 Subject: [PATCH] Update dashy.sh Update `function update_script()` --- ct/dashy.sh | 65 +++++++++++++++++++++++++++++++---------------------- 1 file changed, 38 insertions(+), 27 deletions(-) diff --git a/ct/dashy.sh b/ct/dashy.sh index b06a3955..314802db 100644 --- a/ct/dashy.sh +++ b/ct/dashy.sh @@ -55,38 +55,49 @@ function default_settings() { function update_script() { header_info if [[ ! -d /opt/dashy/public/ ]]; then msg_error "No ${APP} Installation Found!"; exit; fi -msg_error "There is currently no update path available." -exit -msg_info "Stopping ${APP}" -systemctl stop dashy -msg_ok "Stopped ${APP}" -msg_info "Backing up conf.yml" -cd ~ -cp -R /opt/dashy/public/conf.yml conf.yml -msg_ok "Backed up conf.yml" +RELEASE=$(curl -sL https://api.github.com/repos/Lissy93/dashy/releases/latest | grep '"tag_name":' | cut -d'"' -f4) +if [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]] || [[ ! -f /opt/${APP}_version.txt ]]; then + msg_info "Stopping ${APP}" + systemctl stop dashy + msg_ok "Stopped ${APP}" -msg_info "Updating Dashy" -cd /opt/dashy -git merge &>/dev/null -git pull origin master &>/dev/null -yarn &>/dev/null -yarn build &>/dev/null -msg_ok "Updated Dashy" + msg_info "Backing up conf.yml" + cd ~ + if [[ -f /opt/dashy/public/conf.yml ]]; then + cp -R /opt/dashy/public/conf.yml conf.yml + else + cp -R /opt/dashy/user-data/conf.yml conf.yml + fi + msg_ok "Backed up conf.yml" -msg_info "Restoring conf.yml" -cd ~ -cp -R conf.yml /opt/dashy/public -msg_ok "Restored conf.yml" + msg_info "Updating ${APP} to ${RELEASE}" + rm -rf /opt/dashy + mkdir -p /opt/dashy + wget -qO- https://github.com/Lissy93/dashy/archive/refs/tags/${RELEASE}.tar.gz | tar -xz -C /opt/dashy --strip-components=1 + sed -i 's/NODE_OPTIONS=--openssl-legacy-provider vue-cli-service build/NODE_OPTIONS=yarn vue-cli-service build/' /opt/dashy/package.json + cd /opt/dashy + yarn &>/dev/null + yarn build &>/dev/null + echo "${RELEASE}" >/opt/${APP}_version.txt + msg_ok "Updated ${APP} to ${RELEASE}" -msg_info "Cleaning" -rm -rf conf.yml -msg_ok "Cleaned" + msg_info "Restoring conf.yml" + cd ~ + cp -R conf.yml /opt/dashy/user-data + msg_ok "Restored conf.yml" -msg_info "Starting Dashy" -systemctl start dashy -msg_ok "Started Dashy" -msg_ok "Updated Successfully" + msg_info "Cleaning" + rm -rf conf.yml /opt/dashy/public/conf.yml + msg_ok "Cleaned" + + msg_info "Starting Dashy" + systemctl start dashy + msg_ok "Started Dashy" + msg_ok "Updated Successfully" +else + msg_ok "No update required. ${APP} is already at ${RELEASE}" +fi exit }