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 exit
fi fi
# Crawling the new version and checking whether an update is required RELEASE=$(curl -s https://api.github.com/repos/Pf2eToolsOrg/Pf2eTools/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }')
msg_info "Updating System" if [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]] || [[ ! -f "/opt/${APP}_version.txt" ]]; then
apt-get update &>/dev/null # Crawling the new version and checking whether an update is required
apt-get -y upgrade &>/dev/null msg_info "Updating System"
msg_ok "Updated System" apt-get update &>/dev/null
apt-get -y upgrade &>/dev/null
msg_ok "Updated System"
# Execute Update # Execute Update
msg_info "Updating ${APP}" msg_info "Updating ${APP}"
cd "/opt/${APP}" cd "/opt/${APP}"
git config --global http.postBuffer 1048576000 wget -q "https://github.com/Pf2eToolsOrg/Pf2eTools/archive/refs/tags/${RELEASE}.zip"
git config --global https.postBuffer 1048576000 unzip "${RELEASE}.zip" -d /opt/${APP}
git pull --recurse-submodules --jobs=10 echo "${RELEASE}" >/opt/${APP}_version.txt
msg_ok "Updated ${APP}" msg_ok "Updated ${APP}"
chown -R www-data: "/opt/${APP}" chown -R www-data: "/opt/${APP}"
chmod -R 755 "/opt/${APP}" chmod -R 755 "/opt/${APP}"
# Cleaning up # Cleaning up
msg_info "Cleaning Up" msg_info "Cleaning Up"
$STD apt-get -y autoremove rm "${RELEASE}.zip"
$STD apt-get -y autoclean $STD apt-get -y autoremove
msg_ok "Cleanup Completed" $STD apt-get -y autoclean
msg_ok "Cleanup Completed"
else
msg_ok "No update required. ${APP} is already at ${RELEASE}"
fi
exit exit
} }
@ -67,4 +73,4 @@ description
msg_ok "Completed Successfully!\n" msg_ok "Completed Successfully!\n"
echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}" echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}"
echo -e "${INFO}${YW} Access it using the following URL:${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 \ curl \
mc \ mc \
sudo \ sudo \
git \ unzip \
apache2 apache2
msg_ok "Installed Dependencies" msg_ok "Installed Dependencies"
# Setup App # Setup App
msg_info "Setup Pf2eTools" msg_info "Setup Pf2eTools"
rm -rf /var/www/html RELEASE=$(curl -s https://api.github.com/repos/Pf2eToolsOrg/Pf2eTools/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }')
git config --global http.postBuffer 1048576000 wget -q "https://github.com/Pf2eToolsOrg/Pf2eTools/archive/refs/tags/${RELEASE}.zip"
git config --global https.postBuffer 1048576000 unzip "${RELEASE}.zip" -d /opt/Pf2eTools
git clone https://github.com/Pf2eToolsOrg/Pf2eTools /opt/Pf2eTools echo "${RELEASE}" >/opt/Pf2eTools_version.txt
msg_ok "Set up Pf2eTools" msg_ok "Set up Pf2eTools"
msg_info "Creating Service" msg_info "Creating Service"
@ -47,6 +47,7 @@ apache2ctl start
msg_ok "Creating Service" msg_ok "Creating Service"
# Cleanup # Cleanup
msg_info "Cleaning up" msg_info "Cleaning up"
rm "${RELEASE}.zip"
$STD apt-get -y autoremove $STD apt-get -y autoremove
$STD apt-get -y autoclean $STD apt-get -y autoclean
msg_ok "Cleaned" msg_ok "Cleaned"