From dc5fcb83e8f9278f1a33fbc24347cb8a2142ffa5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Slavi=C5=A1a=20Are=C5=BEina?= <58952836+tremor021@users.noreply.github.com> Date: Mon, 4 Aug 2025 14:38:48 +0200 Subject: [PATCH] Refactor (#6548) --- ct/nocodb.sh | 27 ++++++++++++++++++--------- install/nocodb-install.sh | 12 ++++-------- 2 files changed, 22 insertions(+), 17 deletions(-) diff --git a/ct/nocodb.sh b/ct/nocodb.sh index 6e98d8ae7..fe028d9de 100644 --- a/ct/nocodb.sh +++ b/ct/nocodb.sh @@ -27,15 +27,24 @@ function update_script() { msg_error "No ${APP} Installation Found!" exit fi - msg_info "Updating ${APP}" - systemctl stop nocodb.service - cd /opt/nocodb - rm -rf nocodb - curl -fsSL http://get.nocodb.com/linux-x64 -o nocodb -L - chmod +x nocodb - systemctl start nocodb.service + + RELEASE=$(curl -fsSL https://api.github.com/repos/nocodb/nocodb/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }') + if [[ ! -f ~/.nocodb ]] || [[ "${RELEASE}" != "$(cat ~/.nocodb)" ]]; then + msg_info "Stopping Service" + systemctl stop nocodb + msg_ok "Stopped Service" + + fetch_and_deploy_gh_release "nocodb" "nocodb/nocodb" "singlefile" "latest" "/opt/nocodb/" "Noco-linux-x64" + + msg_info "Starting Service" + systemctl start nocodb + msg_ok "Started Service" + msg_ok "Updated Successfully" - exit + else + msg_ok "No update required. ${APP} is already at v${RELEASE}" + fi + exit } start @@ -45,4 +54,4 @@ description msg_ok "Completed Successfully!\n" echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}" echo -e "${INFO}${YW} Access it using the following URL:${CL}" -echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:8080/dashboard${CL}" \ No newline at end of file +echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:8080/dashboard${CL}" diff --git a/install/nocodb-install.sh b/install/nocodb-install.sh index a901609cf..e24bd2e89 100644 --- a/install/nocodb-install.sh +++ b/install/nocodb-install.sh @@ -13,15 +13,10 @@ setting_up_container network_check update_os -msg_info "Installing NocoDB" -mkdir -p /opt/nocodb -cd /opt/nocodb -curl -fsSL http://get.nocodb.com/linux-x64 -o nocodb -L -chmod +x nocodb -msg_ok "Installed NocoDB" +fetch_and_deploy_gh_release "nocodb" "nocodb/nocodb" "singlefile" "latest" "/opt/nocodb/" "Noco-linux-x64" msg_info "Creating Service" -service_path="/etc/systemd/system/nocodb.service" +cat </etc/systemd/system/nocodb.service echo "[Unit] Description=nocodb @@ -33,7 +28,8 @@ WorkingDirectory=/opt/nocodb ExecStart=/opt/nocodb/./nocodb [Install] -WantedBy=multi-user.target" >$service_path +WantedBy=multi-user.target +EOF systemctl enable -q --now nocodb msg_ok "Created Service"