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 exit
fi 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) }') 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 [[ "${RELEASE}" != "$(cat ~/.pocket-id)" ]] || [[ ! -f ~/.pocket-id ]]; then
if [[ "$(cat /opt/${APP}_version.txt)" < "1.0.0" ]]; then if [[ "$(cat ~/.pocket-id)" < "1.0.0" ]]; then
msg_info "Migrating ${APP} to v${RELEASE}" msg_info "Migrating ${APP} to v${RELEASE}"
systemctl -q disable --now pocketid-backend pocketid-frontend caddy systemctl -q disable --now pocketid-backend pocketid-frontend caddy
mv /etc/caddy/Caddyfile ~/Caddyfile.bak mv /etc/caddy/Caddyfile ~/Caddyfile.bak
@ -58,19 +59,19 @@ function update_script() {
mv /opt/data /opt/pocket-id mv /opt/data /opt/pocket-id
msg_ok "Migration complete. The reverse proxy port has been changed to 1411." msg_ok "Migration complete. The reverse proxy port has been changed to 1411."
else else
msg_info "Updating $APP to v${RELEASE}" msg_info "Stopping ${APP}"
systemctl stop pocketid systemctl stop pocketid
msg_ok "Stopped ${APP}"
cp /opt/pocket-id/.env /opt/env cp /opt/pocket-id/.env /opt/env
fi 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 mv /opt/env /opt/pocket-id/.env
msg_info "Starting $APP" msg_info "Starting $APP"
systemctl start pocketid systemctl start pocketid
msg_ok "Started $APP" msg_ok "Started $APP"
echo "${RELEASE}" >/opt/${APP}_version.txt
msg_ok "Update Successful" msg_ok "Update Successful"
else else
msg_ok "No update required. ${APP} is already at ${RELEASE}" msg_ok "No update required. ${APP} is already at ${RELEASE}"

View File

@ -14,12 +14,9 @@ network_check
update_os update_os
read -r -p "${TAB3}What public URL do you want to use (e.g. pocketid.mydomain.com)? " public_url read -r -p "${TAB3}What public URL do you want to use (e.g. pocketid.mydomain.com)? " public_url
msg_info "Setup Pocket ID" fetch_and_deploy_gh_release "pocket-id" "pocket-id/pocket-id" "singlefile" "latest" "/opt/pocket-id/" "pocket-id-linux-amd64"
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
msg_info "Configuring Pocket ID"
cat <<EOF >/opt/pocket-id/.env cat <<EOF >/opt/pocket-id/.env
APP_ENV=production APP_ENV=production
APP_URL=https://${public_url} APP_URL=https://${public_url}
@ -28,8 +25,7 @@ TRUST_PROXY=false
PORT=1411 PORT=1411
HOST=0.0.0.0 HOST=0.0.0.0
EOF EOF
echo "${RELEASE}" >/opt/${APPLICATION}_version.txt msg_ok "Configured Pocket ID"
msg_ok "Setup Pocket ID"
msg_info "Creating Service" msg_info "Creating Service"
cat <<EOF >/etc/systemd/system/pocketid.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 autoremove
$STD apt-get -y autoclean $STD apt-get -y autoclean
msg_ok "Cleaned" msg_ok "Cleaned"
motd_ssh
customize