From 3d699316750f99c90b9913ee6b43aa89a286ad94 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, 4 Jul 2025 22:24:12 +0200 Subject: [PATCH] Refactor: Mafl (#5702) * Refactor: Mafl * Update mafl.sh --- ct/mafl.sh | 35 ++++++++++++++++++++++++----------- install/mafl-install.sh | 13 ++++--------- 2 files changed, 28 insertions(+), 20 deletions(-) diff --git a/ct/mafl.sh b/ct/mafl.sh index aafb60b50..2d30c6674 100644 --- a/ct/mafl.sh +++ b/ct/mafl.sh @@ -27,18 +27,31 @@ function update_script() { msg_error "No ${APP} Installation Found!" exit fi + RELEASE=$(curl -fsSL https://api.github.com/repos/hywax/mafl/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }') - msg_info "Updating Mafl to v${RELEASE} (Patience)" - systemctl stop mafl - curl -fsSL "https://github.com/hywax/mafl/archive/refs/tags/v${RELEASE}.tar.gz" -o $(basename "https://github.com/hywax/mafl/archive/refs/tags/v${RELEASE}.tar.gz") - tar -xzf v${RELEASE}.tar.gz - cp -r mafl-${RELEASE}/* /opt/mafl/ - rm -rf mafl-${RELEASE} - cd /opt/mafl - yarn install - yarn build - systemctl start mafl - msg_ok "Updated Mafl to v${RELEASE}" + if [[ "${RELEASE}" != "$(cat ~/.mafl 2>/dev/null)" ]] || [[ ! -f ~/.mafl ]]; then + msg_info "Stopping Mafl service" + systemctl stop mafl + msg_ok "Service stopped" + + msg_info "Performing backup" + mkdir -p /opt/mafl-backup/data + mv /opt/mafl/data /opt/mafl-backup/data + rm /opt/mafl + msg_ok "Backup complete" + + fetch_and_deploy_gh_release "mafl" "hywax/mafl" + + msg_info "Updating Mafl to v${RELEASE}" + cd /opt/mafl + yarn install + yarn build + systemctl start mafl + mv /opt/mafl-backup/data /opt/mafl/data + msg_ok "Updated Mafl to v${RELEASE}" + else + msg_ok "No update required. ${APP} is already at v${RELEASE}" + fi exit } diff --git a/install/mafl-install.sh b/install/mafl-install.sh index 574949dbb..47cf7bbb6 100644 --- a/install/mafl-install.sh +++ b/install/mafl-install.sh @@ -14,22 +14,17 @@ network_check update_os msg_info "Installing Dependencies" -$STD apt-get install -y make -$STD apt-get install -y g++ -$STD apt-get install -y gcc -$STD apt-get install -y ca-certificates +$STD apt-get install -y \ + ca-certificates \ + build-essential msg_ok "Installed Dependencies" NODE_VERSION="22" NODE_MODULE="yarn@latest" setup_nodejs +fetch_and_deploy_gh_release "mafl" "hywax/mafl" -RELEASE=$(curl -fsSL https://api.github.com/repos/hywax/mafl/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }') msg_info "Installing Mafl v${RELEASE}" -curl -fsSL "https://github.com/hywax/mafl/archive/refs/tags/v${RELEASE}.tar.gz" -o "v${RELEASE}.tar.gz" -tar -xzf v${RELEASE}.tar.gz mkdir -p /opt/mafl/data curl -fsSL "https://raw.githubusercontent.com/hywax/mafl/main/.example/config.yml" -o "/opt/mafl/data/config.yml" -mv mafl-${RELEASE}/* /opt/mafl -rm -rf mafl-${RELEASE} cd /opt/mafl export NUXT_TELEMETRY_DISABLED=true $STD yarn install