diff --git a/.gitignore b/.gitignore index 5e76326..50a5520 100644 --- a/.gitignore +++ b/.gitignore @@ -21,5 +21,6 @@ build.log ## Binaries *.tar.gz +*.jar *.pydevproject diff --git a/opensync-gateway-static-docker/pom.xml b/opensync-gateway-static-docker/pom.xml index 46bc6db..a2570cf 100644 --- a/opensync-gateway-static-docker/pom.xml +++ b/opensync-gateway-static-docker/pom.xml @@ -7,6 +7,7 @@ ../../tip-wlan-cloud-root opensync-gateway-static-docker + pom opensync-gateway-static-docker Docker definition for opensync gateway that uses static configuration @@ -35,8 +36,7 @@ 1.23 - opensync_gateway:${project.version} - + opensync-gateway:${project.version} @ try @@ -47,8 +47,9 @@ - com.telecominfraproject.wlan:opensync-gateway-static-process + com.telecominfraproject.wlan:opensync-gateway-static-process:jar + false app.jar @@ -56,6 +57,28 @@ + + opensync-gateway-and-mqtt:${project.version} + + @ + try + ${project.basedir}/src/main/docker-opensync-gateway-and-mqtt + Dockerfile + + + + + + com.telecominfraproject.wlan:opensync-gateway-static-process:jar + + false + app.jar + + + + + + diff --git a/opensync-gateway-static-docker/src/main/docker-opensync-gateway-and-mqtt/Dockerfile b/opensync-gateway-static-docker/src/main/docker-opensync-gateway-and-mqtt/Dockerfile new file mode 100644 index 0000000..8441cec --- /dev/null +++ b/opensync-gateway-static-docker/src/main/docker-opensync-gateway-and-mqtt/Dockerfile @@ -0,0 +1,34 @@ +FROM adoptopenjdk/openjdk13:alpine-jre + +LABEL maintainer="ConnectUs.ai as part of the Telecom Infrastructure Project" +LABEL version="1.0" +LABEL description="This image runs the mqtt broker (mosquitto) and \ +a statically configured OpenSync gateway." + +# Update the package list and upgrade installed packages +RUN apk update && apk upgrade +RUN mkdir -p /opt/tip-wlan/certs +VOLUME ["/opt/tip-wlan/certs"] + +# Configure mqtt broker +RUN apk add mosquitto +RUN mkdir -p /mosquitto/data /mosquitto/log +COPY app/mqtt/mosquitto.conf /etc/mosquitto/mosquitto.conf +VOLUME ["/mosquitto/data", "/mosquitto/log"] + + +# Configure OpenSync Gateway +RUN mkdir -p /app/logs /app/opensync +COPY maven/app.jar /app +COPY app/opensync/logback.xml /app/opensync/logback.xml +COPY app/run.sh /app +COPY app/opensync/config_2_ssids.json /app/opensync/config_2_ssids.json +VOLUME ["/app/logs"] + +RUN chmod +x /app/run.sh + +EXPOSE 1883 6640 6643 4043 + +WORKDIR /app +ENTRYPOINT ["/app/run.sh"] +CMD [""] diff --git a/opensync-gateway-static-docker/src/main/docker-opensync-gateway-and-mqtt/app/mqtt/mosquitto.conf b/opensync-gateway-static-docker/src/main/docker-opensync-gateway-and-mqtt/app/mqtt/mosquitto.conf new file mode 100644 index 0000000..8682fc8 --- /dev/null +++ b/opensync-gateway-static-docker/src/main/docker-opensync-gateway-and-mqtt/app/mqtt/mosquitto.conf @@ -0,0 +1,18 @@ +cafile /opt/tip-wlan/certs/cacert.pem +certfile /opt/tip-wlan/certs/mqttservercert.pem +keyfile /opt/tip-wlan/certs/mqttserverkey_dec.pem +require_certificate true +use_identity_as_username true +allow_anonymous false +allow_duplicate_messages true +autosave_interval 900 +log_dest file /mosquitto/log/mosquitto.log +max_queued_bytes 0 +max_queued_messages 0 +message_size_limit 0 +persistence true +persistence_file mosquitto.db +persistence_location /mosquitto/data/ +pid_file /mosquitto/mosquitto.pid +port 1883 + diff --git a/opensync-gateway-static-docker/src/main/docker-opensync-gateway-and-mqtt/app/opensync/config_2_ssids.json b/opensync-gateway-static-docker/src/main/docker-opensync-gateway-and-mqtt/app/opensync/config_2_ssids.json new file mode 100644 index 0000000..6486caf --- /dev/null +++ b/opensync-gateway-static-docker/src/main/docker-opensync-gateway-and-mqtt/app/opensync/config_2_ssids.json @@ -0,0 +1,27 @@ +{ + "_type" : "OpensyncAPConfig", + "radioConfig" : { + "_type" : "OpensyncAPRadioConfig", + "country" : "CA", + "radioChannel24G" : 1, + "radioChannel5LG" : 44, + "radioChannel5HG" : 108 + }, + "ssidConfigs" : [ { + "_type" : "OpensyncAPSsidConfig", + "radioType" : "is2dot4GHz", + "ssid" : "Connectus-local", + "encryption" : "WPA-PSK", + "key" : "12345678", + "mode" : "2", + "broadcast" : true + }, { + "_type" : "OpensyncAPSsidConfig", + "radioType" : "is5GHz", + "ssid" : "Connectus-local-5", + "encryption" : "WPA-PSK", + "key" : "12345678", + "mode" : "2", + "broadcast" : true + } ] +} diff --git a/opensync-gateway-static-docker/src/main/docker-opensync-gateway-and-mqtt/app/opensync/logback.xml b/opensync-gateway-static-docker/src/main/docker-opensync-gateway-and-mqtt/app/opensync/logback.xml new file mode 100644 index 0000000..67c0aee --- /dev/null +++ b/opensync-gateway-static-docker/src/main/docker-opensync-gateway-and-mqtt/app/opensync/logback.xml @@ -0,0 +1,80 @@ + + + + + + + + + + + + + %d{yyyy-MM-DD HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + + + + + /app/logs/mqttData.log + true + + %date %msg%n + + + /app/logs/mqttData.%i.log.gz + 1 + 3 + + + 20MB + + + + + + /app/logs/opensyncgw.log + true + + %date %level [%thread] %logger{36} [%file:%line] %msg%n + + + /app/logs/opensyncgw.%i.log.gz + 1 + 3 + + + 20MB + + + + + + + + + + + + + + + + + + + + + + + diff --git a/opensync-gateway-static-docker/src/main/docker-opensync-gateway-and-mqtt/app/run.sh b/opensync-gateway-static-docker/src/main/docker-opensync-gateway-and-mqtt/app/run.sh new file mode 100755 index 0000000..70662ea --- /dev/null +++ b/opensync-gateway-static-docker/src/main/docker-opensync-gateway-and-mqtt/app/run.sh @@ -0,0 +1,122 @@ +#!/bin/sh + +# Prepare the hosts file - do it only if does not have required entries +n1=`grep opensync-mqtt-broker /etc/hosts | wc -l` + +if [[ $n1 -eq 0 ]] +then + echo Adding opensync-mqtt-broker to /etc/hosts + echo "127.0.0.1 opensync-mqtt-broker" >> /etc/hosts +fi + +n2=`grep opensync-wifi-controller /etc/hosts | wc -l` + +if [[ $n2 -eq 0 ]] +then + echo Adding opensync-wifi-controller to /etc/hosts + echo "127.0.0.1 opensync-wifi-controller" >> /etc/hosts +fi + + +echo Starting mosquitto MQTT broker +/usr/sbin/mosquitto -d -c /etc/mosquitto/mosquitto.conf + +# Provide default values for the environment variables +MQTT_CLIENT_KEYSTORE_PASSWORD="${MQTT_CLIENT_KEYSTORE_PASSWORD:=mypassword}" +MQTT_CLIENT_KEYSTORE_FILE="${MQTT_CLIENT_KEYSTORE_FILE:=/opt/tip-wlan/certs/client_keystore.jks}" +MQTT_TRUSTSTORE_FILE="${MQTT_TRUSTSTORE_FILE:=/opt/tip-wlan/certs/truststore.jks}" +MQTT_TRUSTSTORE_PASSWORD="${MQTT_TRUSTSTORE_PASSWORD:=mypassword}" + +OVSDB_SERVER_KEYSTORE_FILE="${OVSDB_SERVER_KEYSTORE_FILE:=/opt/tip-wlan/certs/server.pkcs12}" +OVSDB_SERVER_KEYSTORE_PASSWORD="${OVSDB_SERVER_KEYSTORE_PASSWORD:=mypassword}" +OVSDB_SERVER_TRUSTSTORE_FILE="${OVSDB_SERVER_TRUSTSTORE_FILE:=/opt/tip-wlan/certs/truststore.jks}" +OVSDB_SERVER_TRUSTSTORE_PASSWORD="${OVSDB_SERVER_TRUSTSTORE_PASSWORD:=mypassword}" +OVSDB_CONFIG_FILE="${OVSDB_CONFIG_FILE:=/app/opensync/config_2_ssids.json}" + +EXT_CLIENT_KEYSTORE_PASSWORD="${EXT_CLIENT_KEYSTORE_PASSWORD:=mypassword}" +EXT_CLIENT_KEYSTORE_FILE="${EXT_CLIENT_KEYSTORE_FILE:=/opt/tip-wlan/certs/client_keystore.jks}" +EXT_TRUSTSTORE_FILE="${EXT_TRUSTSTORE_FILE:=/opt/tip-wlan/certs/truststore.jks}" +EXT_TRUSTSTORE_PASSWORD="${EXT_TRUSTSTORE_PASSWORD:=mypassword}" + +MQTT_BROKER_HOST="${MQTT_BROKER_HOST:=opensync-mqtt-broker}" +OVSDB_MANAGER_HOST="${OVSDB_MANAGER_HOST:=opensync-wifi-controller}" + +LOGBACK_CONFIG_FILE="${LOGBACK_CONFIG_FILE:=/app/opensync/logback.xml}" + +# Create ssl.properties file +cat > /app/ssl.properties < /app/httpClientConfig.json < /app/opensync-wifi-controller-stdout.out 2>&1 +