From 96f2c9c990ce039e011d18ffab0b9bdec4470533 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Slavi=C5=A1a=20Are=C5=BEina?= <58952836+tremor021@users.noreply.github.com> Date: Mon, 4 Aug 2025 15:45:02 +0200 Subject: [PATCH] Refactor: PocketID (#6556) * Refactor * Fix --- ct/pocketid.sh | 13 +++++++------ install/pocketid-install.sh | 13 +++---------- 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/ct/pocketid.sh b/ct/pocketid.sh index 000b4b45c..0b0c0cce4 100755 --- a/ct/pocketid.sh +++ b/ct/pocketid.sh @@ -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}" diff --git a/install/pocketid-install.sh b/install/pocketid-install.sh index a00fd8d33..670ad46ba 100644 --- a/install/pocketid-install.sh +++ b/install/pocketid-install.sh @@ -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 </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 </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