From 2ead98c4807de66e9e77f28734fd24add2dd023a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Slavi=C5=A1a=20Are=C5=BEina?= <58952836+tremor021@users.noreply.github.com> Date: Fri, 22 Aug 2025 14:11:23 +0200 Subject: [PATCH] Refactor: Silverbullet (#7082) * Refactor * Update silverbullet.sh --- ct/silverbullet.sh | 11 +++-------- install/silverbullet-install.sh | 13 ++----------- 2 files changed, 5 insertions(+), 19 deletions(-) diff --git a/ct/silverbullet.sh b/ct/silverbullet.sh index d6a3f3876..3d8414daf 100644 --- a/ct/silverbullet.sh +++ b/ct/silverbullet.sh @@ -26,19 +26,14 @@ function update_script() { msg_error "No ${APP} Installation Found!" exit fi + RELEASE=$(curl -fsSL https://api.github.com/repos/silverbulletmd/silverbullet/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }') - if [[ ! -f "/opt/${APP}_version.txt" || "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]]; then + if [[ ! -f ~/.silverbullet || "${RELEASE}" != "$(cat ~/.silverbullet 2>/dev/null)" ]]; then msg_info "Stopping ${APP}" systemctl stop silverbullet msg_ok "Stopped ${APP}" - msg_info "Updating ${APP} to v${RELEASE}" - curl -fsSL "https://github.com/silverbulletmd/silverbullet/releases/download/${RELEASE}/silverbullet-server-linux-x86_64.zip" -o $(basename "https://github.com/silverbulletmd/silverbullet/releases/download/${RELEASE}/silverbullet-server-linux-x86_64.zip") - $STD unzip silverbullet-server-linux-x86_64.zip - mv silverbullet /opt/silverbullet/bin/ - chmod +x /opt/silverbullet/bin/silverbullet - echo "${RELEASE}" >/opt/silverbullet/${APP}_version.txt - msg_ok "Updated ${APP} to v${RELEASE}" + fetch_and_deploy_gh_release "silverbullet" "silverbulletmd/silverbullet" "prebuild" "latest" "/opt/silverbullet/bin" "silverbullet-server-linux-x86_64.zip" msg_info "Starting ${APP}" systemctl start silverbullet diff --git a/install/silverbullet-install.sh b/install/silverbullet-install.sh index beb1aa4ea..64e211ef2 100644 --- a/install/silverbullet-install.sh +++ b/install/silverbullet-install.sh @@ -13,18 +13,10 @@ setting_up_container network_check update_os -msg_info "Installing Silverbullet" -RELEASE=$(curl -fsSL https://api.github.com/repos/silverbulletmd/silverbullet/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }') -mkdir -p /opt/silverbullet/bin /opt/silverbullet/space -cd /opt -curl -fsSL "https://github.com/silverbulletmd/silverbullet/releases/download/${RELEASE}/silverbullet-server-linux-x86_64.zip" -o "silverbullet-server-linux-x86_64.zip" -$STD unzip -o -d /opt/silverbullet/bin/ silverbullet-server-linux-x86_64.zip -chmod +x /opt/silverbullet/bin/silverbullet -echo "${RELEASE}" >/opt/${APPLICATION}_version.txt -msg_ok "Installed Silverbullet" +fetch_and_deploy_gh_release "silverbullet" "silverbulletmd/silverbullet" "prebuild" "latest" "/opt/silverbullet/bin" "silverbullet-server-linux-x86_64.zip" +mkdir -p /opt/silverbullet/space msg_info "Creating Service" - cat </etc/systemd/system/silverbullet.service [Unit] Description=Silverbullet Daemon @@ -47,7 +39,6 @@ motd_ssh customize msg_info "Cleaning up" -rm -rf /opt/silverbullet-server-linux-x86_64.zip $STD apt-get -y autoremove $STD apt-get -y autoclean msg_ok "Cleaned"