Switched to release crawling.

This commit is contained in:
Johanna Rührig 2025-01-01 19:42:51 +01:00
parent 933df2556d
commit 123cc7cde4
2 changed files with 32 additions and 25 deletions

View File

@ -35,28 +35,34 @@ function update_script() {
exit
fi
# Crawling the new version and checking whether an update is required
msg_info "Updating System"
apt-get update &>/dev/null
apt-get -y upgrade &>/dev/null
msg_ok "Updated System"
RELEASE=$(curl -s https://api.github.com/repos/Pf2eToolsOrg/Pf2eTools/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }')
if [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]] || [[ ! -f "/opt/${APP}_version.txt" ]]; then
# Crawling the new version and checking whether an update is required
msg_info "Updating System"
apt-get update &>/dev/null
apt-get -y upgrade &>/dev/null
msg_ok "Updated System"
# Execute Update
msg_info "Updating ${APP}"
cd "/opt/${APP}"
git config --global http.postBuffer 1048576000
git config --global https.postBuffer 1048576000
git pull --recurse-submodules --jobs=10
msg_ok "Updated ${APP}"
# Execute Update
msg_info "Updating ${APP}"
cd "/opt/${APP}"
wget -q "https://github.com/Pf2eToolsOrg/Pf2eTools/archive/refs/tags/${RELEASE}.zip"
unzip "${RELEASE}.zip" -d /opt/${APP}
echo "${RELEASE}" >/opt/${APP}_version.txt
msg_ok "Updated ${APP}"
chown -R www-data: "/opt/${APP}"
chmod -R 755 "/opt/${APP}"
chown -R www-data: "/opt/${APP}"
chmod -R 755 "/opt/${APP}"
# Cleaning up
msg_info "Cleaning Up"
$STD apt-get -y autoremove
$STD apt-get -y autoclean
msg_ok "Cleanup Completed"
# Cleaning up
msg_info "Cleaning Up"
rm "${RELEASE}.zip"
$STD apt-get -y autoremove
$STD apt-get -y autoclean
msg_ok "Cleanup Completed"
else
msg_ok "No update required. ${APP} is already at ${RELEASE}"
fi
exit
}
@ -67,4 +73,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}${CL}"
echo -e "${TAB}${GATEWAY}${BGN}http://${IP}${CL}"

View File

@ -19,16 +19,16 @@ $STD apt-get install -y \
curl \
mc \
sudo \
git \
unzip \
apache2
msg_ok "Installed Dependencies"
# Setup App
msg_info "Setup Pf2eTools"
rm -rf /var/www/html
git config --global http.postBuffer 1048576000
git config --global https.postBuffer 1048576000
git clone https://github.com/Pf2eToolsOrg/Pf2eTools /opt/Pf2eTools
RELEASE=$(curl -s https://api.github.com/repos/Pf2eToolsOrg/Pf2eTools/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }')
wget -q "https://github.com/Pf2eToolsOrg/Pf2eTools/archive/refs/tags/${RELEASE}.zip"
unzip "${RELEASE}.zip" -d /opt/Pf2eTools
echo "${RELEASE}" >/opt/Pf2eTools_version.txt
msg_ok "Set up Pf2eTools"
msg_info "Creating Service"
@ -47,6 +47,7 @@ apache2ctl start
msg_ok "Creating Service"
# Cleanup
msg_info "Cleaning up"
rm "${RELEASE}.zip"
$STD apt-get -y autoremove
$STD apt-get -y autoclean
msg_ok "Cleaned"