Skip to content

Commit 07394b9

Browse files
authored
Refactor (#7096)
1 parent 1fce2de commit 07394b9

File tree

2 files changed

+9
-20
lines changed

2 files changed

+9
-20
lines changed

ct/pf2etools.sh

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,30 +29,25 @@ function update_script() {
2929
exit
3030
fi
3131

32-
RELEASE=$(curl -fsSL https://api.github.com/repos/Pf2eToolsOrg/Pf2eTools/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }')
33-
if [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]] || [[ ! -f "/opt/${APP}_version.txt" ]]; then
32+
RELEASE=$(curl -fsSL https://api.github.com/repos/Pf2eToolsOrg/Pf2eTools/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
33+
if [[ "${RELEASE}" != "$(cat ~/.pf2etools 2>/dev/null)" ]] || [[ ! -f ~/.pf2etools ]]; then
3434
msg_info "Updating System"
3535
$STD apt-get update
3636
$STD apt-get -y upgrade
3737
msg_ok "Updated System"
3838

39+
rm -rf /opt/Pf2eTools
40+
fetch_and_deploy_gh_release "pf2etools" "Pf2eToolsOrg/Pf2eTools" "tarball" "latest" "/opt/Pf2eTools"
41+
3942
msg_info "Updating ${APP}"
40-
cd /opt
41-
curl -fsSL "https://github.com/Pf2eToolsOrg/Pf2eTools/archive/refs/tags/${RELEASE}.zip" -o $(basename "https://github.com/Pf2eToolsOrg/Pf2eTools/archive/refs/tags/${RELEASE}.zip")
42-
$STD unzip ${RELEASE}.zip
43-
rm -rf "/opt/${APP}"
44-
mv ${APP}-${RELEASE:1} /opt/${APP}
4543
cd /opt/Pf2eTools
4644
$STD npm install
4745
$STD npm run build
4846
chown -R www-data: "/opt/${APP}"
4947
chmod -R 755 "/opt/${APP}"
50-
echo "${RELEASE}" >"/opt/${APP}_version.txt"
5148
msg_ok "Updated ${APP}"
5249

53-
msg_info "Cleaning Up"
54-
rm -rf /opt/${RELEASE}.zip
55-
msg_ok "Cleanup Completed"
50+
msg_ok "Updated successfully"
5651
else
5752
msg_ok "No update required. ${APP} is already at ${RELEASE}"
5853
fi

install/pf2etools-install.sh

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,13 @@ $STD apt-get install -y \
2121
msg_ok "Installed Dependencies"
2222

2323
NODE_VERSION="22" setup_nodejs
24+
fetch_and_deploy_gh_release "pf2etools" "Pf2eToolsOrg/Pf2eTools" "tarball" "latest" "/opt/Pf2eTools"
2425

25-
msg_info "Setup Pf2eTools"
26-
cd /opt
27-
RELEASE=$(curl -fsSL https://api.github.com/repos/Pf2eToolsOrg/Pf2eTools/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }')
28-
curl -fsSL "https://github.com/Pf2eToolsOrg/Pf2eTools/archive/refs/tags/${RELEASE}.zip" -o "${RELEASE}.zip"
29-
$STD unzip "${RELEASE}.zip"
30-
mv "Pf2eTools-${RELEASE:1}" /opt/Pf2eTools
26+
msg_info "Configuring Pf2eTools"
3127
cd /opt/Pf2eTools
3228
$STD npm install
3329
$STD npm run build
34-
echo "${RELEASE}" >/opt/Pf2eTools_version.txt
35-
msg_ok "Set up Pf2eTools"
30+
msg_ok "Configured Pf2eTools"
3631

3732
msg_info "Creating Service"
3833
cat <<EOF >>/etc/apache2/apache2.conf
@@ -49,7 +44,6 @@ chmod -R 755 "/opt/Pf2eTools"
4944
msg_ok "Created Service"
5045

5146
msg_info "Cleaning up"
52-
rm -rf /opt/${RELEASE}.zip
5347
$STD apt-get -y autoremove
5448
$STD apt-get -y autoclean
5549
msg_ok "Cleaned"

0 commit comments

Comments
 (0)