Skip to content

Commit 3d69931

Browse files
authored
Refactor: Mafl (#5702)
* Refactor: Mafl * Update mafl.sh
1 parent 3e504cf commit 3d69931

File tree

2 files changed

+28
-20
lines changed

2 files changed

+28
-20
lines changed

ct/mafl.sh

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,31 @@ function update_script() {
2727
msg_error "No ${APP} Installation Found!"
2828
exit
2929
fi
30+
3031
RELEASE=$(curl -fsSL https://api.github.com/repos/hywax/mafl/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
31-
msg_info "Updating Mafl to v${RELEASE} (Patience)"
32-
systemctl stop mafl
33-
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")
34-
tar -xzf v${RELEASE}.tar.gz
35-
cp -r mafl-${RELEASE}/* /opt/mafl/
36-
rm -rf mafl-${RELEASE}
37-
cd /opt/mafl
38-
yarn install
39-
yarn build
40-
systemctl start mafl
41-
msg_ok "Updated Mafl to v${RELEASE}"
32+
if [[ "${RELEASE}" != "$(cat ~/.mafl 2>/dev/null)" ]] || [[ ! -f ~/.mafl ]]; then
33+
msg_info "Stopping Mafl service"
34+
systemctl stop mafl
35+
msg_ok "Service stopped"
36+
37+
msg_info "Performing backup"
38+
mkdir -p /opt/mafl-backup/data
39+
mv /opt/mafl/data /opt/mafl-backup/data
40+
rm /opt/mafl
41+
msg_ok "Backup complete"
42+
43+
fetch_and_deploy_gh_release "mafl" "hywax/mafl"
44+
45+
msg_info "Updating Mafl to v${RELEASE}"
46+
cd /opt/mafl
47+
yarn install
48+
yarn build
49+
systemctl start mafl
50+
mv /opt/mafl-backup/data /opt/mafl/data
51+
msg_ok "Updated Mafl to v${RELEASE}"
52+
else
53+
msg_ok "No update required. ${APP} is already at v${RELEASE}"
54+
fi
4255
exit
4356
}
4457

install/mafl-install.sh

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,17 @@ network_check
1414
update_os
1515

1616
msg_info "Installing Dependencies"
17-
$STD apt-get install -y make
18-
$STD apt-get install -y g++
19-
$STD apt-get install -y gcc
20-
$STD apt-get install -y ca-certificates
17+
$STD apt-get install -y \
18+
ca-certificates \
19+
build-essential
2120
msg_ok "Installed Dependencies"
2221

2322
NODE_VERSION="22" NODE_MODULE="yarn@latest" setup_nodejs
23+
fetch_and_deploy_gh_release "mafl" "hywax/mafl"
2424

25-
RELEASE=$(curl -fsSL https://api.github.com/repos/hywax/mafl/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
2625
msg_info "Installing Mafl v${RELEASE}"
27-
curl -fsSL "https://github.com/hywax/mafl/archive/refs/tags/v${RELEASE}.tar.gz" -o "v${RELEASE}.tar.gz"
28-
tar -xzf v${RELEASE}.tar.gz
2926
mkdir -p /opt/mafl/data
3027
curl -fsSL "https://raw.githubusercontent.com/hywax/mafl/main/.example/config.yml" -o "/opt/mafl/data/config.yml"
31-
mv mafl-${RELEASE}/* /opt/mafl
32-
rm -rf mafl-${RELEASE}
3328
cd /opt/mafl
3429
export NUXT_TELEMETRY_DISABLED=true
3530
$STD yarn install

0 commit comments

Comments
 (0)