From 451dfe1343f3eb7526aa0654f688dc9b57acca75 Mon Sep 17 00:00:00 2001 From: Connor Rigby Date: Fri, 23 Nov 2018 10:25:14 -0800 Subject: [PATCH] [WIP] Pull in NervesHub updates --- .circleci/config.yml | 355 +++++++++++++++++- .gitignore | 1 + farmbot_os/config.test.db-journal | Bin 8720 -> 0 bytes farmbot_os/config/config.exs | 14 +- farmbot_os/config/host/dev.exs | 8 +- farmbot_os/config/host/test.exs | 44 +++ farmbot_os/config/target/dev.exs | 18 +- farmbot_os/config/target/prod.exs | 19 +- farmbot_os/lib/easter_eggs.ex | 2 +- farmbot_os/lib/filesystem.ex | 6 +- farmbot_os/lib/init/ecto.ex | 14 +- farmbot_os/lib/init/supervisor.ex | 2 +- farmbot_os/lib/nerves_hub.ex | 2 +- farmbot_os/lib/platform_supervisor.ex | 2 +- farmbot_os/lib/shoehorn_handler.ex | 8 +- farmbot_os/lib/system.ex | 2 +- farmbot_os/mix.exs | 4 +- farmbot_os/mix.lock.host | 2 +- .../platform/host/nerves_hub_handler.ex | 12 +- .../target/configurator/captive_portal.ex | 4 +- .../platform/target/configurator/router.ex | 4 +- .../platform/target/nerves_hub_client.ex | 76 ++-- farmbot_os/platform/target/network/network.ex | 7 +- farmbot_os/rel/config.exs | 23 +- farmbot_os/rel/plugins/.gitignore | 3 + scripts/update_deps_for_all_platforms.sh | 1 + 26 files changed, 519 insertions(+), 114 deletions(-) delete mode 100644 farmbot_os/config.test.db-journal create mode 100644 farmbot_os/config/host/test.exs create mode 100644 farmbot_os/rel/plugins/.gitignore diff --git a/.circleci/config.yml b/.circleci/config.yml index e78e1577..c50e7e12 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,5 +1,6 @@ version: 2.0 defaults: &defaults + working_directory: /nerves/build docker: - image: nervesproject/nerves_system_br:1.6.8 environment: @@ -22,13 +23,6 @@ install_hex_archives: &install_hex_archives mix local.rebar --force mix archive.install hex nerves_bootstrap "~> 1.2" --force -fetch_and_compile_deps: &fetch_and_compile_deps - run: - name: Fetch and compile Elixir dependencies - command: | - mix deps.get - mix compile - install_arduino: &install_arduino run: name: Run setup script @@ -62,6 +56,7 @@ build_firmware_steps: &build_firmware_steps - run: name: Setup ENV command: | +<<<<<<< HEAD echo $MIX_TARGET > MIX_TARGET echo $MIX_ENV > MIX_ENV cp mix.lock MIX_LOCK @@ -69,10 +64,20 @@ build_firmware_steps: &build_firmware_steps key: v9-fbos-{{ checksum "MIX_TARGET" }}-{{ checksum "MIX_ENV" }}-dependency-cache-{{ checksum "MIX_LOCK" }} - restore_cache: key: v9-fbos-host-test-dependency-cache-{{ checksum "mix.lock" }} +======= + echo "/nerves/build/farmbot_os/$MIX_TARGET" > MIX_TARGET + echo "/nerves/build/farmbot_os/$MIX_ENV" > MIX_ENV + cp /nerves/build/farmbot_os/mix.lock.$MIX_TARGET MIX_LOCK + - restore_cache: + key: v9-fbos-{{ checksum "MIX_TARGET" }}-{{ checksum "MIX_ENV" }}-dependency-cache-{{ checksum "MIX_LOCK" }} + - restore_cache: + key: v9-fbos-host-test-dependency-cache-{{ checksum "mix.lock.host" }} +>>>>>>> e9b01741... [WIP] Pull in NervesHub updates - <<: *install_elixir - <<: *install_hex_archives - run: name: Build Farmbot OS Firmware + working_directory: /nerves/build/farmbot_os command: | mix deps.get mix compile --force @@ -83,12 +88,16 @@ build_firmware_steps: &build_firmware_steps - run: name: Create artifacts command: | +<<<<<<< HEAD cp _build/${MIX_TARGET}_${MIX_ENV}/nerves/images/farmbot.fw /nerves/deploy/system/artifacts/farmbot-${MIX_TARGET}-$(cat VERSION).fw +======= + cp /nerves/build/farmbot_os/_build/${MIX_TARGET}/${MIX_ENV}/nerves/images/farmbot.fw /nerves/deploy/system/artifacts/farmbot-${MIX_TARGET}-$(cat VERSION).fw +>>>>>>> e9b01741... [WIP] Pull in NervesHub updates - save_cache: key: v9-fbos-{{ checksum "MIX_TARGET" }}-{{ checksum "MIX_ENV" }}-dependency-cache-{{ checksum "MIX_LOCK" }} paths: - - _build/ - - deps/ + - /nerves/build/farmbot_os/_build/ + - /nerves/build/farmbot_os/deps/ - ~/.nerves/ - save_cache: key: nerves/deploy/system-{{ checksum "MIX_TARGET" }}-{{ .Branch }}-{{ .Revision }}-{{ .Environment.CIRCLE_TAG }} @@ -102,9 +111,15 @@ deploy_nerves_hub_firmware_steps: &deploy_nerves_hub_firmware_steps - run: name: Setup ENV command: | +<<<<<<< HEAD echo $MIX_TARGET > MIX_TARGET echo $MIX_ENV > MIX_ENV cp mix.lock MIX_LOCK +======= + echo "/nerves/build/farmbot_os/$MIX_TARGET" > MIX_TARGET + echo "/nerves/build/farmbot_os/$MIX_ENV" > MIX_ENV + cp /nerves/build/farmbot_os/mix.lock.$MIX_TARGET MIX_LOCK +>>>>>>> e9b01741... [WIP] Pull in NervesHub updates - restore_cache: key: v9-fbos-{{ checksum "MIX_TARGET" }}-{{ checksum "MIX_ENV" }}-dependency-cache-{{ checksum "MIX_LOCK" }} - restore_cache: @@ -113,9 +128,11 @@ deploy_nerves_hub_firmware_steps: &deploy_nerves_hub_firmware_steps - <<: *install_hex_archives - run: name: Sign Image + working_directory: /nerves/build/farmbot_os command: mix nerves_hub.firmware sign --key notreal /nerves/deploy/system/artifacts/farmbot-${MIX_TARGET}-$(cat VERSION).fw - run: name: Publish to NervesHub + working_directory: /nerves/build/farmbot_os command: mix nerves_hub.firmware publish --deploy ${NERVES_HUB_DEPLOY} ${NERVES_HUB_TTL} /nerves/deploy/system/artifacts/farmbot-${MIX_TARGET}-$(cat VERSION).fw jobs: @@ -124,29 +141,184 @@ jobs: # TEST # ################################################################################ - test: + test_farmbot_celery_script: <<: *defaults environment: MIX_ENV: test MIX_TARGET: host + NERVES_LOG_DISABLE_PROGRESS_BAR: "yes" + ELIXIR_VERSION: 1.7.3 + steps: + - checkout + - restore_cache: + keys: + - v9-fbcs-test-dependency-cache-{{ checksum "farmbot_celery_script/mix.lock" }} + - <<: *install_elixir + - <<: *install_hex_archives + - run: + name: Test Farmbot CeleryScript + working_directory: /nerves/build/farmbot_celery_script + command: | + mix deps.get + mix compile + mix format --check-formatted + mix test + - save_cache: + key: v9-fbcs-test-dependency-cache-{{ checksum "farmbot_celery_script/mix.lock" }} + paths: + - farmbot_celery_script/_build/test + - farmbot_celery_script/deps + + test_farmbot_firmware: + <<: *defaults + environment: + MIX_ENV: test + MIX_TARGET: host +<<<<<<< HEAD ELIXIR_VERSION: 1.8.1 +======= + NERVES_LOG_DISABLE_PROGRESS_BAR: "yes" + ELIXIR_VERSION: 1.7.3 +>>>>>>> e9b01741... [WIP] Pull in NervesHub updates + steps: + - checkout + - restore_cache: + keys: + - v9-fbfw-test-dependency-cache-{{ checksum "farmbot_firmware/mix.lock" }} + - <<: *install_elixir + - <<: *install_hex_archives + - run: + name: Test Farmbot Firmware + working_directory: /nerves/build/farmbot_firmware + command: | + mix deps.get + mix compile + mix format --check-formatted + mix test + - save_cache: + key: v9-fbfw-test-dependency-cache-{{ checksum "farmbot_firmware/mix.lock" }} + paths: + - farmbot_firmware/_build/test + - farmbot_firmware/deps + + test_farmbot_core: + <<: *defaults + environment: + MIX_ENV: test + MIX_TARGET: host + NERVES_LOG_DISABLE_PROGRESS_BAR: "yes" + ELIXIR_VERSION: 1.7.3 + TZ: "America/Los_Angeles" steps: - checkout - run: git submodule update --init --recursive - restore_cache: +<<<<<<< HEAD key: v9-fbos-host-test-dependency-cache-{{ checksum "mix.lock" }} +======= + keys: + - v9-fbcore-test-dependency-cache-{{ checksum "farmbot_core/mix.lock" }} + - restore_cache: + keys: + - v9-fbcore-test-arduino-dependency-cache-{{ checksum ".circleci/setup-arduino.sh" }} + - <<: *install_elixir + - <<: *install_hex_archives + - <<: *install_arduino + - run: + name: Ensure format + command: | + mix format --check-formatted + - run: + name: Test Farmbot Core + working_directory: /nerves/build/farmbot_core + command: | + mix deps.get + mix compile + mix format --check-formatted + mix test --trace + - save_cache: + key: v9-fbcore-test-dependency-cache-{{ checksum "farmbot_core/mix.lock" }} + paths: + - farmbot_core/_build/test + - farmbot_core/deps + - farmbot_core/arduino + - save_cache: + key: v9-fbcore-test-arduino-dependency-cache-{{ checksum ".circleci/setup-arduino.sh" }} + paths: + - ~/arduino-1.8.5 + - farmbot_core/_build/core + - farmbot_core/_build/libraries + - farmbot_core/_build/farmduino_k14 + - farmbot_core/_build/farmduino_v10 + - farmbot_core/_build/ramps_v14 + + test_farmbot_ext: + <<: *defaults + environment: + MIX_ENV: test + MIX_TARGET: host + NERVES_LOG_DISABLE_PROGRESS_BAR: "yes" + ELIXIR_VERSION: 1.7.3 + SKIP_ARDUINO_BUILD: 1 + steps: + - checkout + - run: git submodule update --init --recursive + - restore_cache: + keys: + - v9-fbext-test-dependency-cache-{{ checksum "farmbot_core/mix.lock" }} + - <<: *install_elixir + - <<: *install_hex_archives + - run: + name: Test Farmbot Ext + working_directory: /nerves/build/farmbot_ext + command: | + mix deps.get + mix compile + mix format --check-formatted + mix ecto.create + mix ecto.migrate + mix test + - save_cache: + key: v9-fbext-test-dependency-cache-{{ checksum "farmbot_core/mix.lock" }} + paths: + - farmbot_ext/_build/test + - farmbot_ext/deps + + test_farmbot_os: + <<: *defaults + environment: + MIX_ENV: test + MIX_TARGET: host + NERVES_LOG_DISABLE_PROGRESS_BAR: "yes" + ELIXIR_VERSION: 1.7.3 + steps: + - checkout + - run: git submodule update --init --recursive + - restore_cache: + key: v9-fbos-host-test-dependency-cache-{{ checksum "farmbot_os/mix.lock.host" }} +>>>>>>> e9b01741... [WIP] Pull in NervesHub updates - <<: *install_elixir - <<: *install_hex_archives - run: name: Test Farmbot OS + working_directory: /nerves/build/farmbot_os command: | mix deps.get mix compile + mix format --check-formatted + mix test - save_cache: +<<<<<<< HEAD key: v9-fbos-host-test-dependency-cache-{{ checksum "mix.lock" }} paths: - _build/host_test - deps +======= + key: v9-fbos-host-test-dependency-cache-{{ checksum "farmbot_os/mix.lock.host" }} + paths: + - farmbot_os/_build/host + - farmbot_os/deps/host +>>>>>>> e9b01741... [WIP] Pull in NervesHub updates ################################################################################ # target=rpi app_env=prod # @@ -261,14 +433,22 @@ jobs: name: Setup ENV command: | echo rpi3 > MIX_TARGET_RPI3 +<<<<<<< HEAD cp mix.lock MIX_LOCK_RPI3 +======= + cp /nerves/build/farmbot_os/mix.lock.rpi3 MIX_LOCK_RPI3 +>>>>>>> e9b01741... [WIP] Pull in NervesHub updates # echo rpi > MIX_TARGET_RPI - # cp mix.lock.rpi MIX_LOCK_RPI + # cp /nerves/build/farmbot_os/mix.lock.rpi MIX_LOCK_RPI echo $MIX_ENV > MIX_ENV - restore_cache: key: nerves/deploy/system-{{ checksum "MIX_TARGET_RPI3" }}-{{ .Branch }}-{{ .Revision }}-{{ .Environment.CIRCLE_TAG }} # - restore_cache: +<<<<<<< HEAD # key: nerves/deploy/system-{{ checksum "MIX_TARGET_RPI" }}-{{ .Branch }}-{{ .Revision }}-{{ .Environment.CIRCLE_TAG }} +======= + # key: nerves/deploy/system-{{ checksum "MIX_TARGET_RPI" }}-{{ .Branch }}-{{ .Revision }}-{{ .Environment.CIRCLE_TAG }} +>>>>>>> e9b01741... [WIP] Pull in NervesHub updates - <<: *install_elixir - <<: *install_hex_archives - <<: *install_ghr @@ -317,9 +497,13 @@ jobs: name: Setup ENV command: | echo rpi3 > MIX_TARGET_RPI3 +<<<<<<< HEAD cp mix.lock MIX_LOCK_RPI3 +======= + cp /nerves/build/farmbot_os/mix.lock.rpi3 MIX_LOCK_RPI3 +>>>>>>> e9b01741... [WIP] Pull in NervesHub updates # echo rpi > MIX_TARGET_RPI - # cp mix.lock.rpi MIX_LOCK_RPI + # cp /nerves/build/farmbot_os/mix.lock.rpi MIX_LOCK_RPI echo $MIX_ENV > MIX_ENV - restore_cache: key: nerves/deploy/system-{{ checksum "MIX_TARGET_RPI3" }}-{{ .Branch }}-{{ .Revision }}-{{ .Environment.CIRCLE_TAG }} @@ -359,15 +543,52 @@ workflows: version: 2 test: jobs: - - test: + - test_farmbot_celery_script: context: org-global filters: branches: ignore: - # Merging is blocked on these branches until tests pass. - - beta - master - staging + - beta + - next + - test_farmbot_firmware: + context: org-global + filters: + branches: + ignore: + - master + - staging + - beta + - next + - test_farmbot_core: + context: org-global + filters: + branches: + ignore: + - master + - staging + - beta + - next + - test_farmbot_ext: + context: org-global + filters: + branches: + ignore: + - master + - staging + - beta + - next + - test_farmbot_os: + context: org-global + filters: + branches: + ignore: + - master + - staging + - beta + - next + # master branch to staging.farmbot.io nerves_hub_prod_stable_staging: jobs: @@ -474,6 +695,7 @@ workflows: # - build_rpi_prod - build_rpi3_prod +<<<<<<< HEAD # # staging branch to staging.farmbot.io # nerves_hub_rpi_prod_staging_staging: @@ -498,3 +720,106 @@ workflows: # context: farmbot-staging # requires: # - build_rpi3_prod +======= + # staging branch to staging.farmbot.io + nerves_hub_rpi_prod_staging_staging: + jobs: + # - build_rpi_prod: + # context: farmbot-staging + # filters: + # branches: + # only: + # - staging + - build_rpi3_prod: + context: farmbot-staging + filters: + branches: + only: + - staging + # - deploy_rpi_prod_staging: + # context: farmbot-staging + # requires: + # - build_rpi_prod + - deploy_rpi3_prod_staging: + context: farmbot-staging + requires: + - build_rpi3_prod + + # next branch to staging.farmbot.io + deploy_staging_next: + jobs: + - test_farmbot_celery_script: + context: org-global + filters: + branches: + only: + - next + - test_farmbot_firmware: + context: org-global + filters: + branches: + only: + - next + - test_farmbot_core: + context: org-global + filters: + branches: + only: + - next + - test_farmbot_ext: + context: org-global + filters: + branches: + only: + - next + - test_farmbot_os: + context: org-global + filters: + branches: + only: + - next + + - build_rpi3_prod: + context: farmbot-staging + filters: + branches: + only: + - next + requires: + - test_farmbot_celery_script + - test_farmbot_firmware + - test_farmbot_core + - test_farmbot_ext + - test_farmbot_os + + # - build_rpi_prod: + # context: farmbot-staging + # filters: + # branches: + # only: + # - next + # requires: + # - test_farmbot_celery_script + # - test_farmbot_firmware + # - test_farmbot_core + # - test_farmbot_ext + # - test_farmbot_os + + - deploy_rpi3_prod_staging: + context: farmbot-staging + filters: + branches: + only: + - next + requires: + - build_rpi3_prod + + # - deploy_rpi_prod_staging: + # context: farmbot-staging + # filters: + # branches: + # only: + # - next + # requires: + # - build_rpi_prod +>>>>>>> e9b01741... [WIP] Pull in NervesHub updates diff --git a/.gitignore b/.gitignore index 9b77476b..98f11138 100644 --- a/.gitignore +++ b/.gitignore @@ -56,3 +56,4 @@ RELEASE_NOTES nerves-hub *.pem *.db +*.db-journal diff --git a/farmbot_os/config.test.db-journal b/farmbot_os/config.test.db-journal deleted file mode 100644 index 03d7072cb6c9b3fbe9161b3c5671596998f77836..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 8720 zcmeHLO>7%Q6yA*;uk&M1NK3a-4qa_k%1VeRN>C*#q`K)gvg+E@u~7q+RvUZlY~$T^ zch>nip-qtB!i5VQxby%QE?j!y!UYKs5*LJk0~aL31qpFMATGQaubrKGV+D?ME&1)6 z_ujrY^S$?G#{S{k$-k6`jqe0On5eXh_ux4XEIj7mn|z)C1Tr~TUKCJzUqH{GNBJ-EujYQs9nE}@-k)BbdN2EV z_S(#R=4kTglUyY71c3yB{~H2__p_3`yez))x^HfEu!H?Q*V{2H$H!jFY+y1fnOdvr zg_^F^3fD`zqK+D<%CoA~RFz`6rmyQ&<>hMecA>hd+|oCn1AEiPs#4SM)|7GuzV%WG zr2auSMoI|vLv6vNOLm4l!Hu40`3FOR)!kh+Z0v8l$1m7c+cSL(g6ow^NiUSaiESQi zVPo5BHn9_xv-izr)5C=DPTSyO&wMNr>21Nf4cm;&sp;CL1x~~1(sddHd%M^RJ!-)s z0nOVC^tw&DJ&d!`f`w^GzI8MRYECw$yrP&M9MXrZEwY^%4KAj%)g-48YsQM2HwfLNFxhk*(d&Nb;piVj#2R zMy;c~#HTr`8lP*H3RSsTsuXIPH7Us#FN(neixpXWgw61gBAQbL3hz8xC*407`pe=H z$qgp?aGdT`0U3z*Qj)x|AO>gH!unO&r)l1QSg>QSip++!dAPL%v!Wy~Ee&=&(%8nf zY4q=Tmg|ra!2}<4L{Aq+FKF;G+y;y5wB7jYs&(>Nq7^1Ga(zh@*d9b4bl?}fVfK8N Wjg66D#`1_L1zTN~Zg-Vd`RE^0rRiq? diff --git a/farmbot_os/config/config.exs b/farmbot_os/config/config.exs index 90d2478a..cbc7a67f 100644 --- a/farmbot_os/config/config.exs +++ b/farmbot_os/config/config.exs @@ -35,7 +35,7 @@ config :farmbot_core, :behaviour, config :farmbot_ext, :behaviour, authorization: Farmbot.Bootstrap.Authorization config :ecto, json_library: Farmbot.JSON -config :farmbot_os, +config :farmbot, ecto_repos: [Farmbot.Config.Repo, Farmbot.Logger.Repo, Farmbot.Asset.Repo] config :farmbot_core, Farmbot.Config.Repo, @@ -56,12 +56,18 @@ config :farmbot_core, Farmbot.Asset.Repo, database: "asset.#{Mix.env()}.db", priv: "../farmbot_core/priv/asset" -config :farmbot_os, Farmbot.OS.FileSystem, data_path: "/tmp/farmbot" -config :farmbot_os, Farmbot.System, system_tasks: Farmbot.Host.SystemTasks +config :farmbot, Farmbot.OS.FileSystem, data_path: "/tmp/farmbot" +config :farmbot, Farmbot.System, system_tasks: Farmbot.Host.SystemTasks -config :farmbot_os, Farmbot.Platform.Supervisor, +config :farmbot, Farmbot.Platform.Supervisor, platform_children: [ Farmbot.Host.Configurator ] import_config("lagger.exs") + +if Mix.Project.config()[:target] == "host" do + import_config("host/#{Mix.env()}.exs") +else + import_config("target/#{Mix.env()}.exs") +end diff --git a/farmbot_os/config/host/dev.exs b/farmbot_os/config/host/dev.exs index 29638a23..f628a478 100644 --- a/farmbot_os/config/host/dev.exs +++ b/farmbot_os/config/host/dev.exs @@ -1,6 +1,7 @@ use Mix.Config data_path = Path.join(["/", "tmp", "farmbot"]) + config :farmbot_ext, data_path: data_path @@ -23,16 +24,15 @@ config :farmbot_core, Farmbot.Asset.Repo, loggers: [], database: Path.join(data_path, "repo-#{Mix.env()}.sqlite3") -config :farmbot_os, +config :farmbot, ecto_repos: [Farmbot.Config.Repo, Farmbot.Logger.Repo, Farmbot.Asset.Repo], platform_children: [ {Farmbot.Host.Configurator, []} ] -config :farmbot_os, :behaviour, - system_tasks: Farmbot.Host.SystemTasks +config :farmbot, :behaviour, system_tasks: Farmbot.Host.SystemTasks -config :farmbot_os, Farmbot.System.NervesHub, +config :farmbot, Farmbot.System.NervesHub, farmbot_nerves_hub_handler: Farmbot.Host.NervesHubHandler config :farmbot_core, :behaviour, diff --git a/farmbot_os/config/host/test.exs b/farmbot_os/config/host/test.exs new file mode 100644 index 00000000..f7a4e81a --- /dev/null +++ b/farmbot_os/config/host/test.exs @@ -0,0 +1,44 @@ +use Mix.Config + +data_path = Path.join(["/", "tmp", "farmbot"]) + +config :farmbot_ext, + data_path: data_path + +config :logger_backend_ecto, LoggerBackendEcto.Repo, + adapter: Sqlite.Ecto2, + database: Path.join(data_path, "logs.sqlite3") + +config :farmbot_core, Farmbot.Config.Repo, + adapter: Sqlite.Ecto2, + loggers: [], + database: Path.join(data_path, "config-#{Mix.env()}.sqlite3") + +config :farmbot_core, Farmbot.Logger.Repo, + adapter: Sqlite.Ecto2, + loggers: [], + database: Path.join(data_path, "logs-#{Mix.env()}.sqlite3") + +config :farmbot_core, Farmbot.Asset.Repo, + adapter: Sqlite.Ecto2, + loggers: [], + database: Path.join(data_path, "repo-#{Mix.env()}.sqlite3") + +config :farmbot, + ecto_repos: [Farmbot.Config.Repo, Farmbot.Logger.Repo, Farmbot.Asset.Repo], + platform_children: [ + {Farmbot.Host.Configurator, []} + ] + +config :farmbot, :behaviour, system_tasks: Farmbot.Host.SystemTasks + +config :farmbot, Farmbot.System.NervesHub, + farmbot_nerves_hub_handler: Farmbot.Host.NervesHubHandler + +config :farmbot_core, :behaviour, + leds_handler: Farmbot.Leds.StubHandler, + pin_binding_handler: Farmbot.PinBinding.StubHandler, + celery_script_io_layer: Farmbot.OS.IOLayer, + firmware_handler: Farmbot.Firmware.UartHandler + +config :farmbot_core, :uart_handler, tty: "/dev/ttyACM0" diff --git a/farmbot_os/config/target/dev.exs b/farmbot_os/config/target/dev.exs index 701cd4e7..afa70afd 100644 --- a/farmbot_os/config/target/dev.exs +++ b/farmbot_os/config/target/dev.exs @@ -11,9 +11,10 @@ config :farmbot_core, :behaviour, leds_handler: Farmbot.Target.Leds.AleHandler, pin_binding_handler: Farmbot.Target.PinBinding.AleHandler, celery_script_io_layer: Farmbot.OS.IOLayer, - json_parser: Farmbot.JSON.JasonParser + json_parser: Farmbot.JSON.JasonParser data_path = Path.join("/", "root") + config :farmbot_ext, data_path: data_path @@ -36,11 +37,11 @@ config :farmbot_core, Farmbot.Asset.Repo, loggers: [], database: Path.join(data_path, "repo-#{Mix.env()}.sqlite3") -config :farmbot_os, +config :farmbot, ecto_repos: [Farmbot.Config.Repo, Farmbot.Logger.Repo, Farmbot.Asset.Repo], init_children: [ {Farmbot.Target.Leds.AleHandler, []}, - {Farmbot.Firmware.UartHandler.AutoDetector, []}, + {Farmbot.Firmware.UartHandler.AutoDetector, []} ], platform_children: [ {Farmbot.Target.Bootstrap.Configurator, []}, @@ -58,19 +59,16 @@ config :farmbot_os, # Reports Uptime every 60 seconds. {Farmbot.Target.UptimeWorker, []}, {Farmbot.Target.Network.InfoSupervisor, []}, - {Farmbot.Target.Uevent.Supervisor, []}, + {Farmbot.Target.Uevent.Supervisor, []} ] -config :farmbot_os, :behaviour, - system_tasks: Farmbot.Target.SystemTasks +config :farmbot, :behaviour, system_tasks: Farmbot.Target.SystemTasks -config :farmbot_os, Farmbot.System.NervesHub, +config :farmbot, Farmbot.System.NervesHub, farmbot_nerves_hub_handler: Farmbot.System.NervesHubClient config :nerves_hub, client: Farmbot.System.NervesHubClient, public_keys: [File.read!("priv/staging.pub"), File.read!("priv/prod.pub")] -config :nerves_hub, NervesHub.Socket, [ - reconnect_interval: 5_000, -] +config :nerves_hub, NervesHub.Socket, reconnect_interval: 5_000 diff --git a/farmbot_os/config/target/prod.exs b/farmbot_os/config/target/prod.exs index 73e81c86..6d73454a 100644 --- a/farmbot_os/config/target/prod.exs +++ b/farmbot_os/config/target/prod.exs @@ -5,9 +5,10 @@ config :farmbot_core, :behaviour, leds_handler: Farmbot.Target.Leds.AleHandler, pin_binding_handler: Farmbot.Target.PinBinding.AleHandler, celery_script_io_layer: Farmbot.OS.IOLayer, - json_parser: Farmbot.JSON.JasonParser + json_parser: Farmbot.JSON.JasonParser data_path = Path.join("/", "root") + config :farmbot_ext, data_path: data_path @@ -30,11 +31,11 @@ config :farmbot_core, Farmbot.Asset.Repo, loggers: [], database: Path.join(data_path, "repo-#{Mix.env()}.sqlite3") -config :farmbot_os, +config :farmbot, ecto_repos: [Farmbot.Config.Repo, Farmbot.Logger.Repo, Farmbot.Asset.Repo], init_children: [ {Farmbot.Target.Leds.AleHandler, []}, - {Farmbot.Firmware.UartHandler.AutoDetector, []}, + {Farmbot.Firmware.UartHandler.AutoDetector, []} ], platform_children: [ {Farmbot.Target.Bootstrap.Configurator, []}, @@ -52,20 +53,16 @@ config :farmbot_os, # Reports Uptime every 60 seconds. {Farmbot.Target.UptimeWorker, []}, {Farmbot.Target.Network.InfoSupervisor, []}, - {Farmbot.Target.Uevent.Supervisor, []}, + {Farmbot.Target.Uevent.Supervisor, []} ] -config :farmbot_os, :behaviour, - system_tasks: Farmbot.Target.SystemTasks +config :farmbot, :behaviour, system_tasks: Farmbot.Target.SystemTasks - -config :farmbot_os, Farmbot.System.NervesHub, +config :farmbot, Farmbot.System.NervesHub, farmbot_nerves_hub_handler: Farmbot.System.NervesHubClient config :nerves_hub, client: Farmbot.System.NervesHubClient, public_keys: [File.read!("priv/staging.pub"), File.read!("priv/prod.pub")] -config :nerves_hub, NervesHub.Socket, [ - reconnect_interval: 5_000, -] +config :nerves_hub, NervesHub.Socket, reconnect_interval: 5_000 diff --git a/farmbot_os/lib/easter_eggs.ex b/farmbot_os/lib/easter_eggs.ex index b66e69bf..8eda6294 100644 --- a/farmbot_os/lib/easter_eggs.ex +++ b/farmbot_os/lib/easter_eggs.ex @@ -38,7 +38,7 @@ defmodule Farmbot.EasterEggs do end defp load_data do - Path.join(:code.priv_dir(:farmbot_os), "easter_eggs.json") + Path.join(:code.priv_dir(:farmbot), "easter_eggs.json") |> File.read!() |> Farmbot.JSON.decode!() end diff --git a/farmbot_os/lib/filesystem.ex b/farmbot_os/lib/filesystem.ex index b5cc5111..4b595801 100644 --- a/farmbot_os/lib/filesystem.ex +++ b/farmbot_os/lib/filesystem.ex @@ -1,9 +1,9 @@ defmodule Farmbot.OS.FileSystem do - @data_path Application.get_env(:farmbot_os, __MODULE__)[:data_path] + @data_path Application.get_env(:farmbot, __MODULE__)[:data_path] @data_path || Mix.raise(""" - config :farmbot_os, Farmbot.OS.Filesystem, + config :farmbot, Farmbot.OS.Filesystem, data_path: "/path/to/folder" """) def data_path, do: @data_path -end \ No newline at end of file +end diff --git a/farmbot_os/lib/init/ecto.ex b/farmbot_os/lib/init/ecto.ex index b4f08866..025441e0 100644 --- a/farmbot_os/lib/init/ecto.ex +++ b/farmbot_os/lib/init/ecto.ex @@ -14,16 +14,16 @@ defmodule Farmbot.System.Init.Ecto do @doc "Replacement for Mix.Tasks.Ecto.Create" def setup do - repos = Application.get_env(:farmbot_os, :ecto_repos) + repos = Application.get_env(:farmbot, :ecto_repos) for repo <- repos do - Application.put_env(:farmbot_os, :repo_hack, repo) + Application.put_env(:farmbot, :repo_hack, repo) setup(repo) end end def setup(repo) do - db_file = Application.get_env(:farmbot_os, repo)[:database] + db_file = Application.get_env(:farmbot, repo)[:database] unless File.exists?(db_file) do :ok = repo.__adapter__.storage_up(repo.config) @@ -32,7 +32,7 @@ defmodule Farmbot.System.Init.Ecto do @doc "Replacement for Mix.Tasks.Ecto.Drop" def drop do - repos = Application.get_env(:farmbot_os, :ecto_repos) + repos = Application.get_env(:farmbot, :ecto_repos) for repo <- repos do case drop(repo) do @@ -49,11 +49,11 @@ defmodule Farmbot.System.Init.Ecto do @doc "Replacement for Mix.Tasks.Ecto.Migrate" def migrate do - repos = Application.get_env(:farmbot_os, :ecto_repos) - Application.put_env(:farmbot_os, :repo_hack, nil) + repos = Application.get_env(:farmbot, :ecto_repos) + Application.put_env(:farmbot, :repo_hack, nil) for repo <- repos do - Application.put_env(:farmbot_os, :repo_hack, repo) + Application.put_env(:farmbot, :repo_hack, repo) # setup(repo) migrate(repo) end diff --git a/farmbot_os/lib/init/supervisor.ex b/farmbot_os/lib/init/supervisor.ex index 96775473..63a1ff2e 100644 --- a/farmbot_os/lib/init/supervisor.ex +++ b/farmbot_os/lib/init/supervisor.ex @@ -6,7 +6,7 @@ defmodule Farmbot.System.Init.Supervisor do end def init([]) do - children = Application.get_env(:farmbot_os, :init_children, []) ++ [ + children = Application.get_env(:farmbot, :init_children, []) ++ [ {Farmbot.System.Init.FSCheckup, []}, {Farmbot.System.Init.Ecto, []}, ] diff --git a/farmbot_os/lib/nerves_hub.ex b/farmbot_os/lib/nerves_hub.ex index 4b301e4a..9370cf7c 100644 --- a/farmbot_os/lib/nerves_hub.ex +++ b/farmbot_os/lib/nerves_hub.ex @@ -22,7 +22,7 @@ defmodule Farmbot.System.NervesHub do get_config_value: 3, update_config_value: 4 ] - @handler Application.get_env(:farmbot_os, __MODULE__)[:farmbot_nerves_hub_handler] + @handler Application.get_env(:farmbot, __MODULE__)[:farmbot_nerves_hub_handler] || Mix.raise("missing :farmbot_nerves_hub_handler module") @doc "Function to return a String serial number. " diff --git a/farmbot_os/lib/platform_supervisor.ex b/farmbot_os/lib/platform_supervisor.ex index 0999f076..c23511c2 100644 --- a/farmbot_os/lib/platform_supervisor.ex +++ b/farmbot_os/lib/platform_supervisor.ex @@ -8,7 +8,7 @@ defmodule Farmbot.Platform.Supervisor do end def init([]) do - platform_children = Application.get_env(:farmbot_os, __MODULE__)[:platform_children] + platform_children = Application.get_env(:farmbot, __MODULE__)[:platform_children] Supervisor.init(platform_children, strategy: :one_for_all) end end diff --git a/farmbot_os/lib/shoehorn_handler.ex b/farmbot_os/lib/shoehorn_handler.ex index 3808d14a..fcb51663 100644 --- a/farmbot_os/lib/shoehorn_handler.ex +++ b/farmbot_os/lib/shoehorn_handler.ex @@ -8,14 +8,14 @@ defmodule Farmbot.OS.ShoehornHandler do def application_exited(:farmbot_core, reason, state) do Logger.error "FarmbotCore exited: #{inspect reason}" - Application.stop(:farmbot_os) - Application.ensure_all_started(:farmbot_os) + Application.stop(:farmbot) + Application.ensure_all_started(:farmbot) {:continue, state} end - def application_exited(:farmbot_os, reason, state) do + def application_exited(:farmbot, reason, state) do Logger.error "FarmbotOS exited: #{inspect reason}" - Application.ensure_all_started(:farmbot_os) + Application.ensure_all_started(:farmbot) {:continue, state} end diff --git a/farmbot_os/lib/system.ex b/farmbot_os/lib/system.ex index 04b49c58..2fe5f49b 100644 --- a/farmbot_os/lib/system.ex +++ b/farmbot_os/lib/system.ex @@ -8,7 +8,7 @@ defmodule Farmbot.System do Please configure `:system_tasks`! """ - @system_tasks Application.get_env(:farmbot_os, __MODULE__)[:system_tasks] + @system_tasks Application.get_env(:farmbot, __MODULE__)[:system_tasks] @system_tasks || Mix.raise(error_msg) @data_path Farmbot.OS.FileSystem.data_path() diff --git a/farmbot_os/mix.exs b/farmbot_os/mix.exs index 65219f1c..455cc81e 100644 --- a/farmbot_os/mix.exs +++ b/farmbot_os/mix.exs @@ -8,9 +8,11 @@ defmodule Farmbot.OS.MixProject do System.put_env("NERVES_FW_MISC", @branch) @elixir_version Path.join([__DIR__, "..", "ELIXIR_VERSION"]) |> File.read!() |> String.trim() + System.put_env("NERVES_FW_VCS_IDENTIFIER", @commit) + def project do [ - app: :farmbot_os, + app: :farmbot, elixir: @elixir_version, target: @target, version: @version, diff --git a/farmbot_os/mix.lock.host b/farmbot_os/mix.lock.host index 0ae2b54c..dd23ece1 100644 --- a/farmbot_os/mix.lock.host +++ b/farmbot_os/mix.lock.host @@ -9,7 +9,7 @@ "cowlib": {:hex, :cowlib, "2.6.0", "8aa629f81a0fc189f261dc98a42243fa842625feea3c7ec56c48f4ccdb55490f", [:rebar3], [], "hexpm"}, "db_connection": {:hex, :db_connection, "1.1.3", "89b30ca1ef0a3b469b1c779579590688561d586694a3ce8792985d4d7e575a61", [:mix], [{:connection, "~> 1.0.2", [hex: :connection, repo: "hexpm", optional: false]}, {:poolboy, "~> 1.5", [hex: :poolboy, repo: "hexpm", optional: true]}, {:sbroker, "~> 1.0", [hex: :sbroker, repo: "hexpm", optional: true]}], "hexpm"}, "decimal": {:hex, :decimal, "1.6.0", "bfd84d90ff966e1f5d4370bdd3943432d8f65f07d3bab48001aebd7030590dcc", [:mix], [], "hexpm"}, - "dialyxir": {:hex, :dialyxir, "1.0.0-rc.3", "774306f84973fc3f1e2e8743eeaa5f5d29b117f3916e5de74c075c02f1b8ef55", [:mix], [], "hexpm"}, + "dialyxir": {:hex, :dialyxir, "1.0.0-rc.4", "71b42f5ee1b7628f3e3a6565f4617dfb02d127a0499ab3e72750455e986df001", [:mix], [{:erlex, "~> 0.1", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm"}, "distillery": {:hex, :distillery, "2.0.10", "e9f1f1d3f4a89996a3e1a555872feed8a3a73e3d10b51886941382d29ca58f99", [:mix], [{:artificery, "~> 0.2", [hex: :artificery, repo: "hexpm", optional: false]}], "hexpm"}, "earmark": {:hex, :earmark, "1.2.6", "b6da42b3831458d3ecc57314dff3051b080b9b2be88c2e5aa41cd642a5b044ed", [:mix], [], "hexpm"}, "ecto": {:hex, :ecto, "2.2.9", "031d55df9bb430cb118e6f3026a87408d9ce9638737bda3871e5d727a3594aae", [:mix], [{:db_connection, "~> 1.1", [hex: :db_connection, repo: "hexpm", optional: true]}, {:decimal, "~> 1.2", [hex: :decimal, repo: "hexpm", optional: false]}, {:mariaex, "~> 0.8.0", [hex: :mariaex, repo: "hexpm", optional: true]}, {:poison, "~> 2.2 or ~> 3.0", [hex: :poison, repo: "hexpm", optional: true]}, {:poolboy, "~> 1.5", [hex: :poolboy, repo: "hexpm", optional: false]}, {:postgrex, "~> 0.13.0", [hex: :postgrex, repo: "hexpm", optional: true]}, {:sbroker, "~> 1.0", [hex: :sbroker, repo: "hexpm", optional: true]}], "hexpm"}, diff --git a/farmbot_os/platform/host/nerves_hub_handler.ex b/farmbot_os/platform/host/nerves_hub_handler.ex index 476d29e4..2e6c66a7 100644 --- a/farmbot_os/platform/host/nerves_hub_handler.ex +++ b/farmbot_os/platform/host/nerves_hub_handler.ex @@ -3,6 +3,7 @@ defmodule Farmbot.Host.NervesHubHandler do def serial_number do {:ok, [_ | [{_ifname, info} | _]]} = :inet.getifaddrs() + :io_lib.format('~2.16.0B~2.16.0B~2.16.0B~2.16.0B~2.16.0B~2.16.0B', info[:hwaddr]) |> to_string() |> String.trim() @@ -16,11 +17,12 @@ defmodule Farmbot.Host.NervesHubHandler do def deconfigure, do: :ok - def config, do: [ - serial_number(), - "Not a real cert", - "Not a real key" - ] + def config, + do: [ + serial_number(), + "Not a real cert", + "Not a real key" + ] def check_update, do: nil diff --git a/farmbot_os/platform/target/configurator/captive_portal.ex b/farmbot_os/platform/target/configurator/captive_portal.ex index 6cda118d..006b278e 100644 --- a/farmbot_os/platform/target/configurator/captive_portal.ex +++ b/farmbot_os/platform/target/configurator/captive_portal.ex @@ -2,8 +2,8 @@ defmodule Farmbot.Target.Bootstrap.Configurator.CaptivePortal do use GenServer require Farmbot.Logger - @interface Application.get_env(:farmbot_os, :captive_portal_interface, "wlan0") - @address Application.get_env(:farmbot_os, :captive_portal_address, "192.168.25.1") + @interface Application.get_env(:farmbot, :captive_portal_interface, "wlan0") + @address Application.get_env(:farmbot, :captive_portal_address, "192.168.25.1") @mdns_domain "farmbot-setup.local" @dnsmasq_conf_file "dnsmasq.conf" diff --git a/farmbot_os/platform/target/configurator/router.ex b/farmbot_os/platform/target/configurator/router.ex index 71ed11aa..89aa3643 100644 --- a/farmbot_os/platform/target/configurator/router.ex +++ b/farmbot_os/platform/target/configurator/router.ex @@ -210,7 +210,7 @@ defmodule Farmbot.Target.Bootstrap.Configurator.Router do ntp_server_1 = conn.params["ntp_server_1"] |> remove_empty_string() ntp_server_2 = conn.params["ntp_server_2"] |> remove_empty_string() - reg_domain = conn.params["regulatory_domain"] |> remove_empty_string() + reg_domain = conn.params["regulatory_domain"] |> remove_empty_string() ssh_key = conn.params["ssh_key"] |> remove_empty_string() @@ -244,7 +244,7 @@ defmodule Farmbot.Target.Bootstrap.Configurator.Router do ipv4_address: ipv4_address, ipv4_gateway: ipv4_gateway, ipv4_subnet_mask: ipv4_subnet_mask, - regulatory_domain: reg_domain, + regulatory_domain: reg_domain }) redir(conn, "/firmware") diff --git a/farmbot_os/platform/target/nerves_hub_client.ex b/farmbot_os/platform/target/nerves_hub_client.ex index fb617da3..539d1255 100644 --- a/farmbot_os/platform/target/nerves_hub_client.ex +++ b/farmbot_os/platform/target/nerves_hub_client.ex @@ -4,7 +4,7 @@ defmodule Farmbot.System.NervesHubClient do """ use GenServer - use Farmbot.Logger + require Farmbot.Logger alias Farmbot.BotState.JobProgress @behaviour NervesHub.Client @@ -20,7 +20,11 @@ defmodule Farmbot.System.NervesHubClient do def serial_number(:rpi3), do: serial_number("rpi") def serial_number(plat) do - :os.cmd('/usr/bin/boardid -b uboot_env -u nerves_serial_number -b uboot_env -u serial_number -b #{plat}') + :os.cmd( + '/usr/bin/boardid -b uboot_env -u nerves_serial_number -b uboot_env -u serial_number -b #{ + plat + }' + ) |> to_string() |> String.trim() end @@ -30,10 +34,10 @@ defmodule Farmbot.System.NervesHubClient do def serial_number, do: serial_number(Farmbot.Project.target()) def connect do - Logger.debug 3, "Starting OTA Service" + Farmbot.Logger.debug(3, "Starting OTA Service") # NervesHub replaces it's own env on startup. Reset it. - Application.put_env(:nerves_hub, NervesHub.Socket, [reconnect_interval: 5000]) - + Application.put_env(:nerves_hub, NervesHub.Socket, reconnect_interval: 5000) + supervisor = Farmbot.System.Supervisor # Stop Nerves Hub if it is running. _ = Supervisor.terminate_child(supervisor, NervesHub.Supervisor) @@ -47,7 +51,7 @@ defmodule Farmbot.System.NervesHubClient do # Start the connection again. {:ok, _pid} = Supervisor.start_child(supervisor, NervesHub.Supervisor) - Logger.debug 3, "OTA Service started" + Logger.debug(3, "OTA Service started") :ok end @@ -74,9 +78,9 @@ defmodule Farmbot.System.NervesHubClient do [ Nerves.Runtime.KV.get("nerves_fw_serial_number"), Nerves.Runtime.KV.get("nerves_hub_cert"), - Nerves.Runtime.KV.get("nerves_hub_key"), + Nerves.Runtime.KV.get("nerves_hub_key") ] - |> Enum.map(fn(val) -> + |> Enum.map(fn val -> if val == "", do: nil, else: val end) end @@ -85,15 +89,18 @@ defmodule Farmbot.System.NervesHubClient do case GenServer.call(__MODULE__, :check_update) do # If updates were disabled, and an update is queued {:ignore, _url} -> - Logger.info 1, "Applying OTA update" + Farmbot.Logger.info(1, "Applying OTA update") NervesHub.update() + _ -> - Logger.debug 1, "No update cached. Checking for tag changes." + Farmbot.Logger.debug(1, "No update cached. Checking for tag changes.") + case NervesHub.HTTPClient.update() do {:ok, %{"data" => %{"update_available" => false}}} -> do_backup_strats() + _ -> - Logger.info 1, "Applying OTA update" + Farmbot.Logger.info(1, "Applying OTA update") NervesHub.update() end end @@ -102,11 +109,12 @@ defmodule Farmbot.System.NervesHubClient do defp do_backup_strats do case Farmbot.System.Updates.check_updates() do {version, url} -> - Logger.busy 1, "Downloading fallback OTA" + Logger.busy(1, "Downloading fallback OTA") Farmbot.System.Updates.download_and_apply_update({version, url}) :ok + _ -> - Logger.success 1, "Farmbot is up to date!" + Logger.success(1, "Farmbot is up to date!") nil end end @@ -117,46 +125,56 @@ defmodule Farmbot.System.NervesHubClient do end def handle_error(args) do - Logger.error 1, "OTA failed to download: #{inspect(args)}" + Logger.error(1, "OTA failed to download: #{inspect(args)}") prog = %JobProgress.Percent{status: :error} + if Process.whereis(Farmbot.BotState) do Farmbot.BotState.set_job_progress("FBOS_OTA", prog) end + :ok end def handle_fwup_message({:ok, _, info}) do - Logger.success 1, "OTA Complete Going down for reboot" + Logger.success(1, "OTA Complete Going down for reboot") prog = %JobProgress.Percent{percent: 100, status: :complete} + if Process.whereis(Farmbot.BotState) do Farmbot.BotState.set_job_progress("FBOS_OTA", prog) end + :ok end def handle_fwup_message({:progress, 100}) do - Logger.success 1, "OTA Complete. Going down for reboot" + Logger.success(1, "OTA Complete. Going down for reboot") prog = %JobProgress.Percent{percent: 100, status: :complete} + if Process.whereis(Farmbot.BotState) do Farmbot.BotState.set_job_progress("FBOS_OTA", prog) end + :ok end def handle_fwup_message({:progress, percent}) when rem(percent, 5) == 0 do prog = %JobProgress.Percent{percent: percent} + if Process.whereis(Farmbot.BotState) do Farmbot.BotState.set_job_progress("FBOS_OTA", prog) end + :ok end def handle_fwup_message({:error, _, reason}) do - Logger.error 1, "OTA failed to apply: #{inspect(reason)}" + Farmbot.Logger.error(1, "OTA failed to apply: #{inspect(reason)}") prog = %JobProgress.Percent{status: :error} + if Process.whereis(Farmbot.BotState) do Farmbot.BotState.set_job_progress("FBOS_OTA", prog) end + :ok end @@ -165,7 +183,7 @@ defmodule Farmbot.System.NervesHubClient do end def start_link(_, _) do - GenServer.start_link(__MODULE__, [], [name: __MODULE__]) + GenServer.start_link(__MODULE__, [], name: __MODULE__) end def init([]) do @@ -177,12 +195,14 @@ defmodule Farmbot.System.NervesHubClient do if Process.whereis(Farmbot.BotState) do Farmbot.BotState.set_update_available(true) end + case get_config_value(:bool, "settings", "os_auto_update") do true -> - Logger.success 1, "Applying OTA update" + Logger.success(1, "Applying OTA update") {:reply, :apply, {:apply, url}} + false -> - Logger.info 1, "New Farmbot OS is available!" + Logger.info(1, "New Farmbot OS is available!") {:reply, :ignore, {:ignore, url}} end end @@ -193,15 +213,20 @@ defmodule Farmbot.System.NervesHubClient do defp maybe_post_update do case File.read(update_file()) do - {:ok, @current_version} -> :ok + {:ok, @current_version} -> + :ok + {:ok, old_version} -> - Logger.info 1, "Updating FarmbotOS from #{old_version} to #{@current_version}" + Logger.info(1, "Updating FarmbotOS from #{old_version} to #{@current_version}") do_post_update() {:error, :enoent} -> - Logger.info 1, "Setting up FarmbotOS #{@current_version}" - {:error, err} -> raise err + Logger.info(1, "Setting up FarmbotOS #{@current_version}") + + {:error, err} -> + raise err end + before_update() end @@ -209,8 +234,9 @@ defmodule Farmbot.System.NervesHubClient do alias Farmbot.Firmware.UartHandler.Update hw = get_config_value(:string, "settings", "firmware_hardware") is_beta? = Farmbot.Project.branch() in ["beta", "staging"] + if is_beta? do - Logger.debug 1, "Forcing beta image arduino firmware flash." + Logger.debug(1, "Forcing beta image arduino firmware flash.") Update.force_update_firmware(hw) else Update.maybe_update_firmware(hw) diff --git a/farmbot_os/platform/target/network/network.ex b/farmbot_os/platform/target/network/network.ex index 732070eb..ab13ee76 100644 --- a/farmbot_os/platform/target/network/network.ex +++ b/farmbot_os/platform/target/network/network.ex @@ -186,8 +186,11 @@ defmodule Farmbot.Target.Network do ipv4_gateway: config.ipv4_gateway, ipv4_subnet_mask: config.ipv4_subnet_mask ] - "dhcp" -> - [ipv4_address_method: :dhcp] + + {name, Keyword.merge(opts, settings)} + + "dhcp" -> + {name, opts} end |> maybe_use_name_servers(config) |> maybe_use_domain(config) diff --git a/farmbot_os/rel/config.exs b/farmbot_os/rel/config.exs index bb5088e7..5b9012eb 100644 --- a/farmbot_os/rel/config.exs +++ b/farmbot_os/rel/config.exs @@ -1,12 +1,11 @@ use Mix.Releases.Config, - # This sets the default release built by `mix release` - default_release: :default, - # This sets the default environment used by `mix release` - default_environment: :dev + # This sets the default release built by `mix release` + default_release: :default, + # This sets the default environment used by `mix release` + default_environment: :dev # For a full list of config options for both releases -# and environments, visit https://hexdocs.pm/distillery/configuration.html - +# and environments, visit https://hexdocs.pm/distillery/config/distillery.html # You may define one or more environments in this file, # an environment's settings will override those of a release @@ -14,13 +13,11 @@ use Mix.Releases.Config, # and environment configuration is called a profile environment :dev do - set(cookie: :"gz`tgx[zM,ueL[g{Ji62{jiawNDZHH~PGkNQLa&R>R7c0SKziff4L,*&ZNG)(qu0") - set(vm_args: "rel/vm.args") + set(cookie: :"Unused with Nerves. See vm.args") end environment :prod do - set(cookie: :"gz`tgx[zM,ueL[g{Ji62{jiawNDZHH~PGkNQLa&R>R7c0SKziff4L,*&ZNG)(qu0") - set(vm_args: "rel/vm.args") + set(cookie: :"Unused with Nerves. See vm.args") end # You may define one or more releases in this file. @@ -29,7 +26,7 @@ end # will be used by default release :farmbot do - set version: current_version(:farmbot) - plugin Shoehorn - plugin Nerves + set(version: current_version(:farmbot)) + plugin(Nerves) + plugin(Shoehorn) end diff --git a/farmbot_os/rel/plugins/.gitignore b/farmbot_os/rel/plugins/.gitignore new file mode 100644 index 00000000..4fa3b5c2 --- /dev/null +++ b/farmbot_os/rel/plugins/.gitignore @@ -0,0 +1,3 @@ +*.* +!*.exs +!.gitignore \ No newline at end of file diff --git a/scripts/update_deps_for_all_platforms.sh b/scripts/update_deps_for_all_platforms.sh index 123a5f43..dae8424b 100755 --- a/scripts/update_deps_for_all_platforms.sh +++ b/scripts/update_deps_for_all_platforms.sh @@ -1,5 +1,6 @@ #!/bin/bash PROJECTS="farmbot_celery_script \ +farmbot_firmware \ farmbot_core \ farmbot_ext \ farmbot_os