100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps
Java asset-managementbuildingdashboarddataplatformdevice-managementedge-computingenergyenergy-managementenergy-monitorfleet-managementfleet-telematicsiotiot-applicationiot-platformmodbusmqttmqtt-brokerota-updaterules-enginesmartcity
Some update
Christian Bauer96396c34fa42
diff --git a/README.md b/README.mdindex d7475f890..256552171 100644--- a/README.md+++ b/README.md@@ -1,108 +1,36 @@# OpenRemote--#### This is pre-alpha software under development, we are working on internal Milestone 2. Older code we are currently migrating can be found [in the M1 repository](https://github.com/openremote/or-controller).-------* **Live Demo**: http://demo2.openremote.com (sign-in with `test/test` or `admin/admin`)* **Docker Images**: https://hub.docker.com/u/openremote/-* **Documentation/Wiki:** https://github.com/openremote/openremote/wiki+* **Documentation/Wiki:** https://github.com/openremote/Documentation/wiki* **Community:** https://groups.google.com/forum/#!forum/openremotecommunity* **Issues:** https://github.com/openremote/openremote/issues-## Getting started--You'll need a Docker host to run this software. Please see our [installation documentation](https://github.com/openremote/openremote/wiki/Installing-OpenRemote) for more information.--## Setting up a development workspace--### Preparing the environment--All Docker and Gradle commands should be executed in the project root directory.--NOTE: For Docker volume mapping to work correctly on Windows and OS X ensure that your working directory is located somewhere under your home directory--NOTE: The Docker virtual machine's time will drift when you are using VirtualBox. You will see "token is not active" verification errors if the time skew is too large. Until this is [fixed](https://github.com/boot2docker/boot2docker/issues/69), periodically run `docker-machine ssh default 'sudo ntpclient -s -h pool.ntp.org'` to update the virtual machine's clock.--NOTE: Working with Docker might leave exited containers, untagged images, and dangling volumes. The following bash function can be used to clean up:--```-function dcleanup(){- docker rm -v $(docker ps --filter status=exited -q 2>/dev/null) 2>/dev/null- docker rmi $(docker images --filter dangling=true -q 2>/dev/null) 2>/dev/null- docker volume rm $(docker volume ls -qf dangling=true 2>/dev/null) 2>/dev/null-}-```--For authentication and authorization we are using [Keycloak](http://keycloak.jboss.org/).--We are using PostgreSQL as a database backend. Test and demo data will be installed fresh every time you start the services. Note that this is not suitable for a production configuration!--To access the database directly with an SQL console, run:--```-docker exec -it openremote_postgres_dev_1 su -s /bin/sh - postgres -c "sh -c 'psql openremote'"-```--### Run required services--All services required for development can be deployed with Docker Compose, configured in `docker-compose.yml`. Execute `docker-compose up` in the project root to download required images (this might take a while and give no feedback) and run containers.--The default configuration of all `*Service` classes is for host IP `192.168.99.100`. If this is not your Docker host IP, you must set various environment variables (see [Demo](https://raw.githubusercontent.com/openremote/openremote/master/docker-compose-demo.yml)).--### Run GWT code server--The GWT compiler will listen for compilation requests and produce Javascript code from our Java code. Start and keep it running in the background with `./gradlew -p manager/client gwtSuperDev`.--### Import into IntelliJ IDEA--- Create a "New Project From Existing Sources" and import as a Gradle project--### Import into Eclipse--- Run `./gradlew eclipse`-- In Eclipse go to File > Import and import the project as "Existing Projects into Workspace"--### Run Manager server--Configure your IDE and set up a *Run Configuration*:--- Module: `manager/server`-- Working directory: (Set to project root directory)-- Main class: `org.openremote.manager.server.Server`+## Getting started with OpenRemote-You can now open http://localhost:8080/ in your browser.+Please see our [installation documentation](https://github.com/openremote/openremote/wiki/Installing-OpenRemote) for more information.-*NOTE: Please be aware that currently by default the web server binds to all interfaces (i.e. `0.0.0.0`)*+## Contributing to OpenRemote-*NOTE: During development it can be useful to disable all security checks on the HTTP remote API, for example, to test without authentication and authorization in a simple HTTP client such as `curl`. Start the Manager with the `DISABLE_API_SECURITY=true` environment variable setting to disable security.*+We work with Java, Groovy, Gradle, Docker, and wide range of APIs and protocol implementations. Clone or checkout this project and send us pull requests.-### Running tests+Please see our [developer documentation](https://github.com/openremote/openremote/wiki/Contributing-to-OpenRemote) for more information.-You can run the tests of the `manager` project with `./gradlew test` or run the individual test classes in your IDE directly. The working directory must always be set to the project root diretory.+## Discuss OpenRemote-Note that some of these tests are end-to-end tests that require the whole environment to be running. This means your Keycloak and PostgreSQL containers will be used, and data will be inserted and deleted during a test run. You might want to start with clean containers before running tests and you might have to restart containers after (failed) tests.+Join us on the [community group](https://groups.google.com/forum/#!forum/openremotecommunity).-### Updating map data+## OpenRemote Projects-We currently do not have our own pipeline for extracting/converting OSM data into vector tilesets but depend on the extracts offered on https://github.com/osm2vectortiles/osm2vectortiles.+This is the platform project of OpenRemote, where we integrate services and code from many projects. Some projects developed by OpenRemote are co-located in this repository, others are dependencies that are developed and released independently.-You can extract smaller tilesets with the following procedure:+* [Controller](https://github.com/openremote/Controller) - An IoT gateway with an HTTP API, it manages connections and protocols to devices and 3rd party services. Local state and rule execution provides intelligence at the edge of the network. Controllers can be provisioned directly through the file system or synchronize automatically with the Beehive service.-1. Install tilelive converter:- `npm install -g mapnik mbtiles tilelive tilelive-bridge`-1. Select and copy boundary box coordinates of desired region:- http://tools.geofabrik.de/calc/#tab=1-1. Extract the region with:- `tilelive-copy --minzoom=0 --maxzoom=14 --bounds="BOUNDARY BOX COORDINATES" theworld.mbtiles myextract.mbtiles`+* [Designer](https://github.com/openremote/Designer) - Web application for configuring controllers and devices, writing rules, and editing user interfaces.-## Production+* [Web Console](https://github.com/openremote/WebConsole) - Connecting to a controller or its proxy, this web application renders panel configurations hosted on the controller and allows the user to monitor and interact with a controller.-### Publishing images+* [Controller Command Service (CCS)](https://github.com/openremote/CCS) - A queue where you can put a command for any controller through HTTP. The controller receives commands through push or pull and executes them. Commands for establishing a secure tunnel on a socket of choice are included, thus implementing a remote proxy of a Controller.-Build Docker images with `./gradlew clean buildImage`. Remove old images before if you don't want to use the Docker build cache.+TODO: Document other projects-You can start and test these images with the `docker-compose-demo.yml` configuration.-You can also directly build and push the image to our [Docker Hub Account](https://hub.docker.com/u/openremote/): `/gradlew clean pushImage -PdockerHubUsername=username -PdockerHubPassword=secret`diff --git a/base/README.md b/base/README.mdnew file mode 100644index 000000000..9717f9c94--- /dev/null+++ b/base/README.md@@ -0,0 +1,13 @@+# OpenRemote Base Images++Build Docker base images before you build any other projects, in the main project root run:++```+./gradlew clean buildBaseImage+```++To publish base images, execute:++```+./gradlew clean pushImage -PdockerHubUsername=username -PdockerHubPassword=secret+```diff --git a/keycloak/Dockerfile-demo b/base/keycloak/Dockerfilesimilarity index 100%rename from keycloak/Dockerfile-demorename to base/keycloak/Dockerfilediff --git a/keycloak/Dockerfile-dev b/base/keycloak/Dockerfile-devsimilarity index 100%rename from keycloak/Dockerfile-devrename to base/keycloak/Dockerfile-devdiff --git a/postgres/build.gradle b/base/keycloak/build.gradlesimilarity index 81%rename from postgres/build.gradlerename to base/keycloak/build.gradleindex 7a12d4563..507ce4509 100644--- a/postgres/build.gradle+++ b/base/keycloak/build.gradle@@ -2,7 +2,7 @@ import com.bmuschko.gradle.docker.tasks.image.*task buildImage(type: DockerBuildImage) {inputDir = projectDir- dockerFile = file("$projectDir/Dockerfile-demo")+ dockerFile = file("$projectDir/Dockerfile")tag = dockerImageName}diff --git a/keycloak/changeDatabase.xsl b/base/keycloak/changeDatabase.xslsimilarity index 100%rename from keycloak/changeDatabase.xslrename to base/keycloak/changeDatabase.xsldiff --git a/keycloak/keycloak-server-json-dev.jq b/base/keycloak/keycloak-server-json-dev.jqsimilarity index 100%rename from keycloak/keycloak-server-json-dev.jqrename to base/keycloak/keycloak-server-json-dev.jqdiff --git a/keycloak/module.xml b/base/keycloak/module.xmlsimilarity index 100%rename from keycloak/module.xmlrename to base/keycloak/module.xmldiff --git a/keycloak/setProxyForwarding.xsl b/base/keycloak/setProxyForwarding.xslsimilarity index 100%rename from keycloak/setProxyForwarding.xslrename to base/keycloak/setProxyForwarding.xsldiff --git a/keycloak/theme/account/account.ftl b/base/keycloak/theme/account/account.ftlsimilarity index 100%rename from keycloak/theme/account/account.ftlrename to base/keycloak/theme/account/account.ftldiff --git a/keycloak/theme/account/password.ftl b/base/keycloak/theme/account/password.ftlsimilarity index 100%rename from keycloak/theme/account/password.ftlrename to base/keycloak/theme/account/password.ftldiff --git a/keycloak/theme/account/template.ftl b/base/keycloak/theme/account/template.ftlsimilarity index 100%rename from keycloak/theme/account/template.ftlrename to base/keycloak/theme/account/template.ftldiff --git a/keycloak/theme/account/theme.properties b/base/keycloak/theme/account/theme.propertiessimilarity index 100%rename from keycloak/theme/account/theme.propertiesrename to base/keycloak/theme/account/theme.propertiesdiff --git a/keycloak/theme/login/login.ftl b/base/keycloak/theme/login/login.ftlsimilarity index 100%rename from keycloak/theme/login/login.ftlrename to base/keycloak/theme/login/login.ftldiff --git a/keycloak/theme/login/template.ftl b/base/keycloak/theme/login/template.ftlsimilarity index 100%rename from keycloak/theme/login/template.ftlrename to base/keycloak/theme/login/template.ftldiff --git a/keycloak/theme/login/theme.properties b/base/keycloak/theme/login/theme.propertiessimilarity index 100%rename from keycloak/theme/login/theme.propertiesrename to base/keycloak/theme/login/theme.propertiesdiff --git a/keycloak/wait-for-it.sh b/base/keycloak/wait-for-it.shsimilarity index 100%rename from keycloak/wait-for-it.shrename to base/keycloak/wait-for-it.shdiff --git a/base/mysql/Dockerfile b/base/mysql/Dockerfilenew file mode 100644index 000000000..103c917e3--- /dev/null+++ b/base/mysql/Dockerfile@@ -0,0 +1,3 @@+FROM mysql:5.7++ADD scripts /docker-entrypoint-initdb.d/diff --git a/keycloak/build.gradle b/base/mysql/build.gradlesimilarity index 58%rename from keycloak/build.gradlerename to base/mysql/build.gradleindex 7a12d4563..ab5008a88 100644--- a/keycloak/build.gradle+++ b/base/mysql/build.gradle@@ -1,12 +1,12 @@import com.bmuschko.gradle.docker.tasks.image.*-task buildImage(type: DockerBuildImage) {+task buildBaseImage(type: DockerBuildImage) {inputDir = projectDir- dockerFile = file("$projectDir/Dockerfile-demo")+ dockerFile = file("$projectDir/Dockerfile")tag = dockerImageName}task pushImage(type: DockerPushImage) {- dependsOn buildImage+ dependsOn buildBaseImageimageName = dockerImageName}\ No newline at end of filediff --git a/base/mysql/scripts/10_CreateLegacyBeehiveSchema.sql b/base/mysql/scripts/10_CreateLegacyBeehiveSchema.sqlnew file mode 100644index 000000000..6d16a7cda--- /dev/null+++ b/base/mysql/scripts/10_CreateLegacyBeehiveSchema.sql@@ -0,0 +1,47 @@+CREATE TABLE IF NOT EXISTS `account` (+ `oid` BIGINT(20) NOT NULL AUTO_INCREMENT,+ PRIMARY KEY (`oid`))+ENGINE = InnoDB+DEFAULT CHARACTER SET = utf8;++CREATE TABLE IF NOT EXISTS `user` (+ `oid` BIGINT(20) NOT NULL AUTO_INCREMENT,+ `password` VARCHAR(255) NOT NULL,+ `username` VARCHAR(255) NOT NULL,+ `account_oid` BIGINT(20) NULL DEFAULT NULL,+ `email` VARCHAR(255) NULL DEFAULT NULL,+ `register_time` DATETIME NULL DEFAULT NULL,+ `token` VARCHAR(255) NULL DEFAULT NULL,+ `valid` BIT(1) NULL DEFAULT NULL,+ PRIMARY KEY (`oid`) ,+ UNIQUE INDEX `username` (`username` ASC) ,+ INDEX `IDX__USER__USERNAME` (`account_oid` ASC) ,+ CONSTRAINT `FK__USER__ACCOUNT__ACCOUNT_OID`+ FOREIGN KEY (`account_oid`)+ REFERENCES `account` (`oid`))+ENGINE = InnoDB+DEFAULT CHARACTER SET = utf8;++CREATE TABLE IF NOT EXISTS `role` (+ `oid` BIGINT(20) NOT NULL AUTO_INCREMENT,+ `name` VARCHAR(255) NULL DEFAULT NULL,+ PRIMARY KEY (`oid`) )+ENGINE = InnoDB+DEFAULT CHARACTER SET = utf8;++CREATE TABLE IF NOT EXISTS `user_role` (+ `user_oid` BIGINT(20) NOT NULL,+ `role_oid` BIGINT(20) NOT NULL,+ INDEX `IDX__USER_OID` (`user_oid` ASC) ,+ INDEX `IDX__ROLE_OID` (`role_oid` ASC) ,+ CONSTRAINT `FK__USER_ROLE__ROLE__ROLE_OID`+ FOREIGN KEY (`role_oid`)+ REFERENCES `role` (`oid`),+ CONSTRAINT `FK__USER_ROLE__USER__USER_OID`+ FOREIGN KEY (`user_oid`)+ REFERENCES `user` (`oid`))+ENGINE = InnoDB+DEFAULT CHARACTER SET = utf8;++CREATE VIEW tomcat_user_role+ AS SELECT u.username, r.name AS rolename FROM user_role ur JOIN user u ON ur.user_oid = u.oid JOIN role r ON ur.role_oid = r.oid;\ No newline at end of filediff --git a/base/mysql/scripts/11_CreateLegacyBeehiveDefaultData.sql b/base/mysql/scripts/11_CreateLegacyBeehiveDefaultData.sqlnew file mode 100644index 000000000..129e452d0--- /dev/null+++ b/base/mysql/scripts/11_CreateLegacyBeehiveDefaultData.sql@@ -0,0 +1,24 @@+INSERT INTO role VALUES (1, 'service-admin');+INSERT INTO role VALUES (2, 'account-owner');++INSERT INTO account VALUES (1);+INSERT INTO user ( oid,+ password ,+ username,+ account_oid,+ email,+ register_time ,+ token ,+ valid) VALUES (1, md5('password{admin}'), 'admin', 1, '[email protected]', now(), NULL, 1);+INSERT INTO user_role VALUES (1, 1);++INSERT INTO account VALUES (2);+INSERT INTO user ( oid,+ password ,+ username,+ account_oid,+ email,+ register_time ,+ token ,+ valid) VALUES (2, md5('password{secret}'), 'openremote', 2, '[email protected]', now(), NULL, 1);+INSERT INTO user_role VALUES (2, 2);\ No newline at end of filediff --git a/base/mysql/scripts/20_CreateTables.sql b/base/mysql/scripts/20_CreateTables.sqlnew file mode 100644index 000000000..19d251cb7--- /dev/null+++ b/base/mysql/scripts/20_CreateTables.sql@@ -0,0 +1,21 @@+CREATE TABLE IF NOT EXISTS discovered_device (+ id BIGINT(20) NOT NULL AUTO_INCREMENT,+ device_identifier VARCHAR(255) NOT NULL,+ device_name VARCHAR(255) NOT NULL,+ protocol VARCHAR(255),+ model VARCHAR(255),+ type VARCHAR(255),+ account_id VARCHAR(64),+ PRIMARY KEY (id))+ENGINE = InnoDB+DEFAULT CHARACTER SET = utf8;++CREATE TABLE IF NOT EXISTS discovered_device_attributes (+ discovered_device_id BIGINT(20) NOT NULL,+ attribute_key VARCHAR(255) NOT NULL,+ attribute_value VARCHAR(1000) NOT NULL,+ PRIMARY KEY (discovered_device_id, attribute_key),+ CONSTRAINT FOREIGN KEY (discovered_device_id)+ REFERENCES discovered_device (id))+ENGINE = InnoDB+DEFAULT CHARACTER SET = utf8;\ No newline at end of filediff --git a/base/mysql/scripts/30_CreateTables.sql b/base/mysql/scripts/30_CreateTables.sqlnew file mode 100644index 000000000..7bd6eb241--- /dev/null+++ b/base/mysql/scripts/30_CreateTables.sql@@ -0,0 +1,135 @@+CREATE TABLE IF NOT EXISTS `controller_config` (+ `oid` BIGINT(20) NOT NULL AUTO_INCREMENT,+ `category` VARCHAR(255) NULL DEFAULT NULL,+ `name` VARCHAR(255) NOT NULL,+ `value` TEXT NULL DEFAULT NULL,+ `account_oid` BIGINT(20) NULL DEFAULT NULL,+ PRIMARY KEY (`oid`) ,+ INDEX `IDX__CONTROLLER_CONFIG__ACCOUNT_OID` (`account_oid` ASC) ,+ CONSTRAINT `FK__CONTROLLER_CONFIG__ACCOUNT__ACCOUNT_OID`+ FOREIGN KEY (`account_oid`)+ REFERENCES `account` (`oid`))+ENGINE = InnoDB+DEFAULT CHARACTER SET = utf8;+++CREATE TABLE IF NOT EXISTS `device` (+ `oid` BIGINT(20) NOT NULL AUTO_INCREMENT,+ `model` VARCHAR(255) NULL DEFAULT NULL,+ `name` VARCHAR(255) NOT NULL,+ `vendor` VARCHAR(255) NULL DEFAULT NULL,+ `account_oid` BIGINT(20) NULL DEFAULT NULL,+ PRIMARY KEY (`oid`) ,+ INDEX `IDX__DEVICE__ACCOUNT_OID` (`account_oid` ASC) ,+ CONSTRAINT `FK__DEVICE__ACCOUNT__ACCOUNT_OID`+ FOREIGN KEY (`account_oid`)+ REFERENCES `account` (`oid`))+ENGINE = InnoDB+DEFAULT CHARACTER SET = utf8;+++CREATE TABLE IF NOT EXISTS `protocol` (+ `oid` BIGINT(20) NOT NULL AUTO_INCREMENT,+ `type` VARCHAR(255) NOT NULL,+ PRIMARY KEY (`oid`) )+ENGINE = InnoDB+DEFAULT CHARACTER SET = utf8;++CREATE TABLE IF NOT EXISTS `protocol_attr` (+ `oid` BIGINT(20) NOT NULL AUTO_INCREMENT,+ `name` VARCHAR(255) NOT NULL,+ `value` TEXT NOT NULL,+ `protocol_oid` BIGINT(20) NOT NULL,+ PRIMARY KEY (`oid`) ,+ INDEX `IDX__PROTOCOL_ATTR__PROTOCOL_OID` (`protocol_oid` ASC) ,+ CONSTRAINT `FK_PROTOCOL_ATTR__PROTOCOL__PROTOCOL_OID`+ FOREIGN KEY (`protocol_oid`)+ REFERENCES `protocol` (`oid`))+ENGINE = InnoDB+DEFAULT CHARACTER SET = utf8;+++CREATE TABLE IF NOT EXISTS `device_command` (+ `oid` BIGINT(20) NOT NULL AUTO_INCREMENT,+ `name` VARCHAR(255) NOT NULL,+ `sectionId` VARCHAR(255) NULL DEFAULT NULL,+ `device_oid` BIGINT(20) NULL DEFAULT NULL,+ `protocol_oid` BIGINT(20) NOT NULL,+ PRIMARY KEY (`oid`) ,+ INDEX `IDX__DEVICE_COMMAND__DEVICE_OID` (`device_oid` ASC) ,+ INDEX `IDX__DEVICE_COMMAND__PROTOCOL_OID` (`protocol_oid` ASC) ,+ CONSTRAINT `FK__DEVICE_COMMAND__DEVICE__DEVICE_OID`+ FOREIGN KEY (`device_oid`)+ REFERENCES `device` (`oid`),+ CONSTRAINT `FK__DEVICE_COMMAND__PROTOCOL__PROTOCOL_OID`+ FOREIGN KEY (`protocol_oid`)+ REFERENCES `protocol` (`oid`))+ENGINE = InnoDB+DEFAULT CHARACTER SET = utf8;++CREATE TABLE IF NOT EXISTS `sensor` (+ `dtype` VARCHAR(31) NOT NULL,+ `oid` BIGINT(20) NOT NULL AUTO_INCREMENT,+ `name` VARCHAR(255) NOT NULL,+ `type` INT(11) NULL DEFAULT NULL,+ `device_oid` BIGINT(20) NULL DEFAULT NULL,+ `account_oid` BIGINT(20) NULL DEFAULT NULL,+ PRIMARY KEY (`oid`) ,+ INDEX `IDX__SENSOR__ACCOUNT_OID` (`account_oid` ASC) ,+ INDEX `IDX__SENSOR__DEVICE_OID` (`device_oid` ASC) ,+ CONSTRAINT `FK__SENSOR__ACCOUNT__ACCOUNT_OID`+ FOREIGN KEY (`account_oid`)+ REFERENCES `account` (`oid`),+ CONSTRAINT `FK__SENSOR__DEVICE__DEVICE_OID`+ FOREIGN KEY (`device_oid`)+ REFERENCES `device` (`oid`))+ENGINE = InnoDB+DEFAULT CHARACTER SET = utf8;++CREATE TABLE IF NOT EXISTS `state` (+ `oid` BIGINT(20) NOT NULL AUTO_INCREMENT,+ `name` VARCHAR(255) NULL DEFAULT NULL,+ `value` VARCHAR(255) NULL DEFAULT NULL,+ `sensor_oid` BIGINT(20) NOT NULL,+ PRIMARY KEY (`oid`) ,+ INDEX `IDX__STATE__SENSOR_OID` (`sensor_oid` ASC) ,+ CONSTRAINT `FK__STATE__SENSOR__SENSOIR_OID`+ FOREIGN KEY (`sensor_oid`)+ REFERENCES `sensor` (`oid`))+ENGINE = InnoDB+DEFAULT CHARACTER SET = utf8;++CREATE TABLE IF NOT EXISTS `range_sensor` (+ `max_value` INT(11) NULL DEFAULT NULL,+ `min_value` INT(11) NULL DEFAULT NULL,+ `oid` BIGINT(20) NOT NULL,+ PRIMARY KEY (`oid`) ,+ INDEX `IDX__RANGE_SENSOR__OID` (`oid` ASC) ,+ CONSTRAINT `FK__RANGE_SENSOR__SENSOR__OID`+ FOREIGN KEY (`oid`)+ REFERENCES `sensor` (`oid`))+ENGINE = InnoDB+DEFAULT CHARACTER SET = utf8;++CREATE TABLE IF NOT EXISTS `command_ref_item` (+ `type` VARCHAR(31) NOT NULL,+ `oid` BIGINT(20) NOT NULL AUTO_INCREMENT,+ `sensor_oid` BIGINT(20) NULL DEFAULT NULL,+ `slider_oid` BIGINT(20) NULL DEFAULT NULL,+ `on_switch_oid` BIGINT(20) NULL DEFAULT NULL,+ `off_switch_oid` BIGINT(20) NULL DEFAULT NULL,+ `target_device_command_oid` BIGINT(20) NULL DEFAULT NULL,+ PRIMARY KEY (`oid`) ,+ INDEX `IDX__COMMAND_REF_ITEM__SENSOR_OID` (`sensor_oid` ASC) ,+ INDEX `IDX__COMMAND_REF_ITEM__TARGET_DEVICE_COMMAND_OID` (`target_device_command_oid` ASC) ,+ INDEX `IDX__COMMAND_REF_ITEM__ON_SWITCH_OID` (`on_switch_oid` ASC) ,+ INDEX `IDX__COMMAND_REF_ITEM__OFF_SWITCH_OID` (`off_switch_oid` ASC) ,+ INDEX `IDX__COMMAND_REF_ITEM__SLIDER_OID` (`slider_oid` ASC) ,+ CONSTRAINT `FK__COMMAND_REF_ITEM__DEVICE_COMMAND__TARGET_DEVICE_COMMAND_OID`+ FOREIGN KEY (`target_device_command_oid`)+ REFERENCES `device_command` (`oid`),+ CONSTRAINT `FK__COMMAND_REF_ITEM__SENSOR__SENSOR_OID`+ FOREIGN KEY (`sensor_oid`)+ REFERENCES `sensor` (`oid`))+ENGINE = InnoDB+DEFAULT CHARACTER SET = utf8;\ No newline at end of filediff --git a/base/mysql/scripts/40_CreateTables.sql b/base/mysql/scripts/40_CreateTables.sqlnew file mode 100644index 000000000..1cc108cc3--- /dev/null+++ b/base/mysql/scripts/40_CreateTables.sql@@ -0,0 +1,38 @@+CREATE TABLE IF NOT EXISTS `controller` (+ `oid` BIGINT(20) NOT NULL AUTO_INCREMENT,+ `linked` TINYINT(1) NOT NULL,+ `macAddress` VARCHAR(255) NULL DEFAULT NULL,+ `account_oid` BIGINT(20) NULL DEFAULT NULL,+ PRIMARY KEY (`oid`) ,+ INDEX `IDX__CONTROLLER__ACCOUNT_OID` (`account_oid` ASC) ,+ CONSTRAINT `FK__CONTROLLER__ACCOUNT__ACCOUNT_OID`+ FOREIGN KEY (`account_oid`)+ REFERENCES `account` (`oid`))+ENGINE = InnoDB+DEFAULT CHARACTER SET = utf8;++CREATE TABLE IF NOT EXISTS `controller_command` (+ `oid` BIGINT(20) NOT NULL AUTO_INCREMENT,+ `creationDate` DATETIME NULL DEFAULT NULL,+ `state` VARCHAR(255) NULL DEFAULT NULL,+ `type` VARCHAR(255) NULL DEFAULT NULL,+ `account_oid` BIGINT(20) NULL DEFAULT NULL,+ PRIMARY KEY (`oid`) ,+ INDEX `IDX__CONTROLLER_COMMAND__ACCOUNT_OID` (`account_oid` ASC) ,+ CONSTRAINT `FK__CONTROLLER_COMMAND__ACCOUNT__ACCOUNT_OID`+ FOREIGN KEY (`account_oid`)+ REFERENCES `account` (`oid`))+ENGINE = InnoDB+DEFAULT CHARACTER SET = utf8;++CREATE TABLE IF NOT EXISTS `initiate_proxy_controller_command` (+ `oid` BIGINT(20) NOT NULL,+ `token` VARCHAR(255) NULL DEFAULT NULL,+ `url` VARCHAR(255) NULL DEFAULT NULL,+ PRIMARY KEY (`oid`) ,+ INDEX `IDX__INITIATE_PROXY_CONTROLLER_COMMAND__OID` (`oid` ASC) ,+ CONSTRAINT `FK__INITIATE_PROXY_CONTROLLER_COMMAND__CONTROLLER_COMMAND__OID`+ FOREIGN KEY (`oid`)+ REFERENCES `controller_command` (`oid`))+ENGINE = InnoDB+DEFAULT CHARACTER SET = utf8;\ No newline at end of filediff --git a/postgres/Dockerfile-demo b/base/postgres/Dockerfilesimilarity index 80%rename from postgres/Dockerfile-demorename to base/postgres/Dockerfileindex deaa0188e..f8f905cc2 100644--- a/postgres/Dockerfile-demo+++ b/base/postgres/Dockerfile@@ -12,7 +12,7 @@# The above copyright notice and this permission notice shall be# included in all copies or substantial portions of the Software.-FROM postgres:9.6+FROM postgres:9.6.1ENV POSTGIS_MAJOR 2.3ENV POSTGIS_VERSION 2.3.0+dfsg-2.pgdg80+1@@ -24,9 +24,7 @@ RUN apt-get update \postgis=$POSTGIS_VERSION \&& rm -rf /var/lib/apt/lists/*-RUN mkdir -p /docker-entrypoint-initdb.d--ADD 01-init-user.sh /docker-entrypoint-initdb.d/01-init-user.sh-ADD 02-init-postgis.sh /docker-entrypoint-initdb.d/02-init-postgis.sh+ENV POSTGRES_USER postgres+ADD scripts /docker-entrypoint-initdb.d/RUN chmod +x /docker-entrypoint-initdb.d/*.sh\ No newline at end of filediff --git a/base/postgres/build.gradle b/base/postgres/build.gradlenew file mode 100644index 000000000..ab5008a88--- /dev/null+++ b/base/postgres/build.gradle@@ -0,0 +1,12 @@+import com.bmuschko.gradle.docker.tasks.image.*++task buildBaseImage(type: DockerBuildImage) {+ inputDir = projectDir+ dockerFile = file("$projectDir/Dockerfile")+ tag = dockerImageName+}++task pushImage(type: DockerPushImage) {+ dependsOn buildBaseImage+ imageName = dockerImageName+}\ No newline at end of filediff --git a/postgres/01-init-user.sh b/base/postgres/scripts/01-init-user.shsimilarity index 100%rename from postgres/01-init-user.shrename to base/postgres/scripts/01-init-user.shdiff --git a/postgres/02-init-postgis.sh b/base/postgres/scripts/02-init-postgis.shsimilarity index 100%rename from postgres/02-init-postgis.shrename to base/postgres/scripts/02-init-postgis.shdiff --git a/base/tomcat/Dockerfile b/base/tomcat/Dockerfilenew file mode 100644index 000000000..fa4f0d35c--- /dev/null+++ b/base/tomcat/Dockerfile@@ -0,0 +1,18 @@+FROM tomcat:7.0-jre7++# Remove default webapps+RUN rm -rf /usr/local/tomcat/webapps/*++# Create certificate+RUN keytool -genkey -noprompt -genkey -keyalg RSA -alias selfsigned -keystore keystore.ks -storepass storepass -validity 360 -keysize 2048 -dname "CN=localhost, OU=localhost, O=localhost, L=, S=, C=" -keypass 'secret'++ADD conf/server_tpl.xml conf/+ADD lib/* lib/+ADD run.sh ./++# Reduce startup time+ENV JAVA_OPTS -Djava.security.egd=file:/dev/urandom++EXPOSE 8443++CMD /usr/local/tomcat/run.sh\ No newline at end of filediff --git a/base/tomcat/build.gradle b/base/tomcat/build.gradlenew file mode 100644index 000000000..ab5008a88--- /dev/null+++ b/base/tomcat/build.gradle@@ -0,0 +1,12 @@+import com.bmuschko.gradle.docker.tasks.image.*++task buildBaseImage(type: DockerBuildImage) {+ inputDir = projectDir+ dockerFile = file("$projectDir/Dockerfile")+ tag = dockerImageName+}++task pushImage(type: DockerPushImage) {+ dependsOn buildBaseImage+ imageName = dockerImageName+}\ No newline at end of filediff --git a/base/tomcat/conf/server_tpl.xml b/base/tomcat/conf/server_tpl.xmlnew file mode 100644index 000000000..a75a246db--- /dev/null+++ b/base/tomcat/conf/server_tpl.xml@@ -0,0 +1,158 @@+<?xml version='1.0' encoding='utf-8'?>+<!--+ Licensed to the Apache Software Foundation (ASF) under one or more+ contributor license agreements. See the NOTICE file distributed with+ this work for additional information regarding copyright ownership.+ The ASF licenses this file to You under the Apache License, Version 2.0+ (the "License"); you may not use this file except in compliance with+ the License. You may obtain a copy of the License at++ http://www.apache.org/licenses/LICENSE-2.0++ Unless required by applicable law or agreed to in writing, software+ distributed under the License is distributed on an "AS IS" BASIS,+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ See the License for the specific language governing permissions and+ limitations under the License.+-->+<!-- Note: A "Server" is not itself a "Container", so you may not+ define subcomponents such as "Valves" at this level.+ Documentation at /docs/config/server.html+ -->+<Server port="8005" shutdown="SHUTDOWN">+ <Listener className="org.apache.catalina.startup.VersionLoggerListener" />+ <!-- Security listener. Documentation at /docs/config/listeners.html+ <Listener className="org.apache.catalina.security.SecurityListener" />+ -->+ <!--APR library loader. Documentation at /docs/apr.html -->+ <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />+ <!--Initialize Jasper prior to webapps are loaded. Documentation at /docs/jasper-howto.html -->+ <Listener className="org.apache.catalina.core.JasperListener" />+ <!-- Prevent memory leaks due to use of particular java/javax APIs-->+ <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />+ <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />+ <Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" />++ <!-- Global JNDI resources+ Documentation at /docs/jndi-resources-howto.html+ -->+ <GlobalNamingResources>+ <!-- Editable user database that can also be used by+ UserDatabaseRealm to authenticate users+ -->+ <Resource name="UserDatabase" auth="Container"+ type="org.apache.catalina.UserDatabase"+ description="User database that can be updated and saved"+ factory="org.apache.catalina.users.MemoryUserDatabaseFactory"+ pathname="conf/tomcat-users.xml" />++ <Resource name="jdbc/AuthDB" auth="Container" type="javax.sql.DataSource"+ maxActive="100" maxIdle="30" maxWait="10000"+ username="${BEEHIVE_DB_USERNAME}" password="${BEEHIVE_DB_PASSWORD}" driverClassName="${BEEHIVE_DB_DRIVER}"+ url="${BEEHIVE_DB_URL}"+ validationQuery="/* ping */ SELECT 1" testWhileIdle="true"/>+ </GlobalNamingResources>++ <!-- A "Service" is a collection of one or more "Connectors" that share+ a single "Container" Note: A "Service" is not itself a "Container",+ so you may not define subcomponents such as "Valves" at this level.+ Documentation at /docs/config/service.html+ -->+ <Service name="Catalina">++ <!--The connectors can use a shared executor, you can define one or more named thread pools-->+ <!--+ <Executor name="tomcatThreadPool" namePrefix="catalina-exec-"+ maxThreads="150" minSpareThreads="4"/>+ -->+++ <!-- A "Connector" represents an endpoint by which requests are received+ and responses are returned. Documentation at :+ Java HTTP Connector: /docs/config/http.html (blocking & non-blocking)+ Java AJP Connector: /docs/config/ajp.html+ APR (HTTP/AJP) Connector: /docs/apr.html+ Define a non-SSL HTTP/1.1 Connector on port 8080+ -->+ <!--+ <Connector port="8080" protocol="HTTP/1.1"+ connectionTimeout="20000"+ redirectPort="8443" /> -->+ <!-- A "Connector" using the shared thread pool-->+ <!--+ <Connector executor="tomcatThreadPool"+ port="8080" protocol="HTTP/1.1"+ connectionTimeout="20000"+ redirectPort="8443" />+ -->+ <!-- Define a SSL HTTP/1.1 Connector on port 8443+ This connector uses the BIO implementation that requires the JSSE+ style configuration. When using the APR/native implementation, the+ OpenSSL style configuration is required as described in the APR/native+ documentation -->+ <!--<Connector port="8443" protocol="org.apache.coyote.http11.Http11Protocol"+ maxThreads="150" SSLEnabled="true" scheme="https" secure="true"+ clientAuth="false" sslProtocol="TLS" /> -->+ <Connector port="8443" protocol="org.apache.coyote.http11.Http11Protocol"+ connectionTimeout="-1"+ maxThreads="150" SSLEnabled="true" scheme="https" secure="true"+ keystoreFile="keystore.jks" keystorePass="${SSL_KEY_STORE_PASSWORD}"+ clientAuth="false" sslProtocol="TLS" />++ <!-- Define an AJP 1.3 Connector on port 8009 -->+ <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />+++ <!-- An Engine represents the entry point (within Catalina) that processes+ every request. The Engine implementation for Tomcat stand alone+ analyzes the HTTP headers included with the request, and passes them+ on to the appropriate Host (virtual host).+ Documentation at /docs/config/engine.html -->++ <!-- You should set jvmRoute to support load-balancing via AJP ie :+ <Engine name="Catalina" defaultHost="localhost" jvmRoute="jvm1">+ -->+ <Engine name="Catalina" defaultHost="localhost">++ <!--For clustering, please take a look at documentation at:+ /docs/cluster-howto.html (simple how to)+ /docs/config/cluster.html (reference documentation) -->+ <!--+ <Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>+ -->++ <!-- Use the LockOutRealm to prevent attempts to guess user passwords+ via a brute-force attack -->+ <Realm className="org.apache.catalina.realm.LockOutRealm">+ <!-- This Realm uses the UserDatabase configured in the global JNDI+ resources under the key "UserDatabase". Any edits+ that are performed against this UserDatabase are immediately+ available for use by the Realm. -->+ <Realm className="org.apache.catalina.realm.UserDatabaseRealm"+ resourceName="UserDatabase"/>+ <Realm className="org.openremote.tomcat.realm.LegacyBeehiveDataSourceRealm"+ dataSourceName="jdbc/AuthDB" digest="md5"+ userTable="user" userNameCol="username" userCredCol="password"+ userRoleTable="tomcat_user_role" roleNameCol="rolename"/>+ </Realm>++ <Host name="localhost" appBase="webapps"+ unpackWARs="true" autoDeploy="true">++ <!-- SingleSignOn valve, share authentication between web applications+ Documentation at: /docs/config/valve.html -->+ <!--+ <Valve className="org.apache.catalina.authenticator.SingleSignOn" />+ -->++ <!-- Access log processes all example.+ Documentation at: /docs/config/valve.html+ Note: The pattern used is equivalent to using pattern="common" -->+ <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"+ prefix="localhost_access_log." suffix=".txt"+ pattern="%h %l %u %t "%r" %s %b" />++ </Host>+ </Engine>+ </Service>+</Server>diff --git a/base/tomcat/lib/mysql-connector-java-5.1.39-bin.jar b/base/tomcat/lib/mysql-connector-java-5.1.39-bin.jarnew file mode 100644index 000000000..dac6e1498Binary files /dev/null and b/base/tomcat/lib/mysql-connector-java-5.1.39-bin.jar differdiff --git a/base/tomcat/lib/or-tomcat-extensions-1.0.0.jar b/base/tomcat/lib/or-tomcat-extensions-1.0.0.jarnew file mode 100644index 000000000..8b012cdb5Binary files /dev/null and b/base/tomcat/lib/or-tomcat-extensions-1.0.0.jar differdiff --git a/base/tomcat/run.sh b/base/tomcat/run.shnew file mode 100755index 000000000..dfecf2bc9--- /dev/null+++ b/base/tomcat/run.sh@@ -0,0 +1,3 @@+#!/usr/bin/env bash+perl -p -i -e 's/\$\{([^}]+)\}/defined $ENV{$1} ? $ENV{$1} : $&/eg' < conf/server_tpl.xml > conf/server.xml+exec ${CATALINA_HOME}/bin/catalina.sh rundiff --git a/build.gradle b/build.gradleindex 043eaf11c..f433894d1 100644--- a/build.gradle+++ b/build.gradle@@ -39,7 +39,7 @@ allprojects {}}- ext.dockerImageName = "$dockerRepository/$project.name:$imageVersion".toString()+ ext.dockerImageName = "$dockerRepository/$project.name:$imageVersion".toLowerCase(Locale.ROOT)apply plugin: 'eclipse'}diff --git a/ccs/Dockerfile b/ccs/Dockerfilenew file mode 100644index 000000000..e69de29bbdiff --git a/controller/Dockerfile b/controller/Dockerfilenew file mode 100644index 000000000..7b0e69582--- /dev/null+++ b/controller/Dockerfile@@ -0,0 +1,34 @@+FROM openremote/controller:latest++WORKDIR /opt/OpenRemote-Controller/bin++# TODO The Web Console should be retrieved as a dependency or it should be in platform project+ADD webconsole.war /opt/OpenRemote-Controller/webapps/++RUN rm -r /opt/or-resources/*++ADD conf/.password /opt/or-resources/.password+ADD conf/.user /opt/or-resources/.user+ADD conf/controller.xml /opt/or-resources/controller.xml++ADD conf/env.drl /opt/or-resources/rules/env.drl+ENV RULES_DATA /opt/or-resources/data/++ADD conf/GVconfig.txt /opt/or-resources/data/GVconfig.txt++# Fix some permissions+USER root+RUN apt-get update && apt-get -y install netcat+RUN chown -R openremote.openremote /opt/or-resources+USER openremote++# Automatically configure Tomcat from env variables on startup+ADD conf/server_tpl.xml ../conf/+ADD run.sh ./+RUN chmod +x ./run.sh++# SSL configuration+ADD conf/keystore.jks ../+ADD conf/truststore.jks ../++ENTRYPOINT ["/opt/OpenRemote-Controller/bin/run.sh"]diff --git a/demo-controller/build.gradle b/controller/build.gradlesimilarity index 85%rename from demo-controller/build.gradlerename to controller/build.gradleindex e0b1e33f1..cefc6ccb5 100644--- a/demo-controller/build.gradle+++ b/controller/build.gradle@@ -4,7 +4,7 @@ ext.dockerImageName = "$dockerRepository/$project.name:$imageVersion".toString()task buildImage(type: DockerBuildImage) {inputDir = projectDir- dockerFile = file("$projectDir/Dockerfile-demo")+ dockerFile = file("$projectDir/Dockerfile")tag = dockerImageName}diff --git a/controller/conf/.password b/controller/conf/.passwordnew file mode 100644index 000000000..d97c5eada--- /dev/null+++ b/controller/conf/.password@@ -0,0 +1 @@+secretdiff --git a/controller/conf/.user b/controller/conf/.usernew file mode 100644index 000000000..e403209fe--- /dev/null+++ b/controller/conf/.user@@ -0,0 +1 @@+openremotediff --git a/controller/conf/GVconfig.txt b/controller/conf/GVconfig.txtnew file mode 100644index 000000000..4f0b8480b--- /dev/null+++ b/controller/conf/GVconfig.txt@@ -0,0 +1 @@+Demodiff --git a/demo-controller/config/controller.xml b/controller/conf/controller.xmlsimilarity index 100%rename from demo-controller/config/controller.xmlrename to controller/conf/controller.xmldiff --git a/demo-controller/config/env.drl b/controller/conf/env.drlsimilarity index 100%rename from demo-controller/config/env.drlrename to controller/conf/env.drldiff --git a/controller/conf/keystore.jks b/controller/conf/keystore.jksnew file mode 100644index 000000000..af98bdbaeBinary files /dev/null and b/controller/conf/keystore.jks differdiff --git a/controller/conf/server_tpl.xml b/controller/conf/server_tpl.xmlnew file mode 100644index 000000000..b1459f50d--- /dev/null+++ b/controller/conf/server_tpl.xml@@ -0,0 +1,123 @@+<?xml version='1.0' encoding='utf-8'?>+<!--+ Licensed to the Apache Software Foundation (ASF) under one or more+ contributor license agreements. See the NOTICE file distributed with+ this work for additional information regarding copyright ownership.+ The ASF licenses this file to You under the Apache License, Version 2.0+ (the "License"); you may not use this file except in compliance with+ the License. You may obtain a copy of the License at++ http://www.apache.org/licenses/LICENSE-2.0++ Unless required by applicable law or agreed to in writing, software+ distributed under the License is distributed on an "AS IS" BASIS,+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ See the License for the specific language governing permissions and+ limitations under the License.+-->++<!-- Documentation at /docs/config/server.html -->+<Server port="8005" shutdown="SHUTDOWN">++ <!--APR library loader. Documentation at /docs/apr.html -->+ <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />+ <!--Initialize Jasper prior to webapps are loaded. Documentation at /docs/jasper-howto.html -->+ <Listener className="org.apache.catalina.core.JasperListener" />+ <!-- JMX Support for the Tomcat server. Documentation at /docs/non-existent.html -->+ <Listener className="org.apache.catalina.mbeans.ServerLifecycleListener" />+ <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />++ <!-- Global JNDI resources. Documentation at /docs/jndi-resources-howto.html -->++ <GlobalNamingResources>+ <Resource name="UserDatabase" auth="Container"+ type="org.apache.catalina.UserDatabase"+ description="User database that can be updated and saved"+ factory="org.apache.catalina.users.MemoryUserDatabaseFactory"+ pathname="security/users.xml" />+ </GlobalNamingResources>++ <!-- A "Service" is a collection of one or more "Connectors" that share+ a single "Container". Documentation at /docs/config/service.html -->++ <Service name="Catalina">++ <!--The connectors can use a shared executor, you can define one or more named thread pools-->+ <Executor name="HTTP-ThreadPool" namePrefix="HTTP-Thread-" maxThreads="150" minSpareThreads="4"/>+++ <!-- Documentation at :+ Java HTTP Connector: /docs/config/http.html (blocking & non-blocking)+ Java AJP Connector: /docs/config/ajp.html+ APR (HTTP/AJP) Connector: /docs/apr.html+ -->+ <!--+ <Connector executor="HTTP-ThreadPool"+ port="8688" protocol="HTTP/1.1"+ connectionTimeout="20000"+ redirectPort="8443"+ URIEncoding="UTF-8"/>+ -->++ <!-- Define a SSL HTTP/1.1 Connector on port 8443+ This connector uses the JSSE configuration, when using APR, the+ connector should be using the OpenSSL style configuration+ described in the APR documentation -->+ <Connector port="8688" protocol="HTTP/1.1"+ connectionTimeout="-1"+ maxThreads="150" SSLEnabled="true" scheme="https" secure="true"+ keystoreFile="keystore.jks" keystorePass="${SSL_KEY_STORE_PASSWORD}"+ clientAuth="false" sslProtocol="TLS" />++ <!-- Define an AJP 1.3 Connector on port 8009 -->+ <!--+ <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />+ -->++ <!-- An Engine represents the entry point (within Catalina) that processes+ every request. The Engine implementation for Tomcat stand alone+ analyzes the HTTP headers included with the request, and passes them+ on to the appropriate Host (virtual host).+ Documentation at /docs/config/engine.html -->++ <!-- You should set jvmRoute to support load-balancing via AJP ie :+ <Engine name="Catalina" defaultHost="localhost" jvmRoute="jvm1">+ -->+ <Engine name="Catalina" defaultHost="localhost">++ <!-- The request dumper valve dumps useful debugging information about+ the request and response data received and sent by Tomcat.+ Documentation at: /docs/config/valve.html -->+ <!--+ <Valve className="org.apache.catalina.valves.RequestDumperValve"/>+ -->++ <!-- This Realm uses the UserDatabase configured in the global JNDI+ resources under the key "UserDatabase". Any edits+ that are performed against this UserDatabase are immediately+ available for use by the Realm. -->+ <Realm className="org.apache.catalina.realm.UserDatabaseRealm"+ resourceName="UserDatabase"/>++ <!-- Define the default virtual host -->+ <Host name="localhost" appBase="webapps"+ unpackWARs="true" autoDeploy="true"+ xmlValidation="false" xmlNamespaceAware="false">++ <!-- SingleSignOn valve, share authentication between web applications+ Documentation at: /docs/config/valve.html -->+ <!--+ <Valve className="org.apache.catalina.authenticator.SingleSignOn" />+ -->++ <!-- Access log processes all example.+ Documentation at: /docs/config/valve.html -->+ <!--+ <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"+ prefix="localhost_access_log." suffix=".txt" pattern="common" resolveHosts="false"/>+ -->++ </Host>+ </Engine>+ </Service>+</Server>diff --git a/controller/conf/truststore.jks b/controller/conf/truststore.jksnew file mode 100644index 000000000..9683ff9d3Binary files /dev/null and b/controller/conf/truststore.jks differdiff --git a/controller/run.sh b/controller/run.shnew file mode 100755index 000000000..36368cf60--- /dev/null+++ b/controller/run.sh@@ -0,0 +1,3 @@+#!/usr/bin/env bash+perl -p -i -e 's/\$\{([^}]+)\}/defined $ENV{$1} ? $ENV{$1} : $&/eg' < ../conf/server_tpl.xml > ../conf/server.xml+./openremote.sh rundiff --git a/demo-controller/webconsole.war b/controller/webconsole.warsimilarity index 100%rename from demo-controller/webconsole.warrename to controller/webconsole.wardiff --git a/demo-controller/Dockerfile-demo b/demo-controller/Dockerfile-demodeleted file mode 100644index 4ce0bcd8a..000000000--- a/demo-controller/Dockerfile-demo+++ /dev/null@@ -1,19 +0,0 @@-FROM openremote/controller:latest--RUN rm -r /opt/or-resources/*--ENV rules_data=/opt/or-resources/data/-ADD config/env.drl /opt/or-resources/rules/env.drl-ADD config/GVconfig.txt /opt/or-resources/data/GVconfig.txt--ADD webconsole.war /opt/OpenRemote-Controller/webapps/--ADD config/controller.xml /opt/or-resources/controller.xml--USER root-# nc is a great connectivity debug tool-RUN apt-get update && apt-get -y install netcat-RUN chown -R openremote.openremote /opt/or-resources-USER openremote--CMD ["run"]diff --git a/demo-controller/Dockerfile-dev b/demo-controller/Dockerfile-devdeleted file mode 100644index f705c75db..000000000--- a/demo-controller/Dockerfile-dev+++ /dev/null@@ -1,13 +0,0 @@-FROM openremote/controller:latest--RUN rm -r /opt/or-resources/*--ADD webconsole.war /opt/OpenRemote-Controller/webapps/--ADD config/controller.xml /opt/or-resources/controller.xml--USER root-RUN chown -R openremote.openremote /opt/or-resources-USER openremote--CMD ["run"]diff --git a/demo-controller/config/GVconfig.txt b/demo-controller/config/GVconfig.txtdeleted file mode 100644index cbde64d80..000000000--- a/demo-controller/config/GVconfig.txt+++ /dev/null@@ -1 +0,0 @@-Demo3diff --git a/postgres/Dockerfile-dev b/postgres/Dockerfile-devdeleted file mode 100644index deaa0188e..000000000--- a/postgres/Dockerfile-dev+++ /dev/null@@ -1,32 +0,0 @@-# Copyright (c) 2014, Docker PostGIS Authors (See AUTHORS)--# Permission is hereby granted, free of charge, to any person-# obtaining a copy of this software and associated documentation-# files (the "Software"), to deal in the Software without-# restriction, including without limitation the rights to use,-# copy, modify, merge, publish, distribute, sublicense, and/or sell-# copies of the Software, and to permit persons to whom the-# Software is furnished to do so, subject to the following-# conditions:--# The above copyright notice and this permission notice shall be-# included in all copies or substantial portions of the Software.--FROM postgres:9.6--ENV POSTGIS_MAJOR 2.3-ENV POSTGIS_VERSION 2.3.0+dfsg-2.pgdg80+1--RUN apt-get update \- && apt-get install -y --no-install-recommends \- postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR=$POSTGIS_VERSION \- postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR-scripts=$POSTGIS_VERSION \- postgis=$POSTGIS_VERSION \- && rm -rf /var/lib/apt/lists/*--RUN mkdir -p /docker-entrypoint-initdb.d--ADD 01-init-user.sh /docker-entrypoint-initdb.d/01-init-user.sh-ADD 02-init-postgis.sh /docker-entrypoint-initdb.d/02-init-postgis.sh--RUN chmod +x /docker-entrypoint-initdb.d/*.sh\ No newline at end of filediff --git a/profile/README.md b/profile/README.mdnew file mode 100644index 000000000..c2dd7b07a--- /dev/null+++ b/profile/README.md@@ -0,0 +1,54 @@+# OpenRemote Deployment Profiles++Mix and match these [Docker Compose](https://docs.docker.com/compose/) configurations to customize an OpenRemote system.++## Configuring security++In an OpenRemote system, servers use certificates to authenticate themselves to clients. Simple default TLS certificates (and the private key only known to the server(s)) have been created with:++```+#!/bin/bash++rm /tmp/or-keystore.jks+rm /tmp/or-truststore.jks+rm /tmp/or-certificate.cer++keytool -genkeypair -alias "openremote" \+ -noprompt -keyalg RSA -validity 9999 -keysize 2048 \+ -dname "CN=openremote" \+ -keypass CHANGE_ME_SSL_KEY_STORE_PASSWORD \+ -keystore /tmp/or-keystore.jks \+ -storepass CHANGE_ME_SSL_KEY_STORE_PASSWORD++keytool -exportcert \+ -alias "openremote" \+ -keystore /tmp/or-keystore.jks \+ -storepass CHANGE_ME_SSL_KEY_STORE_PASSWORD \+ -file /tmp/or-certificate.cer++keytool -importcert -noprompt \+ -alias "openremote" \+ -file /tmp/or-certificate.cer \+ -keystore /tmp/or-truststore.jks \+ -storepass CHANGE_ME_SSL_KEY_STORE_PASSWORD++keytool -list -v \+ -keystore /tmp/or-keystore.jks \+ -storepass CHANGE_ME_SSL_KEY_STORE_PASSWORD++cp /tmp/or-keystore.jks demo-controller/conf/keystore.jks+cp /tmp/or-truststore.jks demo-controller/conf/truststore.jks++```++At a minimum, you should re-create the stores and private key with your own passwords when deploying OpenRemote.++TODO: Unify default CAs in trust stores in all server systems, which (root) CAs should stay and what is the setup we recommend for OpenRemote users, etc.++TODO: Old Tomcat can't have separate key and store passwords...++## Deploying profiles++```+docker-compose -p <my_project_name> -f profile/mysql.yml -f profile/ccs.yml up+```diff --git a/docker-compose-demo.yml b/profile/TODO-demo.ymlsimilarity index 100%rename from docker-compose-demo.ymlrename to profile/TODO-demo.ymldiff --git a/profile/TODO-m1designer_dev.yml b/profile/TODO-m1designer_dev.ymlnew file mode 100644index 000000000..60bd9e712--- /dev/null+++ b/profile/TODO-m1designer_dev.yml@@ -0,0 +1,11 @@+#+# Milestone1 Designer (prototype)+#+version: '2'+services:+ m1designer:+ image: openremote/m1designer:latest+ environment:+ TZ: "Europe/Zurich"+ ports:+ - "8084:8080"diff --git a/docker-compose.yml b/profile/TODO-manager_dev.ymlsimilarity index 67%rename from docker-compose.ymlrename to profile/TODO-manager_dev.ymlindex b16fb0a3e..1d7a0903f 100644--- a/docker-compose.yml+++ b/profile/TODO-manager_dev.yml@@ -1,12 +1,14 @@-# Development setup of OpenRemote v3+#+# Development setup of Manager+#version: '2'services:keycloak_dev:build:- context: ./keycloak+ context: ../keycloakdockerfile: Dockerfile-devvolumes:- - ./keycloak/theme:/opt/jboss/keycloak/themes/openremote+ - ../keycloak/theme:/opt/jboss/keycloak/themes/openremotelinks:- postgres_dev:postgresqlenvironment:@@ -21,14 +23,13 @@ services:- "8081:8080"postgres_dev:build:- context: ./postgres+ context: ../postgresdockerfile: Dockerfile-devenvironment:TZ: "Europe/Zurich"# This is the database superuser- POSTGRES_USER: postgresPOSTGRES_PASSWORD: secret- # Create default database when started (also see init.sh files)+ # Create default database when started (see scripts)POSTGRES_DB: openremoteOPENREMOTE_USERNAME: openremoteOPENREMOTE_PASSWORD: secret@@ -36,17 +37,11 @@ services:- "8082:5432"controller_dev:build:- context: ./demo-controller+ context: ../demo-controllerdockerfile: Dockerfile-devenvironment:TZ: "Europe/Zurich"BEEHIVE_REMOTE_SERVICE_URI: "urn:disabled"CONTROLLER_CONSOLE_THRESHOLD: "INFO"ports:- - "8083:8688"- m1designer:- image: openremote/m1designer:latest- environment:- TZ: "Europe/Zurich"- ports:- - "8084:8080"\ No newline at end of file+ - "8083:8688"\ No newline at end of filediff --git a/profile/ccs.yml b/profile/ccs.ymlnew file mode 100644index 000000000..1d1364212--- /dev/null+++ b/profile/ccs.yml@@ -0,0 +1,33 @@+#+# Controller Commmand Service (Remote Proxy)+#+version: '2'+services:++ controller:+ image: openremote/controller:latest+ environment:+ TZ: "Europe/Zurich"+ SSL_KEY_STORE_PASSWORD: "CHANGE_ME_SSL_KEY_STORE_PASSWORD"+ BEEHIVE_REMOTE_SERVICE_URI: "https://css:8443/css/rest"+ CONTROLLER_CONSOLE_THRESHOLD: "INFO"+ links:+ - ccs+ ports:+ - "8688:8688"++ ccs:+ image: openremote/ccs:latest+ # TODO Why is this necessary? Is CCS connecting with itself?+ extra_hosts:+ - "ccs:127.0.0.1"+ environment:+ BEEHIVE_DB_USERNAME: "openremote"+ BEEHIVE_DB_PASSWORD: "CHANGE_ME_DB_USER_PASSWORD"+ BEEHIVE_DB_DRIVER: "com.mysql.jdbc.Driver"+ BEEHIVE_DB_URL: "jdbc:mysql://mysql:3306/openremote"+ SSL_KEYSTORE_PASSWORD: "CHANGE_ME_SSL_KEY_STORE_PASSWORD"+ links:+ - mysql+ ports:+ - "8443:8443"diff --git a/profile/ccs_dev.yml b/profile/ccs_dev.ymlnew file mode 100644index 000000000..9e823a0f8--- /dev/null+++ b/profile/ccs_dev.yml@@ -0,0 +1,33 @@+#+# Controller Commmand Service (Remote Proxy)+#+version: '2'+services:++ controller:+ build:+ context: ../demo-controller+ dockerfile: Dockerfile+ environment:+ TZ: "Europe/Zurich"+ SSL_KEY_STORE_PASSWORD: "CHANGE_ME_SSL_KEY_STORE_PASSWORD"+ BEEHIVE_REMOTE_SERVICE_URI: "https://css:8443/css/rest"+ CONTROLLER_CONSOLE_THRESHOLD: "INFO"+ ports:+ - "8688:8688"++ ccs:+ image: openremote/ccs:latest+ ports:+ - "8443:8443"+ # TODO Why is this necessary? Is CCS connecting with itself?+ extra_hosts:+ - "ccs:127.0.0.1"+ environment:+ BEEHIVE_DB_USERNAME: "openremote"+ BEEHIVE_DB_PASSWORD: "CHANGE_ME_DB_USER_PASSWORD"+ BEEHIVE_DB_DRIVER: "com.mysql.jdbc.Driver"+ BEEHIVE_DB_URL: "jdbc:mysql://mysql:3306/openremote"+ SSL_KEY_STORE_PASSWORD: "CHANGE_ME_SSL_KEY_STORE_PASSWORD"+ links:+ - mysqldiff --git a/profile/dependencies/mysql.yml b/profile/dependencies/mysql.ymlnew file mode 100644index 000000000..eb5cd512c--- /dev/null+++ b/profile/dependencies/mysql.yml@@ -0,0 +1,18 @@+#+# MySQL database service(s)+#+version: '2'+services:++ mysql:+ image: openremote/mysql:latest+ environment:+ TZ: "Europe/Zurich"+ # This is the database superuser+ MYSQL_ROOT_PASSWORD: "CHANGE_ME_DB_ROOT_PASSWORD"+ # Create default database when started (see scripts)+ MYSQL_DATABASE: openremote+ MYSQL_USER: openremote+ MYSQL_PASSWORD: "CHANGE_ME_DB_USER_PASSWORD"+ ports:+ - "3306:3306"diff --git a/profile/dependencies/mysql_dev.yml b/profile/dependencies/mysql_dev.ymlnew file mode 100644index 000000000..505a30c71--- /dev/null+++ b/profile/dependencies/mysql_dev.yml@@ -0,0 +1,22 @@+#+# DEVELOPER VERSION+#+# MySQL database service(s)+#+version: '2'+services:++ mysql:+ build:+ context: ../../base/mysql+ dockerfile: Dockerfile+ environment:+ TZ: "Europe/Zurich"+ # This is the database superuser+ MYSQL_ROOT_PASSWORD: "CHANGE_ME_DB_ROOT_PASSWORD"+ # Create default database when started (see scripts)+ MYSQL_DATABASE: openremote+ MYSQL_USER: openremote+ MYSQL_PASSWORD: "CHANGE_ME_DB_USER_PASSWORD"+ ports:+ - "3306:3306"diff --git a/settings.gradle b/settings.gradleindex a2b1cf589..af4d90832 100644--- a/settings.gradle+++ b/settings.gradle@@ -1,9 +1,11 @@rootProject.name = "openremote"-include "container",- "postgres",- "keycloak",- "demo-controller",+include "base:postgres",+ "base:mysql",+ "base:tomcat",+ "base:keycloak",+ "container",+ "controller","manager:shared","manager:server","manager:client",