diff --git a/Dockerfile b/Dockerfile index c069160..ec10d3f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -68,8 +68,8 @@ COPY --from=builder /aws-sdk-cpp/cmake-build/aws-cpp-sdk-s3/libaws-cpp-sdk-s3.so COPY --from=builder /aws-sdk-cpp/cmake-build/aws-cpp-sdk-sns/libaws-cpp-sdk-sns.so /lib/ COPY owsec.properties.tmpl / -COPY wwwassets $OWSEC_ROOT/wwwassets -COPY templates $OWSEC_ROOT/templates +COPY wwwassets /dist/wwwassets +COPY templates /dist/templates COPY docker-entrypoint.sh / RUN wget https://raw.githubusercontent.com/Telecominfraproject/wlan-cloud-ucentral-deploy/main/docker-compose/certs/restapi-ca.pem \ -O /usr/local/share/ca-certificates/restapi-ca-selfsigned.pem diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index 3170700..8d67230 100755 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -11,7 +11,7 @@ if [[ "$TEMPLATE_CONFIG" = 'true' && ! -f "$OWSEC_CONFIG"/owsec.properties ]]; t RESTAPI_HOST_CERT=${RESTAPI_HOST_CERT:-"\$OWSEC_ROOT/certs/restapi-cert.pem"} \ RESTAPI_HOST_KEY=${RESTAPI_HOST_KEY:-"\$OWSEC_ROOT/certs/restapi-key.pem"} \ RESTAPI_HOST_KEY_PASSWORD=${RESTAPI_HOST_KEY_PASSWORD:-"mypassword"} \ - RESTAPI_WWWASSETS=${RESTAPI_WWWASSETS:-"\$OWSEC_ROOT/wwwassets"} \ + RESTAPI_WWWASSETS=${RESTAPI_WWWASSETS:-"\$OWSEC_ROOT/persist/wwwassets"} \ INTERNAL_RESTAPI_HOST_ROOTCA=${INTERNAL_RESTAPI_HOST_ROOTCA:-"\$OWSEC_ROOT/certs/restapi-ca.pem"} \ INTERNAL_RESTAPI_HOST_PORT=${INTERNAL_RESTAPI_HOST_PORT:-"17001"} \ INTERNAL_RESTAPI_HOST_CERT=${INTERNAL_RESTAPI_HOST_CERT:-"\$OWSEC_ROOT/certs/restapi-cert.pem"} \ @@ -30,11 +30,11 @@ if [[ "$TEMPLATE_CONFIG" = 'true' && ! -f "$OWSEC_CONFIG"/owsec.properties ]]; t MAILER_PASSWORD=${MAILER_PASSWORD:-"************************"} \ MAILER_SENDER=${MAILER_SENDER:-"OpenWIFI"} \ MAILER_PORT=${MAILER_PORT:-"587"} \ - MAILER_TEMPLATES=${MAILER_TEMPLATES:-"\$OWSEC_ROOT/templates"} \ + MAILER_TEMPLATES=${MAILER_TEMPLATES:-"\$OWSEC_ROOT/persist/templates"} \ KAFKA_ENABLE=${KAFKA_ENABLE:-"true"} \ KAFKA_BROKERLIST=${KAFKA_BROKERLIST:-"localhost:9092"} \ - DOCUMENT_POLICY_ACCESS=${DOCUMENT_POLICY_ACCESS:-"\$OWSEC_ROOT/wwwassets/access_policy.html"} \ - DOCUMENT_POLICY_PASSWORD=${DOCUMENT_POLICY_PASSWORD:-"\$OWSEC_ROOT/wwwassets/password_policy.html"} \ + DOCUMENT_POLICY_ACCESS=${DOCUMENT_POLICY_ACCESS:-"\$OWSEC_ROOT/persist/wwwassets/access_policy.html"} \ + DOCUMENT_POLICY_PASSWORD=${DOCUMENT_POLICY_PASSWORD:-"\$OWSEC_ROOT/persist/wwwassets/password_policy.html"} \ STORAGE_TYPE=${STORAGE_TYPE:-"sqlite"} \ STORAGE_TYPE_POSTGRESQL_HOST=${STORAGE_TYPE_POSTGRESQL_HOST:-"localhost"} \ STORAGE_TYPE_POSTGRESQL_USERNAME=${STORAGE_TYPE_POSTGRESQL_USERNAME:-"owsec"} \ @@ -49,6 +49,24 @@ if [[ "$TEMPLATE_CONFIG" = 'true' && ! -f "$OWSEC_CONFIG"/owsec.properties ]]; t envsubst < /owsec.properties.tmpl > $OWSEC_CONFIG/owsec.properties fi +# Check if wwwassets directory exists +export RESTAPI_WWWASSETS=$(grep 'openwifi.restapi.wwwassets' $OWSEC_CONFIG/owsec.properties | awk -F '=' '{print $2}' | xargs | envsubst) +if [[ ! -d "$(dirname $RESTAPI_WWWASSETS)" ]]; then + mkdir -p $(dirname $RESTAPI_WWWASSETS) +fi +if [[ ! -d "$RESTAPI_WWWASSETS" ]]; then + cp -r /dist/wwwassets $RESTAPI_WWWASSETS +fi + +# Check if templates directory exists +export MAILER_TEMPLATES=$(grep 'mailer.templates' $OWSEC_CONFIG/owsec.properties | awk -F '=' '{print $2}' | xargs | envsubst) +if [[ ! -d "$(dirname $MAILER_TEMPLATES)" ]]; then + mkdir -p $(dirname $MAILER_TEMPLATES) +fi +if [[ ! -d "$MAILER_TEMPLATES" ]]; then + cp -r /dist/templates $MAILER_TEMPLATES +fi + if [ "$1" = '/openwifi/owsec' -a "$(id -u)" = '0' ]; then if [ "$RUN_CHOWN" = 'true' ]; then chown -R "$OWSEC_USER": "$OWSEC_ROOT" "$OWSEC_CONFIG" diff --git a/helm/values.yaml b/helm/values.yaml index d18408e..ac64443 100644 --- a/helm/values.yaml +++ b/helm/values.yaml @@ -119,7 +119,7 @@ configProperties: openwifi.restapi.host.0.port: 16001 openwifi.restapi.host.0.cert: $OWSEC_ROOT/certs/restapi-cert.pem openwifi.restapi.host.0.key: $OWSEC_ROOT/certs/restapi-key.pem - openwifi.restapi.wwwassets: $OWSEC_ROOT/wwwassets + openwifi.restapi.wwwassets: $OWSEC_ROOT/persist/wwwassets openwifi.internal.restapi.host.0.backlog: 100 openwifi.internal.restapi.host.0.security: relaxed openwifi.internal.restapi.host.0.rootca: $OWSEC_ROOT/certs/restapi-ca.pem @@ -136,7 +136,7 @@ configProperties: mailer.sender: OpenWIFI mailer.loginmethod: login mailer.port: 587 - mailer.templates: $OWSEC_ROOT/templates + mailer.templates: $OWSEC_ROOT/persist/templates # ALB alb.enable: "true" alb.port: 16101