Enable setting config securely in firmware/config/secrets.exs
This commit is contained in:
parent
fe172f018a
commit
8f99154259
7 changed files with 17 additions and 15 deletions
12
README.md
12
README.md
|
@ -12,6 +12,7 @@ If you have found the source code before finding the geocache, consider it a hin
|
|||
|
||||
Building:
|
||||
```bash
|
||||
export MIX_ENV=prod && export MIX_TARGET=<device>
|
||||
cd ui/assets && npm install
|
||||
cd ../ && mix phx.digest
|
||||
cd ../firmware && mix deps.get
|
||||
|
@ -20,12 +21,9 @@ mix firmware.burn # After inserting SD card
|
|||
```
|
||||
|
||||
## Setting morse code
|
||||
Still have to find out how to correctly set secrets... so I have to do it manually now.
|
||||
|
||||
```bash
|
||||
ssh nerves.local
|
||||
```
|
||||
|
||||
To set the morse code, create a new file under firmware/config, called secrets.exs:
|
||||
```elixir
|
||||
System.set_env("MORSE_MESSAGE", "...---...")
|
||||
use Mix.Config
|
||||
|
||||
config :morse, :morse_message, "...---..."
|
||||
```
|
||||
|
|
3
firmware/config/secrets.exs
Normal file
3
firmware/config/secrets.exs
Normal file
|
@ -0,0 +1,3 @@
|
|||
use Mix.Config
|
||||
|
||||
config :morse, :morse_message, "................"
|
|
@ -37,6 +37,10 @@ config :nerves_init_gadget,
|
|||
node_name: node_name,
|
||||
node_host: :mdns_domain
|
||||
|
||||
if File.exists?("config/secrets.exs") do
|
||||
import_config "secrets.exs"
|
||||
end
|
||||
|
||||
# Import target specific config. This must remain at the bottom
|
||||
# of this file so it overrides the configuration defined above.
|
||||
# Uncomment to use target specific configurations
|
||||
|
|
1
morse/.gitignore
vendored
1
morse/.gitignore
vendored
|
@ -21,4 +21,3 @@ erl_crash.dump
|
|||
|
||||
# Ignore package tarball (built via "mix hex.build").
|
||||
morse-*.tar
|
||||
|
||||
|
|
|
@ -21,12 +21,7 @@ defmodule Morse do
|
|||
"""
|
||||
|
||||
def signal do
|
||||
case System.get_env("MORSE_MESSAGE") do
|
||||
nil ->
|
||||
# Signal for SOS if the env variable wasn't found :)
|
||||
signal("...---...")
|
||||
message -> signal(message)
|
||||
end
|
||||
signal(Application.fetch_env!(:morse, :morse_message))
|
||||
end
|
||||
|
||||
def signal(symbols) do
|
||||
|
|
|
@ -14,7 +14,8 @@ defmodule Morse.MixProject do
|
|||
# Run "mix help compile.app" to learn about applications.
|
||||
def application do
|
||||
[
|
||||
extra_applications: [:logger]
|
||||
extra_applications: [:logger],
|
||||
env: [morse_message: "...---..."]
|
||||
]
|
||||
end
|
||||
|
||||
|
|
2
ui/.gitignore
vendored
2
ui/.gitignore
vendored
|
@ -32,3 +32,5 @@ npm-debug.log
|
|||
# we ignore priv/static. You may want to comment
|
||||
# this depending on your deployment strategy.
|
||||
/priv/static/
|
||||
|
||||
config/secrets.exs
|
||||
|
|
Loading…
Reference in a new issue