mirror of
https://git.cloudron.io/cloudron/peertube-app.git
synced 2024-12-22 08:07:22 +00:00
always install oidc plugin
This commit is contained in:
parent
4fcf9b1684
commit
3c7afbe0ca
1 changed files with 17 additions and 22 deletions
39
start.sh
39
start.sh
|
@ -8,27 +8,20 @@ mkdir -p /app/data/storage /run/peertube/cache /run/peertube/npm /tmp/peertube
|
|||
cd /app/code/server
|
||||
|
||||
migrate_ldap_to_oidc() {
|
||||
if [[ -n "${CLOUDRON_OIDC_ISSUER:-}" ]]; then
|
||||
OIDC_PLUIGIN_INSTALLED=$(PGPASSWORD=${CLOUDRON_POSTGRESQL_PASSWORD} psql -h ${CLOUDRON_POSTGRESQL_HOST} -p ${CLOUDRON_POSTGRESQL_PORT} -U ${CLOUDRON_POSTGRESQL_USERNAME} -d ${CLOUDRON_POSTGRESQL_DATABASE} -AXqtc "SELECT count(*) FROM \"plugin\" WHERE name='auth-openid-connect'")
|
||||
if [ ${OIDC_PLUIGIN_INSTALLED} -eq 0 ]; then
|
||||
install_oidc
|
||||
fi
|
||||
USERS_TO_MIGRATE=$(PGPASSWORD=${CLOUDRON_POSTGRESQL_PASSWORD} psql -h ${CLOUDRON_POSTGRESQL_HOST} -p ${CLOUDRON_POSTGRESQL_PORT} -U ${CLOUDRON_POSTGRESQL_USERNAME} -d ${CLOUDRON_POSTGRESQL_DATABASE} -AXqtc "SELECT count(*) FROM \"user\" u WHERE \"pluginAuth\"='peertube-plugin-auth-ldap'")
|
||||
echo "==> Migrating users to OIDC";
|
||||
echo " Users to migrate: ${USERS_TO_MIGRATE}"
|
||||
if [ ${USERS_TO_MIGRATE} -gt 0 ]; then
|
||||
PGPASSWORD=${CLOUDRON_POSTGRESQL_PASSWORD} psql -h ${CLOUDRON_POSTGRESQL_HOST} -p ${CLOUDRON_POSTGRESQL_PORT} -U ${CLOUDRON_POSTGRESQL_USERNAME} -d ${CLOUDRON_POSTGRESQL_DATABASE} -c "UPDATE \"user\" SET \"pluginAuth\"='peertube-plugin-auth-openid-connect' WHERE \"pluginAuth\"='peertube-plugin-auth-ldap'"
|
||||
fi
|
||||
|
||||
USERS_TO_MIGRATE=$(PGPASSWORD=${CLOUDRON_POSTGRESQL_PASSWORD} psql -h ${CLOUDRON_POSTGRESQL_HOST} -p ${CLOUDRON_POSTGRESQL_PORT} -U ${CLOUDRON_POSTGRESQL_USERNAME} -d ${CLOUDRON_POSTGRESQL_DATABASE} -AXqtc "SELECT count(*) FROM \"user\" u WHERE \"pluginAuth\"='peertube-plugin-auth-ldap'")
|
||||
echo "==> Migrating users to OIDC";
|
||||
echo " Users to migrate: ${USERS_TO_MIGRATE}"
|
||||
if [ ${USERS_TO_MIGRATE} -gt 0 ]; then
|
||||
PGPASSWORD=${CLOUDRON_POSTGRESQL_PASSWORD} psql -h ${CLOUDRON_POSTGRESQL_HOST} -p ${CLOUDRON_POSTGRESQL_PORT} -U ${CLOUDRON_POSTGRESQL_USERNAME} -d ${CLOUDRON_POSTGRESQL_DATABASE} -c "UPDATE \"user\" SET \"pluginAuth\"='peertube-plugin-auth-openid-connect' WHERE \"pluginAuth\"='peertube-plugin-auth-ldap'"
|
||||
fi
|
||||
LDAP_PLUGIN_INSTALLED=$(PGPASSWORD=${CLOUDRON_POSTGRESQL_PASSWORD} psql -h ${CLOUDRON_POSTGRESQL_HOST} -p ${CLOUDRON_POSTGRESQL_PORT} -U ${CLOUDRON_POSTGRESQL_USERNAME} -d ${CLOUDRON_POSTGRESQL_DATABASE} -AXqtc "SELECT count(*) FROM \"plugin\" WHERE name='auth-ldap'")
|
||||
if [ ${LDAP_PLUGIN_INSTALLED} -gt 0 ]; then
|
||||
echo "==> Uninstalling LDAP plugin"
|
||||
gosu cloudron:cloudron npm run plugin:uninstall -- -n peertube-plugin-auth-ldap
|
||||
|
||||
LDAP_PLUGIN_INSTALLED=$(PGPASSWORD=${CLOUDRON_POSTGRESQL_PASSWORD} psql -h ${CLOUDRON_POSTGRESQL_HOST} -p ${CLOUDRON_POSTGRESQL_PORT} -U ${CLOUDRON_POSTGRESQL_USERNAME} -d ${CLOUDRON_POSTGRESQL_DATABASE} -AXqtc "SELECT count(*) FROM \"plugin\" WHERE name='auth-ldap'")
|
||||
if [ ${LDAP_PLUGIN_INSTALLED} -gt 0 ]; then
|
||||
echo "==> Uninstalling LDAP plugin"
|
||||
gosu cloudron:cloudron npm run plugin:uninstall -- -n peertube-plugin-auth-ldap
|
||||
|
||||
echo "==> Deleting LDAP settings"
|
||||
PGPASSWORD=${CLOUDRON_POSTGRESQL_PASSWORD} psql -h ${CLOUDRON_POSTGRESQL_HOST} -p ${CLOUDRON_POSTGRESQL_PORT} -U ${CLOUDRON_POSTGRESQL_USERNAME} -d ${CLOUDRON_POSTGRESQL_DATABASE} -c "DELETE FROM \"plugin\" WHERE name='auth-ldap'"
|
||||
fi
|
||||
echo "==> Deleting LDAP settings"
|
||||
PGPASSWORD=${CLOUDRON_POSTGRESQL_PASSWORD} psql -h ${CLOUDRON_POSTGRESQL_HOST} -p ${CLOUDRON_POSTGRESQL_PORT} -U ${CLOUDRON_POSTGRESQL_USERNAME} -d ${CLOUDRON_POSTGRESQL_DATABASE} -c "DELETE FROM \"plugin\" WHERE name='auth-ldap'"
|
||||
fi
|
||||
}
|
||||
|
||||
|
@ -138,9 +131,11 @@ if [[ ! -f "/app/data/production.yaml" ]]; then
|
|||
first_time_setup
|
||||
else
|
||||
update_config
|
||||
migrate_ldap_to_oidc
|
||||
|
||||
[[ -n "${CLOUDRON_OIDC_ISSUER:-}" ]] && update_oidc
|
||||
if [[ -n "${CLOUDRON_OIDC_ISSUER:-}" ]]; then
|
||||
install_oidc
|
||||
migrate_ldap_to_oidc
|
||||
update_oidc
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "==> Configuring nginx"
|
||||
|
|
Loading…
Reference in a new issue