export PHP_UPLOADS_CONF_VERSION=v3 export ENTRYPOINT_CONF_VERSION=v7 export ENTRYPOINT_MAILRELAY_CONF_VERSION=v2 export MSMTP_CONF_VERSION=v4 export HTACCESS_CONF_VERSION=v2 wp() { su -p www-data -s /bin/bash -c "/usr/local/bin/wp $@" } update() { wp "core update-db" wp "plugin update --all" wp "plugin auto-updates enable --all" wp "theme update --all" wp "theme auto-updates enable --all" wp "language core update" wp "language plugin update --all" wp "language theme update --all" } core_install(){ ADMIN=admin if [ -n "$AUTHENTIK_DOMAIN" ] then ADMIN=akadmin fi chown www-data:www-data -R /var/www/html/wp-content wp "core install --url=$DOMAIN --title=\"$TITLE\" --admin_user=$ADMIN --admin_email=$ADMIN_EMAIL --locale=$LOCALE --skip-email" wp "language core install $LOCALE" wp "site switch-language $LOCALE" wp "rewrite structure '/%year%/%monthnum%/%day%/%postname%/'" wp "plugin install --activate disable-update-notifications" wp "option update disable_notification_setting --format=json '{\"dpun_setting\":false,\"dwtu_setting\":false,\"dwcun_setting\":true}'" if [ -n "$DEFAULT_USER_ROLE" ] then wp "option set default_role $DEFAULT_USER_ROLE" else wp "option set default_role subscriber" fi wp "theme auto-updates enable --all" wp 'plugin auto-updates enable --all' || exit 0 } set_authentik(){ AUTHENTIK_SECRET=$(cat /run/secrets/authentik_secret) AUTHENTIK_ID=$(cat /run/secrets/authentik_id) if [ -z $LOGIN_TYPE ] then LOGIN_TYPE='button' fi wp "user create akadmin admin@example.com --role=administrator" wp "plugin install --activate daggerhart-openid-connect-generic" wp 'plugin auto-updates enable daggerhart-openid-connect-generic' wp "option update --format=json openid_connect_generic_settings ' { \"login_type\":\"$LOGIN_TYPE\", \"client_id\":\"$AUTHENTIK_ID\", \"client_secret\":\"$AUTHENTIK_SECRET\", \"scope\":\"email profile openid\", \"endpoint_login\":\"https://$AUTHENTIK_DOMAIN/application/o/authorize/\", \"endpoint_userinfo\":\"https://$AUTHENTIK_DOMAIN/application/o/userinfo/\", \"endpoint_token\":\"https://$AUTHENTIK_DOMAIN/application/o/token/\", \"endpoint_end_session\":\"https://$AUTHENTIK_DOMAIN/application/o/wordpress/end-session/\", \"acr_values\":\"\", \"identity_key\":\"preferred_username\", \"no_sslverify\":\"0\", \"http_request_timeout\":\"30\", \"enforce_privacy\":\"0\", \"alternate_redirect_uri\":\"1\", \"nickname_key\":\"preferred_username\", \"email_format\":\"{email}\", \"displayname_format\":\"\", \"identify_with_username\":\"1\", \"state_time_limit\":\"\", \"token_refresh_enable\":\"1\", \"link_existing_users\":\"1\", \"create_if_does_not_exist\":\"1\", \"redirect_user_back\":\"0\", \"redirect_on_logout\":\"1\", \"enable_logging\":\"0\", \"log_limit\":\"1000\" }'" wp "rewrite flush" wp "cache flush" } fix_mysql() { echo "ALTER TABLE mysql.column_stats MODIFY histogram longblob; ALTER TABLE mysql.column_stats MODIFY hist_type enum('SINGLE_PREC_HB','DOUBLE_PREC_HB','JSON_HB');" | mysql -u root -p$(cat /run/secrets/db_root_password) }