diff --git a/README.md b/README.md index cc02571..82c7464 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ #### Docker Ocie Image -Base image we use for our containers, Ocie itself is just a helper utility. -Default shell for Ubuntu is /bin/dash, this image sets /bin/sh to /bin/bash +Base image we use for our containers, Ocie itself is just an overlay utility. +Default shell, symlink for /bin/sh, in Ubuntu is /bin/dash, this image chages the symlink to /bin/bash Note: no support provided, released on github for automated builds and registry publishing :D diff --git a/src/usr/lib/ocie/include/config/apache b/src/usr/lib/ocie/include/config/apache index 5f54630..dd38fb3 100644 --- a/src/usr/lib/ocie/include/config/apache +++ b/src/usr/lib/ocie/include/config/apache @@ -29,8 +29,7 @@ function add_cors() function reset_config() { - SITE_TEMPLATE=/etc/apache2/sites-available; - + local site_template=/etc/apache2/sites-available; if [[ -f "${APACHE_MODS}/rewrite.conf" ]];then mv -f "${APACHE_MODS}/rewrite.conf" "${APACHE_MODS}/rewrite.conf.previous"; fi; @@ -45,11 +44,11 @@ function reset_config() fi; if [[ -f "${APACHE_SITES}/000-default.conf" ]];then mv -f "${APACHE_SITES}/000-default.conf" "${APACHE_SITES}/000-default.conf.previous"; - cp -f "${SITE_TEMPLATE}/000-default.conf.dist" "${APACHE_SITES}/000-default.conf"; + cp -f "${site_template}/000-default.conf.dist" "${APACHE_SITES}/000-default.conf"; fi; if [[ -f "${APACHE_SITES}/default-ssl.conf" ]];then mv -f "${APACHE_SITES}/default-ssl.conf" "${APACHE_SITES}/default-ssl.conf.previous"; - cp -f "${SITE_TEMPLATE}/default-ssl.conf.dist" "${APACHE_SITES}/default-ssl.conf"; + cp -f "${site_template}/default-ssl.conf.dist" "${APACHE_SITES}/default-ssl.conf"; fi; } @@ -69,7 +68,7 @@ else echo "Ocie: Config: Rewriting all requests to: [ https ]"; add_default; fi; - if [[ ! "${REWRITE_INDEX}" == "" ]];then + if [[ ! -z "${REWRITE_INDEX}" ]];then echo "Ocie: Config: Rewriting all requests to: [ ${REWRITE_INDEX} ]"; add_framework; fi; @@ -77,15 +76,15 @@ else echo "Ocie: Config: Adding CORS config for JSON to enabled site"; add_cors; fi; - if [[ ! "${REWRITE_EXT}" == "" ]];then - if [[ ! "${REWRITE_INDEX}" = "" ]];then + if [[ ! -z "${REWRITE_EXT}" ]];then + if [[ ! -z "${REWRITE_INDEX}" ]];then echo "Ocie: Config: Cannot configure both [ REWRITE_INDEX ] and [ REWRITE_EXT ], using [ REWRITE_INDEX ], value ${REWRITE_INDEX}"; else echo "Ocie: Config: Rewriting all requests with the following extensions: [ ${REWRITE_EXT} ]"; add_extension; fi; fi; - if [[ ! "${REWRITE_EXCLUDE}" == "" ]];then + if [[ ! -z "${REWRITE_EXCLUDE}" ]];then echo "Ocie: Config: Ecluding the following pattern from rewrite: [ ${REWRITE_EXCLUDE} ]"; add_exclude; fi; @@ -94,10 +93,10 @@ fi; # Test config and print results # Tomcat sources this script, only print if apache if [[ ! "${APP_TYPE}" == "tomcat" ]];then - HTTPD_CFG=$(ociectl --test); - if [[ ! -z "${HTTPD_CFG}" ]];then + local httpd_cfg=$(ociectl --test); + if [[ ! -z "${httpd_cfg}" ]];then echo "Ocie: Config: Test FAILED, reverting changes"; - echo "Ocie: Config: Result: ${HTTPD_CFG}"; + echo "Ocie: Config: Result: ${httpd_cfg}"; reset_config; exit 1; fi; diff --git a/src/usr/lib/ocie/include/config/tomcat b/src/usr/lib/ocie/include/config/tomcat index 3c3d3e7..3660569 100644 --- a/src/usr/lib/ocie/include/config/tomcat +++ b/src/usr/lib/ocie/include/config/tomcat @@ -3,7 +3,7 @@ . ${OCIE_LIB}/include/config/apache; # Tomcat specific -APP_PROXIES="$(echo ${VADC_IP_ADDRESS// /|} | sed 's/\./\\./g' | sed 's|\/|\\/|g')"; +local app_proxies="$(echo ${VADC_IP_ADDRESS// /|} | sed 's/\./\\./g' | sed 's|\/|\\/|g')"; if [[ -f "${OCIE_HOME}/conf/ocie-tomcat.init" ]];then reset_config; fi; @@ -13,15 +13,15 @@ function apache_mod_jk() cp "${APACHE_MODS}/jk.conf.dist" "${APACHE_MODS}/jk.conf" >/dev/null 2>&1; cp "${APACHE_MODS}/jk.load.dist" "${APACHE_MODS}/jk.load" >/dev/null 2>&1; } - + function tomcat_set_env() { echo "export JAVA_OPTS=\"${JAVA_OPTS} ${APP_PARAMS}\"" > ${CATALINA_HOME}/bin/setenv.sh - echo "export VADC_IP_REG=\"${APP_PROXIES}\"" >> ${CATALINA_HOME}/bin/setenv.sh + echo "export VADC_IP_REG=\"${app_proxies}\"" >> ${CATALINA_HOME}/bin/setenv.sh chown ${APP_OWNER}:${APP_GROUP} "${CATALINA_HOME}/bin/setenv.sh"; chmod a+x "${CATALINA_HOME}/bin/setenv.sh"; } - + function tomcat_server_cfg() { if [[ -f "${CATALINA_HOME}/conf/server.xml" ]];then @@ -31,23 +31,23 @@ function tomcat_server_cfg() cp "${CATALINA_HOME}/conf/server.xml.dist" "${CATALINA_HOME}/conf/server.xml" >/dev/null 2>&1; fi; } - + # Set environment tomcat_set_env; # Enable libapache2-mod-jk apache_mod_jk; # Ensure config is valid -CATALINA_CFG=$(ociectl --test); -if [[ ! -z "${CATALINA_CFG}" ]];then +local catalina_cfg=$(ociectl --test); +if [[ ! -z "${catalina_cfg}" ]];then echo "Ocie Config: Tomcat config test FAILED, reverting changes"; - echo "Ocie Config: Result: ${CATALINA_CFG}"; + echo "Ocie Config: Result: ${catalina_cfg}"; reset_config; exit 1; fi; # Set ready echo "Ocie Config: Tomcat Config Test PASSED, using updated configuration"; -echo "Ocie Config: Tomcat RemoteIpValve configured with [internalProxies: ${APP_PROXIES}, remoteIpHeader: ${VADC_IP_HEADER}]"; +echo "Ocie Config: Tomcat RemoteIpValve configured with [internalProxies: ${app_proxies}, remoteIpHeader: ${VADC_IP_HEADER}]"; echo "Ocie Config: Configured JAVA_OPTS with ${APP_PARAMS}"; echo "#Tomcat Initialized" > ${OCIE_HOME}/conf/ocie-tomcat.init; diff --git a/src/usr/lib/ocie/include/utils b/src/usr/lib/ocie/include/utils index ac0ba9b..ed81d21 100644 --- a/src/usr/lib/ocie/include/utils +++ b/src/usr/lib/ocie/include/utils @@ -24,13 +24,13 @@ function print_msg() # Get sha1 OR sha256 signature of directory/file, default: sha1 function get_signature() { - object="$1"; - option="${2,,}"; + local object="$1"; + local option="${2,,}"; if [[ -z "${option}" ]];then - option='sha1'; + local option='sha1'; fi; if [[ ! "${option}" == "sha1" ]] && [[ ! "${option}" == "sha256" ]];then - option='sha1'; + local option='sha1'; fi; if [[ -d "${object}" ]];then echo "$(find ${object} -type f -print0 | xargs -0 sha1sum | sort | sha1sum | cut -f1 -d' ')";