Refactor: PocketID (#6556)

* Refactor

* Fix
This commit is contained in:
Slaviša Arežina 2025-08-04 15:45:02 +02:00 committed by GitHub
parent 349827aa97
commit 96f2c9c990
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 16 deletions

View File

@ -29,9 +29,10 @@ function update_script() {
exit
fi
[[ -f /opt/${APP}_version.txt ]] && mv /opt/${APP}_version.txt ~/.pocket-id
RELEASE=$(curl -fsSL https://api.github.com/repos/pocket-id/pocket-id/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
if [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]] || [[ ! -f /opt/${APP}_version.txt ]]; then
if [[ "$(cat /opt/${APP}_version.txt)" < "1.0.0" ]]; then
if [[ "${RELEASE}" != "$(cat ~/.pocket-id)" ]] || [[ ! -f ~/.pocket-id ]]; then
if [[ "$(cat ~/.pocket-id)" < "1.0.0" ]]; then
msg_info "Migrating ${APP} to v${RELEASE}"
systemctl -q disable --now pocketid-backend pocketid-frontend caddy
mv /etc/caddy/Caddyfile ~/Caddyfile.bak
@ -58,19 +59,19 @@ function update_script() {
mv /opt/data /opt/pocket-id
msg_ok "Migration complete. The reverse proxy port has been changed to 1411."
else
msg_info "Updating $APP to v${RELEASE}"
msg_info "Stopping ${APP}"
systemctl stop pocketid
msg_ok "Stopped ${APP}"
cp /opt/pocket-id/.env /opt/env
fi
curl -fsSL "https://github.com/pocket-id/pocket-id/releases/download/v${RELEASE}/pocket-id-linux-amd64" -o /opt/pocket-id/pocket-id
chmod u+x /opt/pocket-id/pocket-id
fetch_and_deploy_gh_release "pocket-id" "pocket-id/pocket-id" "singlefile" "latest" "/opt/pocket-id/" "pocket-id-linux-amd64"
mv /opt/env /opt/pocket-id/.env
msg_info "Starting $APP"
systemctl start pocketid
msg_ok "Started $APP"
echo "${RELEASE}" >/opt/${APP}_version.txt
msg_ok "Update Successful"
else
msg_ok "No update required. ${APP} is already at ${RELEASE}"

View File

@ -14,12 +14,9 @@ network_check
update_os
read -r -p "${TAB3}What public URL do you want to use (e.g. pocketid.mydomain.com)? " public_url
msg_info "Setup Pocket ID"
RELEASE=$(curl -fsSL https://api.github.com/repos/pocket-id/pocket-id/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
mkdir -p /opt/pocket-id
curl -fsSL "https://github.com/pocket-id/pocket-id/releases/download/v${RELEASE}/pocket-id-linux-amd64" -o /opt/pocket-id/pocket-id
chmod u+x /opt/pocket-id/pocket-id
fetch_and_deploy_gh_release "pocket-id" "pocket-id/pocket-id" "singlefile" "latest" "/opt/pocket-id/" "pocket-id-linux-amd64"
msg_info "Configuring Pocket ID"
cat <<EOF >/opt/pocket-id/.env
APP_ENV=production
APP_URL=https://${public_url}
@ -28,8 +25,7 @@ TRUST_PROXY=false
PORT=1411
HOST=0.0.0.0
EOF
echo "${RELEASE}" >/opt/${APPLICATION}_version.txt
msg_ok "Setup Pocket ID"
msg_ok "Configured Pocket ID"
msg_info "Creating Service"
cat <<EOF >/etc/systemd/system/pocketid.service
@ -63,6 +59,3 @@ msg_info "Cleaning up"
$STD apt-get -y autoremove
$STD apt-get -y autoclean
msg_ok "Cleaned"
motd_ssh
customize