This commit is contained in:
Jesper Dramsch 2025-01-09 10:58:49 +01:00 committed by GitHub
commit ddabb8bf1f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -34,25 +34,27 @@ function update_script() {
fi fi
RELEASE=$(curl -s https://api.github.com/repos/seanmorley15/AdventureLog/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }') RELEASE=$(curl -s https://api.github.com/repos/seanmorley15/AdventureLog/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
if [[ ! -f /opt/${APP}_version.txt ]] || [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]]; then if [[ ! -f /opt/${APP}_version.txt ]] || [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]]; then
LAST_VERSION=$(cat /opt/${APP}_version.txt)
msg_info "Stopping Services" msg_info "Stopping Services"
systemctl stop adventurelog-backend systemctl stop adventurelog-backend
systemctl stop adventurelog-frontend systemctl stop adventurelog-frontend
msg_ok "Services Stopped" msg_ok "Services Stopped"
msg_info "Updating ${APP} to ${RELEASE}" msg_info "Updating ${APP} to ${RELEASE}"
cp /opt/adventurelog/backend/server/.env /opt/server.env mv /opt/adventurelog/ /opt/adventurelog-backup/
cp /opt/adventurelog/frontend/.env /opt/frontend.env wget -qO /opt/v${RELEASE}.zip "https://github.com/seanmorley15/AdventureLog/archive/refs/tags/v${RELEASE}.zip"
wget -q "https://github.com/seanmorley15/AdventureLog/archive/refs/tags/v${RELEASE}.zip" unzip -q /opt/v${RELEASE}.zip
unzip -q v${RELEASE}.zip mv /opt/AdventureLog-${RELEASE} /opt/adventurelog
mv AdventureLog-${RELEASE} /opt/adventurelog
mv /opt/server.env /opt/adventurelog/backend/server/.env mv /opt/adventurelog-backup/backend/server/.env /opt/adventurelog/backend/server/.env
mv /opt/adventurelog-backup/backend/server/media /opt/adventurelog/backend/server/media
cd /opt/adventurelog/backend/server cd /opt/adventurelog/backend/server
pip install --upgrade pip &>/dev/null pip install --upgrade pip &>/dev/null
pip install -r requirements.txt &>/dev/null pip install -r requirements.txt &>/dev/null
python3 manage.py collectstatic --noinput &>/dev/null python3 manage.py collectstatic --noinput &>/dev/null
python3 manage.py migrate &>/dev/null python3 manage.py migrate &>/dev/null
mv /opt/frontend.env /opt/adventurelog/frontend/.env mv /opt/adventurelog-backup/frontend/.env /opt/adventurelog/frontend/.env
cd /opt/adventurelog/frontend cd /opt/adventurelog/frontend
pnpm install &>/dev/null pnpm install &>/dev/null
pnpm run build &>/dev/null pnpm run build &>/dev/null
@ -65,7 +67,8 @@ function update_script() {
msg_ok "Started Services" msg_ok "Started Services"
msg_info "Cleaning Up" msg_info "Cleaning Up"
rm -rf v${RELEASE}.zip rm -rf /opt/v${RELEASE}.zip
rm -rf /opt/adventurelog-backup
msg_ok "Cleaned" msg_ok "Cleaned"
msg_ok "Updated Successfully" msg_ok "Updated Successfully"
else else
@ -81,4 +84,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}:3000${CL}" echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:3000${CL}"