#
# Add a non-XA datasource as the main persistence backend for Silverpeas
#

echo Add a non-XA datasource as the main persistence backend for Silverpeas

# If already set, remove it so that the datasource can be updated
if (outcome == success) of /subsystem=datasources/data-source=Silverpeas:read-resource
  /subsystem=datasources/data-source=Silverpeas:remove
end-if

data-source add \
  --name=Silverpeas \
  --driver-name=${DB_DRIVER_NAME} \
  --connection-url=${DB_URL} \
  --jndi-name=${DB_DATASOURCE_JNDI} \
  --allow-multiple-users=true \
  --use-java-context=true \
  --statistics-enabled=${DB_STATS_ENABLED} \
  --user-name=${DB_USER} \
  --password=${DB_PASSWORD} \
  --use-ccm=true \
  --min-pool-size=${DB_MIN_POOL_SIZE} \
  --max-pool-size=${DB_MAX_POOL_SIZE} \
  --blocking-timeout-wait-millis=${DB_BLOCKING_TIMEOUT} \
  --idle-timeout-minutes=${DB_IDLE_TIMEOUT}
