Skip to content

Commit

Permalink
fix env variables declarations (#484)
Browse files Browse the repository at this point in the history
* Cleanup info and fix gwc config and echo statements
  • Loading branch information
NyakudyaA authored Jan 29, 2023
1 parent 2ed84d2 commit 59bc3e3
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 37 deletions.
8 changes: 4 additions & 4 deletions build_data/gwc-gs.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<GeoServerGWCConfig>
<version>1.1.0</version>
<directWMSIntegrationEnabled>${WMS_DIR_INTEGRATION}</directWMSIntegrationEnabled>
<requireTiledParameter>true</requireTiledParameter>
<WMSCEnabled>true</WMSCEnabled>
<TMSEnabled>true</TMSEnabled>
<securityEnabled>false</securityEnabled>
<requireTiledParameter>${REQUIRE_TILED_PARAMETER}</requireTiledParameter>
<WMSCEnabled>${WMSC_ENABLED}</WMSCEnabled>
<TMSEnabled>${TMS_ENABLED}</TMSEnabled>
<securityEnabled>${SECURITY_ENABLED}</securityEnabled>
<innerCachingEnabled>false</innerCachingEnabled>
<persistenceEnabled>true</persistenceEnabled>
<cacheProviderClass>class org.geowebcache.storage.blobstore.memory.guava.GuavaCacheProvider</cacheProviderClass>
Expand Down
19 changes: 19 additions & 0 deletions scripts/env-data.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,25 @@ if [ -z "${WMS_DIR_INTEGRATION}" ]; then
WMS_DIR_INTEGRATION=false
fi

if [ -z "${REQUIRE_TILED_PARAMETER}" ]; then
REQUIRE_TILED_PARAMETER=true
fi


if [ -z "${WMSC_ENABLED}" ]; then
WMSC_ENABLED=true
fi


if [ -z "${TMS_ENABLED}" ]; then
TMS_ENABLED=true
fi


if [ -z "${SECURITY_ENABLED}" ]; then
SECURITY_ENABLED=false
fi

if [ -z "${DISK_QUOTA_SIZE}" ]; then
DISK_QUOTA_SIZE=20
fi
Expand Down
5 changes: 2 additions & 3 deletions scripts/functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ function create_dir() {
DATA_PATH=$1

if [[ ! -d ${DATA_PATH} ]]; then
echo "Creating" "${DATA_PATH}" "directory"
mkdir -p "${DATA_PATH}"
fi
}
Expand Down Expand Up @@ -85,7 +84,6 @@ function web_cors() {
# Useful if CORS is handled outside of Tomcat (e.g. in a proxying webserver like nginx)
###
if [[ "${DISABLE_CORS}" =~ [Tt][Rr][Uu][Ee] ]]; then
echo "Deactivating Tomcat CORS filter"
sed -i 's/<!-- CORS_START.*/<!-- CORS DEACTIVATED BY DISABLE_CORS -->\n<!--/; s/^.*<!-- CORS_END -->/-->/' \
${CATALINA_HOME}/conf/web.xml
fi
Expand Down Expand Up @@ -247,6 +245,7 @@ function install_plugin() {

if [[ -f "${DATA_PATH}"/"${EXT}".zip ]];then
unzip "${DATA_PATH}"/"${EXT}".zip -d /tmp/gs_plugin
echo -e "\e[32m Enabling ${EXT} for GeoServer \033[0m"
if [[ -f /geoserver/start.jar ]]; then
cp -r -u -p /tmp/gs_plugin/*.jar /geoserver/webapps/geoserver/WEB-INF/lib/
else
Expand Down Expand Up @@ -285,7 +284,7 @@ function jdbc_disk_quota_config() {
fi
}

function enable_direct_integration_wms() {
function activate_gwc_global_configs() {
if [[ ! -f "${GEOSERVER_DATA_DIR}"/gwc-gs.xml ]]; then
if [[ -f "${EXTRA_CONFIG_DIR}"/gwc-gs.xml ]]; then
envsubst < "${EXTRA_CONFIG_DIR}"/gwc-gs.xml < "${GEOSERVER_DATA_DIR}"/gwc-gs.xml
Expand Down
41 changes: 11 additions & 30 deletions scripts/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,34 +33,29 @@ geoserver_logging

# Activate sample data
if [[ ${SAMPLE_DATA} =~ [Tt][Rr][Uu][Ee] ]]; then
echo "Activating default data directory"
cp -r "${CATALINA_HOME}"/data/* "${GEOSERVER_DATA_DIR}"
fi


# Recreate DISK QUOTA config, useful to change between H2 and jdbc and change connection or schema
if [[ "${RECREATE_DISKQUOTA}" =~ [Tt][Rr][Uu][Ee] ]]; then

echo "Remove old geowebcache disk quota xml."
if [[ -f "${GEOWEBCACHE_CACHE_DIR}"/geowebcache-diskquota.xml ]]; then
rm "${GEOWEBCACHE_CACHE_DIR}"/geowebcache-diskquota.xml
echo "${GEOWEBCACHE_CACHE_DIR}/geowebcache-diskquota.xml removed"
fi
if [[ -f "${GEOWEBCACHE_CACHE_DIR}"/geowebcache-diskquota-jdbc.xml ]]; then
rm "${GEOWEBCACHE_CACHE_DIR}"/geowebcache-diskquota-jdbc.xml
echo "${GEOWEBCACHE_CACHE_DIR}/geowebcache-diskquota-jdbc.xml removed"
fi
fi

export DISK_QUOTA_SIZE
export DISK_QUOTA_FREQUENCY DISK_QUOTA_SIZE
if [[ ${DB_BACKEND} =~ [Pp][Oo][Ss][Tt][Gg][Rr][Ee][Ss] ]]; then
postgres_ssl_setup
export DISK_QUOTA_BACKEND=JDBC
export SSL_PARAMETERS=${PARAMS}
default_disk_quota_config
jdbc_disk_quota_config

echo -e "[Entrypoint] Checking PostgreSQL connection to see if init tables are loaded: \033[0m"
echo -e "[Entrypoint] Checking PostgreSQL connection to see if diskquota tables are loaded: \033[0m"
export PGPASSWORD="${POSTGRES_PASS}"
postgres_ready_status ${HOST} ${POSTGRES_PORT} ${POSTGRES_USER} $POSTGRES_DB
create_gwc_tile_tables ${HOST} ${POSTGRES_PORT} ${POSTGRES_USER} $POSTGRES_DB $POSTGRES_SCHEMA
Expand All @@ -69,27 +64,23 @@ else
default_disk_quota_config
fi

# Direct Integration with GeoServer WMS
echo "Direct Integration with Geoserver WMS option"
enable_direct_integration_wms
# GWC Global Config options GeoServer WMS
export WMS_DIR_INTEGRATION REQUIRE_TILED_PARAMETER WMSC_ENABLED TMS_ENABLED SECURITY_ENABLED
activate_gwc_global_configs

# Install stable plugins
if [[ -z "${STABLE_EXTENSIONS}" ]]; then
echo -e "\e[32m STABLE_EXTENSIONS is unset, so we do not install any stable extensions \033[0m"
else
if [[ ! -z "${STABLE_EXTENSIONS}" ]]; then
if [[ ${FORCE_DOWNLOAD_STABLE_EXTENSIONS} =~ [Tt][Rr][Uu][Ee] ]];then
rm -rf /stable_plugins/*.zip
for plugin in $(cat /stable_plugins/stable_plugins.txt); do
approved_plugins_url="${STABLE_PLUGIN_BASE_URL}/${GS_VERSION}/extensions/geoserver-${GS_VERSION}-${plugin}.zip"
download_extension "${approved_plugins_url}" "${plugin}" /stable_plugins
done
for ext in $(echo "${STABLE_EXTENSIONS}" | tr ',' ' '); do
echo "Enabling ${ext} for GeoServer ${GS_VERSION}"
install_plugin /stable_plugins/ "${ext}"
done
else
for ext in $(echo "${STABLE_EXTENSIONS}" | tr ',' ' '); do
echo "Enabling ${ext} for GeoServer ${GS_VERSION}"
if [[ ! -f /stable_plugins/${ext}.zip ]]; then
approved_plugins_url="${STABLE_PLUGIN_BASE_URL}/${GS_VERSION}/extensions/geoserver-${GS_VERSION}-${ext}.zip"
download_extension "${approved_plugins_url}" "${ext}" /stable_plugins/
Expand All @@ -106,7 +97,6 @@ if [[ ${ACTIVATE_ALL_STABLE_EXTENSIONS} =~ [Tt][Rr][Uu][Ee] ]];then
pushd /stable_plugins/ || exit
for val in *.zip; do
ext=${val%.*}
echo "Enabling ${ext} for GeoServer ${GS_VERSION}"
install_plugin /stable_plugins/ "${ext}"
done
pushd "${GEOSERVER_HOME}" || exit
Expand All @@ -116,34 +106,26 @@ fi
# Function to install community extensions
export S3_SERVER_URL S3_USERNAME S3_PASSWORD

function community_config() {
echo -e "\e[32m Installing ${ext} \033[0m"
install_plugin /community_plugins "${ext}"
}

# Install community modules plugins
if [[ -z ${COMMUNITY_EXTENSIONS} ]]; then
echo -e "\e[32m COMMUNITY_EXTENSIONS is unset, so we do not install any community extensions \033[0m"
else
if [[ ! -z ${COMMUNITY_EXTENSIONS} ]]; then
if [[ ${FORCE_DOWNLOAD_COMMUNITY_EXTENSIONS} =~ [Tt][Rr][Uu][Ee] ]];then
rm -rf /community_plugins/*.zip
for plugin in $(cat /community_plugins/community_plugins.txt); do
community_plugins_url="https://build.geoserver.org/geoserver/${GS_VERSION:0:5}x/community-latest/geoserver-${GS_VERSION:0:4}-SNAPSHOT-${plugin}.zip"
download_extension "${community_plugins_url}" "${plugin}" /community_plugins
done
for ext in $(echo "${COMMUNITY_EXTENSIONS}" | tr ',' ' '); do
echo "Enabling ${ext} for GeoServer ${GS_VERSION}"
community_config
install_plugin /community_plugins "${ext}"
done
else
for ext in $(echo "${COMMUNITY_EXTENSIONS}" | tr ',' ' '); do
echo "Enabling ${ext} for GeoServer ${GS_VERSION}"
if [[ ! -f /community_plugins/${ext}.zip ]]; then
community_plugins_url="https://build.geoserver.org/geoserver/${GS_VERSION:0:5}x/community-latest/geoserver-${GS_VERSION:0:4}-SNAPSHOT-${ext}.zip"
download_extension "${community_plugins_url}" "${ext}" /community_plugins
community_config
install_plugin /community_plugins "${ext}"
else
community_config
install_plugin /community_plugins "${ext}"
fi
done
fi
Expand All @@ -154,8 +136,7 @@ if [[ ${ACTIVATE_ALL_COMMUNITY_EXTENSIONS} =~ [Tt][Rr][Uu][Ee] ]];then
pushd /community_plugins/ || exit
for val in *.zip; do
ext=${val%.*}
echo -e "\e[32m Enabling ${ext} for GeoServer ${GS_VERSION} \033[0m"
community_config
install_plugin /community_plugins "${ext}"
done
pushd "${GEOSERVER_HOME}" || exit
fi
Expand Down
1 change: 1 addition & 0 deletions scripts/update_passwords.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ else
if [ ! -d "${GEOSERVER_DATA_DIR}/security" ]; then
echo -e "\e[32m Copying default security folder \033[0m"
cp -r ${CATALINA_HOME}/security ${GEOSERVER_DATA_DIR}
sed -i 's/pbePasswordEncoder/strongPbePasswordEncoder/g' ${GEOSERVER_DATA_DIR}/security/config.xml
fi
fi
fi
Expand Down

0 comments on commit 59bc3e3

Please sign in to comment.