This commit is contained in:
Slaviša Arežina 2025-08-04 15:43:07 +02:00 committed by GitHub
parent b5b6048697
commit 4dc458c605
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 26 additions and 19 deletions

View File

@ -27,18 +27,26 @@ function update_script() {
msg_error "No ${APP} Installation Found!"
exit
fi
RELEASE=$(curl -s https://api.github.com/repos/pocketbase/pocketbase/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
if [[ "${RELEASE}" != "$(cat ~/.pocketbase 2>/dev/null)" ]] || [[ ! -f ~/.pocketbase ]]; then
msg_info "Stopping ${APP}"
systemctl stop pocketbase
msg_ok "Stopped ${APP}"
msg_info "Updating ${APP}"
/opt/pocketbase/pocketbase update
echo "${RELEASE}" > ~/.pocketbase
msg_ok "Updated ${APP}"
msg_info "Starting ${APP}"
systemctl start pocketbase
msg_ok "Started ${APP}"
msg_ok "Updated Successfully"
msg_ok "Update Successful"
else
msg_ok "No update required. ${APP} is already at ${RELEASE}"
fi
exit
}

View File

@ -13,12 +13,13 @@ setting_up_container
network_check
update_os
msg_info "Installing Pocketbase"
RELEASE="$(curl -fsSL https://api.github.com/repos/pocketbase/pocketbase/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')"
curl -fsSL "https://github.com/pocketbase/pocketbase/releases/download/v${RELEASE}/pocketbase_${RELEASE}_linux_amd64.zip" -o "/tmp/pocketbase.zip"
mkdir -p /opt/pocketbase/{pb_public,pb_migrations,pb_hooks}
$STD unzip -o /tmp/pocketbase.zip -d /opt/pocketbase
fetch_and_deploy_gh_release "pocketbase" "pocketbase/pocketbase" "prebuild" "latest" "/opt/pocketbase" "pocketbase*linux_amd64.zip"
msg_info "Configuring Pocketbase"
mkdir -p /opt/pocketbase/{pb_public,pb_migrations,pb_hooks}
msg_ok "Configured Pocketbase"
msg_info "Creating service"
cat <<EOF >/etc/systemd/system/pocketbase.service
[Unit]
Description = pocketbase
@ -35,15 +36,13 @@ ExecStart = /opt/pocketbase/pocketbase serve --http=0.0.0.0:8080
[Install]
WantedBy = multi-user.target
EOF
systemctl enable -q --now pocketbase
msg_ok "Installed Pocketbase"
msg_ok "Service created"
motd_ssh
customize
msg_info "Cleaning up"
rm -rf /tmp/pocketbase.zip
$STD apt-get -y autoremove
$STD apt-get -y autoclean
msg_ok "Cleaned"