Files
ProxmoxVE/ct/pocketid.sh
T

95 lines
3.3 KiB
Bash
Raw Normal View History

2025-01-28 22:04:39 +10:00
#!/usr/bin/env bash
_cs_boot="${COMMUNITY_SCRIPTS_CORE_DIR:-$(dirname "${BASH_SOURCE[0]}")/../../core}/core/build.func"
source "$_cs_boot" 2>/dev/null || source <(curl -fsSL "${COMMUNITY_SCRIPTS_CORE_URL:-https://raw.githubusercontent.com/community-scripts/core/main}/core/build.func")
# Copyright (c) 2021-2026 community-scripts ORG
2025-01-28 22:04:39 +10:00
# Author: Snarkenfaugister
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
# Source: https://github.com/pocket-id/pocket-id
2025-01-28 22:04:39 +10:00
APP="PocketID"
var_tags="${var_tags:-identity-provider}"
var_cpu="${var_cpu:-2}"
var_ram="${var_ram:-2048}"
var_disk="${var_disk:-4}"
var_os="${var_os:-debian}"
var_version="${var_version:-13}"
var_arm64="${var_arm64:-yes}"
var_unprivileged="${var_unprivileged:-1}"
2025-01-28 22:04:39 +10:00
header_info "$APP"
variables
color
catch_errors
function update_script() {
header_info
check_container_storage
check_container_resources
2025-01-28 22:04:39 +10:00
if [[ ! -d /opt/pocket-id ]]; then
msg_error "No ${APP} Installation Found!"
exit
fi
2025-01-28 22:04:39 +10:00
2026-01-04 23:07:44 +01:00
# Mandatory as of v2.x.x
ENCRYPTION_KEY=$(openssl rand -base64 32)
if ! grep -q '^ENCRYPTION_KEY=' /opt/pocket-id/.env; then
echo "ENCRYPTION_KEY=$ENCRYPTION_KEY" >> /opt/pocket-id/.env
fi
if check_for_gh_release "pocket-id" "pocket-id/pocket-id"; then
2025-10-10 11:15:44 +02:00
if [ "$(printf '%s\n%s' "$(cat ~/.pocket-id 2>/dev/null || echo 0.0.0)" "1.0.0" | sort -V | head -n1)" = "$(cat ~/.pocket-id 2>/dev/null || echo 0.0.0)" ] &&
[ "$(cat ~/.pocket-id 2>/dev/null || echo 0.0.0)" != "1.0.0" ]; then
msg_info "Migrating ${APP}"
systemctl -q disable --now pocketid-backend pocketid-frontend caddy
mv /etc/caddy/Caddyfile ~/Caddyfile.bak
$STD apt remove --purge caddy nodejs -y
$STD apt autoremove -y
rm /etc/apt/{keyrings/nodesource.gpg,sources.list.d/nodesource.list}
rm -r /usr/local/go
cp -r /opt/pocket-id/backend/data /opt/data
cp /opt/pocket-id/backend/.env /opt/env
sed -i -e 's/PUBLIC_//g' \
-e '/^SQLITE_DB_PATH/d' \
-e '/^POSTGRES/s/^/# /' \
-e '/^UPLOAD_PATH/d' \
-e 's/8080/1411/' /opt/env
rm -r /opt/pocket-id
rm /etc/systemd/system/pocketid-frontend.service
BACKEND="/etc/systemd/system/pocketid-backend.service"
sed -i -e 's/Backend/Service/' \
-e 's/\/backend\|-backend//g' "$BACKEND"
mv "$BACKEND" ${BACKEND//-backend/}
systemctl daemon-reload
systemctl -q enable pocketid
mkdir /opt/pocket-id
mv /opt/data /opt/pocket-id
msg_ok "Migration complete. The reverse proxy port has been changed to 1411."
2025-01-28 22:04:39 +10:00
else
2025-10-10 11:15:44 +02:00
msg_info "Stopping Service"
systemctl stop pocketid
2025-10-10 11:15:44 +02:00
msg_ok "Stopped Service"
cp /opt/pocket-id/.env /opt/env
2025-01-28 22:04:39 +10:00
fi
2025-08-04 15:45:02 +02:00
fetch_and_deploy_gh_release "pocket-id" "pocket-id/pocket-id" "singlefile" "latest" "/opt/pocket-id/" "pocket-id_linux_$(arch_resolve)"
mv /opt/env /opt/pocket-id/.env
msg_info "Starting Service"
systemctl start pocketid
msg_ok "Started Service"
msg_ok "Updated successfully!"
fi
exit
2025-01-28 22:04:39 +10:00
}
start
build_container
description
2026-01-06 22:57:40 +01:00
msg_ok "Completed successfully!\n"
2025-01-28 22:04:39 +10:00
echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}"
echo -e "${INFO}${YW} Configure your reverse proxy to point to:${BGN} ${IP}:1411${CL}"
echo -e "${INFO}${YW}Access it using the following URL:${CL}"
echo -e "${GATEWAY}${BGN}https://{PUBLIC_URL}/setup${CL}"