From 8c09216691e272b4b7c0b3fc9c1518e181f695c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Slavi=C5=A1a=20Are=C5=BEina?= <58952836+tremor021@users.noreply.github.com> Date: Wed, 9 Jul 2025 14:22:41 +0200 Subject: [PATCH] Refactor: Commafeed (#5802) --- ct/commafeed.sh | 17 ++++++++++------- install/commafeed-install.sh | 19 ++----------------- 2 files changed, 12 insertions(+), 24 deletions(-) diff --git a/ct/commafeed.sh b/ct/commafeed.sh index 37cc45d14..f5635a372 100644 --- a/ct/commafeed.sh +++ b/ct/commafeed.sh @@ -23,12 +23,13 @@ function update_script() { header_info check_container_storage check_container_resources + if [[ ! -d /opt/commafeed ]]; then msg_error "No ${APP} Installation Found!" exit fi RELEASE=$(curl -fsSL https://api.github.com/repos/Athou/commafeed/releases/latest | grep '"tag_name":' | cut -d'"' -f4) - if [[ ! -f /opt/${APP}_version.txt ]] || [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]]; then + if [[ "${RELEASE}" != "$(cat ~/.commafeed 2>/dev/null)" ]] || [[ ! -f ~/.commafeed ]]; then msg_info "Stopping ${APP}" systemctl stop commafeed msg_ok "Stopped ${APP}" @@ -39,13 +40,15 @@ function update_script() { $STD apt-get install -y rsync msg_ok "Installed Dependencies" fi - + if [ -d /opt/commafeed/data ] && [ "$(ls -A /opt/commafeed/data)" ]; then + mv /opt/commafeed/data /opt/data.bak + fi + fetch_and_deploy_gh_release "commafeed" "Athou/commafeed" "prebuild" "latest" "/opt/commafeed" "commafeed-*-h2-jvm.zip" + msg_info "Updating ${APP} to ${RELEASE}" - curl -fsSL "https://github.com/Athou/commafeed/releases/download/${RELEASE}/commafeed-${RELEASE}-h2-jvm.zip" -o $(basename "https://github.com/Athou/commafeed/releases/download/${RELEASE}/commafeed-${RELEASE}-h2-jvm.zip") - $STD unzip commafeed-"${RELEASE}"-h2-jvm.zip - rsync -a --exclude 'data/' commafeed-"${RELEASE}"-h2/ /opt/commafeed/ - rm -rf commafeed-"${RELEASE}"-h2 commafeed-"${RELEASE}"-h2-jvm.zip - echo "${RELEASE}" >/opt/${APP}_version.txt + if [ -d /opt/commafeed/data.bak ] && [ "$(ls -A /opt/commafeed/data.bak)" ]; then + mv /opt/commafeed/data.bak /opt/commafeed/data + fi msg_ok "Updated ${APP} to ${RELEASE}" msg_info "Starting ${APP}" diff --git a/install/commafeed-install.sh b/install/commafeed-install.sh index 5162ab4ab..fb1154ccd 100644 --- a/install/commafeed-install.sh +++ b/install/commafeed-install.sh @@ -17,22 +17,8 @@ msg_info "Installing Dependencies" $STD apt-get install -y rsync msg_ok "Installed Dependencies" -msg_info "Installing Azul Zulu" -curl -fsSL "https://keyserver.ubuntu.com/pks/lookup?op=get&search=0xB1998361219BD9C9" -o "/etc/apt/trusted.gpg.d/zulu-repo.asc" -curl -fsSL "https://cdn.azul.com/zulu/bin/zulu-repo_1.0.0-3_all.deb" -o "zulu-repo_1.0.0-3_all.deb" -$STD dpkg -i zulu-repo_1.0.0-3_all.deb -$STD apt-get update -$STD apt-get -y install zulu17-jdk -msg_ok "Installed Azul Zulu" - -RELEASE=$(curl -fsSL https://api.github.com/repos/Athou/commafeed/releases/latest | grep '"tag_name":' | cut -d'"' -f4) -msg_info "Installing CommaFeed ${RELEASE}" -mkdir /opt/commafeed -curl -fsSL "https://github.com/Athou/commafeed/releases/download/${RELEASE}/commafeed-${RELEASE}-h2-jvm.zip" -o "commafeed-${RELEASE}-h2-jvm.zip" -$STD unzip commafeed-${RELEASE}-h2-jvm.zip -mv commafeed-${RELEASE}-h2/* /opt/commafeed/ -echo "${RELEASE}" >/opt/${APPLICATION}_version.txt -msg_ok "Installed CommaFeed ${RELEASE}" +JAVA_VERSION="17" setup_java +fetch_and_deploy_gh_release "commafeed" "Athou/commafeed" "prebuild" "latest" "/opt/commafeed" "commafeed-*-h2-jvm.zip" msg_info "Creating Service" cat </etc/systemd/system/commafeed.service @@ -55,7 +41,6 @@ motd_ssh customize msg_info "Cleaning up" -rm -rf commafeed-${RELEASE}-h2 commafeed-${RELEASE}-h2-jvm.zip zulu-repo_1.0.0-3_all.deb $STD apt-get -y autoremove $STD apt-get -y autoclean msg_ok "Cleaned"