diff --git a/apps/emqx/mix.exs b/apps/emqx/mix.exs index 86d890ab0..69065eca5 100644 --- a/apps/emqx/mix.exs +++ b/apps/emqx/mix.exs @@ -19,7 +19,7 @@ defmodule EMQX.MixProject do def application do [ mod: {:emqx_app, []}, - extra_applications: [:logger, :os_mon, :syntax_tools] + extra_applications: [:logger, :os_mon, :syntax_tools, :mnesia] ] end @@ -29,12 +29,13 @@ defmodule EMQX.MixProject do {:recon, "~> 2.5"}, {:cowboy, github: "emqx/cowboy", tag: "2.8.2"}, {:esockd, github: "emqx/esockd", tag: "5.8.0"}, - {:ekka, github: "emqx/ekka", tag: "0.10.2"}, + {:ekka, github: "emqx/ekka", tag: "0.10.8"}, {:gen_rpc, github: "emqx/gen_rpc", tag: "2.5.1"}, {:cuttlefish, github: "emqx/cuttlefish", tag: "v4.0.1"}, {:hocon, github: "emqx/hocon"}, {:pbkdf2, github: "emqx/erlang-pbkdf2", tag: "2.0.4"}, - {:snabbkaffe, github: "kafka4beam/snabbkaffe", tag: "0.14.0"} + {:snabbkaffe, github: "kafka4beam/snabbkaffe", tag: "0.14.0"}, + {:jiffy, github: "emqx/jiffy", tag: "1.0.5"} ] end end diff --git a/apps/emqx/src/emqx_app.erl b/apps/emqx/src/emqx_app.erl index 40a92565b..1585946d1 100644 --- a/apps/emqx/src/emqx_app.erl +++ b/apps/emqx/src/emqx_app.erl @@ -48,6 +48,7 @@ start(_Type, _Args) -> ok = maybe_load_config(), %% Load application first for ekka_mnesia scanner + mnesia:change_table_copy_type(schema, node(), disc_copies), ekka:start(), ok = ekka_rlog:wait_for_shards(?EMQX_SHARDS, infinity), ok = maybe_start_quicer(), diff --git a/apps/emqx_authz/etc/emqx_authz.conf b/apps/emqx_authz/etc/emqx_authz.conf index c2856f0b5..c629f4f52 100644 --- a/apps/emqx_authz/etc/emqx_authz.conf +++ b/apps/emqx_authz/etc/emqx_authz.conf @@ -1,63 +1,63 @@ authorization { - sources = [ - # { - # type: http - # url: "https://emqx.com" - # headers: { - # Accept: "application/json" - # Content-Type: "application/json" - # } - # }, - # { - # type: mysql - # server: "127.0.0.1:3306" - # database: mqtt - # pool_size: 1 - # username: root - # password: public - # auto_reconnect: true - # ssl: { - # enable: true - # cacertfile: "{{ platform_etc_dir }}/certs/cacert.pem" - # certfile: "{{ platform_etc_dir }}/certs/client-cert.pem" - # keyfile: "{{ platform_etc_dir }}/certs/client-key.pem" - # } - # query: "select ipaddress, username, clientid, action, permission, topic from mqtt_authz where ipaddr = '%a' or username = '%u' or clientid = '%c'" - # }, - # { - # type: pgsql - # server: "127.0.0.1:5432" - # database: mqtt - # pool_size: 1 - # username: root - # password: public - # auto_reconnect: true - # ssl: {enable: false} - # query: "select ipaddress, username, clientid, action, permission, topic from mqtt_authz where ipaddr = '%a' or username = '%u' or username = '$all' or clientid = '%c'" - # }, - # { - # type: redis - # server: "127.0.0.1:6379" - # database: 0 - # pool_size: 1 - # password: public - # auto_reconnect: true - # ssl: {enable: false} - # cmd: "HGETALL mqtt_authz:%u" - # }, - # { - # type: mongo - # mongo_type: single - # server: "127.0.0.1:27017" - # pool_size: 1 - # database: mqtt - # ssl: {enable: false} - # collection: mqtt_authz - # selector: { "$or": [ { "username": "%u" }, { "clientid": "%c" } ] } - # }, - { - type: file - path: "{{ platform_etc_dir }}/acl.conf" - } - ] + # sources = [ + # # { + # # type: http + # # url: "https://emqx.com" + # # headers: { + # # Accept: "application/json" + # # Content-Type: "application/json" + # # } + # # }, + # # { + # # type: mysql + # # server: "127.0.0.1:3306" + # # database: mqtt + # # pool_size: 1 + # # username: root + # # password: public + # # auto_reconnect: true + # # ssl: { + # # enable: true + # # cacertfile: "{{ platform_etc_dir }}/certs/cacert.pem" + # # certfile: "{{ platform_etc_dir }}/certs/client-cert.pem" + # # keyfile: "{{ platform_etc_dir }}/certs/client-key.pem" + # # } + # # query: "select ipaddress, username, clientid, action, permission, topic from mqtt_authz where ipaddr = '%a' or username = '%u' or clientid = '%c'" + # # }, + # # { + # # type: pgsql + # # server: "127.0.0.1:5432" + # # database: mqtt + # # pool_size: 1 + # # username: root + # # password: public + # # auto_reconnect: true + # # ssl: {enable: false} + # # query: "select ipaddress, username, clientid, action, permission, topic from mqtt_authz where ipaddr = '%a' or username = '%u' or username = '$all' or clientid = '%c'" + # # }, + # # { + # # type: redis + # # server: "127.0.0.1:6379" + # # database: 0 + # # pool_size: 1 + # # password: public + # # auto_reconnect: true + # # ssl: {enable: false} + # # cmd: "HGETALL mqtt_authz:%u" + # # }, + # # { + # # type: mongo + # # mongo_type: single + # # server: "127.0.0.1:27017" + # # pool_size: 1 + # # database: mqtt + # # ssl: {enable: false} + # # collection: mqtt_authz + # # selector: { "$or": [ { "username": "%u" }, { "clientid": "%c" } ] } + # # }, + # { + # type: file + # path: "{{ platform_etc_dir }}/acl.conf" + # } + # ] } diff --git a/apps/emqx_dashboard/mix.exs b/apps/emqx_dashboard/mix.exs index fe954dcdd..a848df4fa 100644 --- a/apps/emqx_dashboard/mix.exs +++ b/apps/emqx_dashboard/mix.exs @@ -27,7 +27,7 @@ defmodule EMQXDashboard.MixProject do defp deps do [ {:emqx, in_umbrella: true, runtime: false}, - {:minirest, github: "emqx/minirest", tag: "1.1.7"} + {:minirest, github: "emqx/minirest", tag: "1.2.2"} ] end end diff --git a/apps/emqx_management/mix.exs b/apps/emqx_management/mix.exs index a26d482ce..b00d8fd3f 100644 --- a/apps/emqx_management/mix.exs +++ b/apps/emqx_management/mix.exs @@ -27,9 +27,9 @@ defmodule EMQXManagement.MixProject do defp deps do [ {:emqx_rule_engine, in_umbrella: true}, - {:ekka, github: "emqx/ekka", tag: "0.10.2"}, + {:ekka, github: "emqx/ekka", tag: "0.10.8"}, {:emqx_http_lib, github: "emqx/emqx_http_lib", tag: "0.2.1"}, - {:minirest, github: "emqx/minirest", tag: "1.1.7"} + {:minirest, github: "emqx/minirest", tag: "1.2.2"} ] end end diff --git a/apps/emqx_release_helper/lib/emqx_release_helper/applications.ex b/apps/emqx_release_helper/lib/emqx_release_helper/applications.ex index 34a28518e..8f6b67fbb 100644 --- a/apps/emqx_release_helper/lib/emqx_release_helper/applications.ex +++ b/apps/emqx_release_helper/lib/emqx_release_helper/applications.ex @@ -34,6 +34,10 @@ defmodule EmqxReleaseHelper.Applications do application :emqx_gateway do start_type :permanent + + overlay do + copy "src/lwm2m/lwm2m_xml", "etc/lwm2m_xml" + end end application :emqx_connector do @@ -52,11 +56,6 @@ defmodule EmqxReleaseHelper.Applications do start_type :permanent end - application :emqx_data_bridge do - start_type :permanent - overlay :application - end - application :emqx_authn do start_type :permanent overlay :application @@ -65,6 +64,10 @@ defmodule EmqxReleaseHelper.Applications do application :emqx_authz do start_type :permanent overlay :application + + overlay do + template "etc/acl.conf", "etc/acl.conf" + end end application :emqx_dashboard do diff --git a/apps/emqx_rule_engine/mix.exs b/apps/emqx_rule_engine/mix.exs index 947648930..c24ed0d42 100644 --- a/apps/emqx_rule_engine/mix.exs +++ b/apps/emqx_rule_engine/mix.exs @@ -28,7 +28,7 @@ defmodule EMQXRuleEngine.MixProject do [ {:emqx, in_umbrella: true, runtime: false}, {:emqx_http_lib, github: "emqx/emqx_http_lib", tag: "0.2.1"}, - {:ekka, github: "emqx/ekka", tag: "0.10.2"} + {:ekka, github: "emqx/ekka", tag: "0.10.8"} ] end end diff --git a/mix.lock b/mix.lock index acdb25cd1..5ffeba096 100644 --- a/mix.lock +++ b/mix.lock @@ -2,12 +2,12 @@ "bbmustache": {:hex, :bbmustache, "1.12.1", "857fbdf86bda46d07201b0e7a969820cb763a7c174c485fd0780d7e033efe9f0", [:rebar3], [], "hexpm", "f4320778c31a821a2a664db8894618abb79c1af7bbf7c03c703c8868d9bb09fe"}, "bcrypt": {:git, "https://github.com/emqx/erlang-bcrypt.git", "dc2ba66acf2332c111362d01137746eefecc5e90", [tag: "0.6.0"]}, "cowboy": {:git, "https://github.com/emqx/cowboy.git", "b89d4689a04149b1a4a3641280aa5c5643f921b2", [tag: "2.8.2"]}, - "cowboy_swagger": {:git, "https://github.com/inaka/cowboy_swagger", "f779ffe1365f474f0b569c9cd87ded2ac147a67e", [tag: "2.3.0"]}, + "cowboy_swagger": {:git, "https://github.com/inaka/cowboy_swagger", "f4b49a4f289a9ee9ae1ff35772c4e191b5fafbd5", [tag: "2.4.0"]}, "cowlib": {:hex, :cowlib, "2.11.0", "0b9ff9c346629256c42ebe1eeb769a83c6cb771a6ee5960bd110ab0b9b872063", [:make, :rebar3], [], "hexpm", "2b3e9da0b21c4565751a6d4901c20d1b4cc25cbb7fd50d91d2ab6dd287bc86a9"}, "cuttlefish": {:git, "https://github.com/emqx/cuttlefish.git", "1b95e3aa275fc240dd51f53e771566b1f89b5fcc", []}, "ecpool": {:git, "https://github.com/emqx/ecpool.git", "0516d2cebd14654ef8c583c347e4a0b01363b86d", [tag: "0.5.1"]}, "eetcd": {:hex, :eetcd, "0.3.4", "27e8b4775230c53a9ef602f62a1603591302b40b2eb195d567edffb35b6cf1a2", [:rebar3], [{:gun, "1.3.3", [hex: :gun, repo: "hexpm", optional: false]}], "hexpm", "b763c0e1a9741d39a62f5a19186a342863eacbc769151c4e81db5790efecefca"}, - "ekka": {:git, "https://github.com/emqx/ekka.git", "cdde7fa2db89764f5c6be69d8bc6f79f4cfa5c82", [tag: "0.10.2"]}, + "ekka": {:git, "https://github.com/emqx/ekka.git", "80e7439472164ce2b121cff523b979291cc7c9f3", [tag: "0.10.8"]}, "emqtt": {:git, "https://github.com/emqx/emqtt.git", "9e867b1fcaadbfcce45ea75d3721f982907ae417", [tag: "v1.2.3"]}, "emqx_http_lib": {:git, "https://github.com/emqx/emqx_http_lib.git", "9a1aafcbad1bb35392ebabc0cf102c7bce660432", [tag: "0.4.0"]}, "epgsql": {:git, "https://github.com/epgsql/epgsql.git", "895c8f9d53f08d09ec6a0301c56d3d6f270929f2", [tag: "4.4.0"]}, @@ -26,7 +26,7 @@ "jose": {:hex, :jose, "1.11.2", "f4c018ccf4fdce22c71e44d471f15f723cb3efab5d909ab2ba202b5bf35557b3", [:mix, :rebar3], [], "hexpm", "98143fbc48d55f3a18daba82d34fe48959d44538e9697c08f34200fa5f0947d2"}, "jsx": {:hex, :jsx, "3.1.0", "d12516baa0bb23a59bb35dccaf02a1bd08243fcbb9efe24f2d9d056ccff71268", [:rebar3], [], "hexpm", "0c5cc8fdc11b53cc25cf65ac6705ad39e54ecc56d1c22e4adb8f5a53fb9427f3"}, "lwm2m_coap": {:git, "https://github.com/emqx/lwm2m-coap.git", "495f3c62fae153040c89f9a0ba5344789ff5acc8", [tag: "v2.0.0"]}, - "minirest": {:git, "https://github.com/emqx/minirest.git", "27ad0a8eaf10dca7748b0f63aa66754486a39dd5", [tag: "1.1.7"]}, + "minirest": {:git, "https://github.com/emqx/minirest.git", "dea1f49a55d46673e2ca6400a87f8fcdee58b8ef", [tag: "1.2.2"]}, "mysql": {:git, "https://github.com/emqx/mysql-otp.git", "bdabac44cc8836a9e23897b7e1b77c7df7e04f70", [tag: "1.7.1"]}, "pbkdf2": {:git, "https://github.com/emqx/erlang-pbkdf2.git", "45d9981209ea07a83a58cf85aaf8236457da4342", [tag: "2.0.4"]}, "poolboy": {:git, "https://github.com/emqx/poolboy.git", "29be47db8c2be38b18c908e43a80ebb7b9b6116b", [tag: "1.5.2"]}, diff --git a/rel/overlays/ex_bin/emqx b/rel/overlays/ex_bin/emqx index 0f7b93455..d104e113a 100755 --- a/rel/overlays/ex_bin/emqx +++ b/rel/overlays/ex_bin/emqx @@ -25,10 +25,55 @@ export RELEASE_BOOT_SCRIPT="${RELEASE_BOOT_SCRIPT:-"start"}" export RELEASE_BOOT_SCRIPT_CLEAN="${RELEASE_BOOT_SCRIPT_CLEAN:-"start_clean"}" export RELEASE_SYS_CONFIG="${RELEASE_SYS_CONFIG:-"$REL_VSN_DIR/sys"}" +# defined in emqx_vars +export RUNNER_ROOT_DIR +export RUNNER_ETC_DIR + export SCHEMA_MOD=emqx_machine_schema export CONFIGS_DIR="$RUNNER_DATA_DIR/configs" -export NAME='emqx' -export NAME_TYPE='-sname' +export MNESIA_DATA_DIR="$RUNNER_DATA_DIR/mnesia" + +set_name () { + IS_BOOT_COMMAND='no' + case "$1" in + start|start_iex|daemon|daemon_iex) + IS_BOOT_COMMAND='yes' + ;; + esac + + ## Possible ways to configure emqx node name: + ## 1. configure node.name in emqx.conf + ## 2. override with environment variable EMQX_NODE_NAME + ## Node name is either short-name (without '@'), e.g. 'emqx' + ## or long name (with '@') e.g. 'emqx@example.net' or 'emqx@127.0.0.1' + NAME="${EMQX_NODE_NAME:-}" + if [ -z "$NAME" ]; then + if [ "$IS_BOOT_COMMAND" = 'yes' ]; then + # for boot commands, inspect emqx.conf for node name + NAME="$(call_hocon -s $SCHEMA_MOD -c "$RUNNER_ETC_DIR"/emqx.conf get node.name | tr -d \")" + else + # for non-boot commands, inspect vm.