Files
cryptpad/sso-entrypoint.sh
2026-03-01 02:54:27 +00:00

38 lines
1.3 KiB
Bash

#!/bin/bash
set -e
# SSO plugin installer — runs before the original CryptPad entrypoint.
# Clones the cryptpad/sso plugin into the plugins volume if not already present
# or if the version has changed.
# Skips SSO setup entirely when SSO_ENABLED is not "true".
if [ "${SSO_ENABLED}" != "true" ]; then
echo "[sso-entrypoint] SSO not enabled, skipping plugin install"
exec "$@"
fi
PLUGIN_DIR="/cryptpad/lib/plugins/sso"
VERSION_FILE="${PLUGIN_DIR}/.version"
SSO_PLUGIN_VERSION="${SSO_PLUGIN_VERSION:-0.4.0}"
# Copy SSO config template into place (mounted as Docker config)
if [ -f /sso.js ]; then
cp /sso.js /cryptpad/config/sso.js
echo "[sso-entrypoint] Copied sso.js config into /cryptpad/config/sso.js"
fi
# Install/update the SSO plugin
if [ -f "${VERSION_FILE}" ] && [ "$(cat "${VERSION_FILE}")" = "${SSO_PLUGIN_VERSION}" ]; then
echo "[sso-entrypoint] SSO plugin ${SSO_PLUGIN_VERSION} already installed"
else
echo "[sso-entrypoint] Installing SSO plugin ${SSO_PLUGIN_VERSION} ..."
rm -rf "${PLUGIN_DIR}"
git clone --depth 1 --branch "${SSO_PLUGIN_VERSION}" \
https://github.com/cryptpad/sso.git "${PLUGIN_DIR}"
echo "${SSO_PLUGIN_VERSION}" > "${VERSION_FILE}"
echo "[sso-entrypoint] SSO plugin installed"
fi
# Hand off to the original CryptPad entrypoint
exec "$@"