From 43bc144185ce6ac2a4a8adaa5a92dd3e14023dd9 Mon Sep 17 00:00:00 2001 From: Rudis Muiznieks Date: Sun, 29 Aug 2021 18:43:29 -0500 Subject: [PATCH] fixed new config save, updated docs --- README.md | 13 ++++++++++++- dotplan | 7 ++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d534415..fc9a25d 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ Configure your email and password in `~/.dotplan.conf.json`. Make sure this file } ``` -- `dotplan register` will register a new account using the email and password in your `~/.dotplan.conf.json` file +- `dotplan register` will prompt for an email address and password and attempt to register it for you, optionally saving it to your `~/.dotplan.conf.json` file - `dotplan publish` will sign (if `minisign` is available) and publish your `~/.plan` file to your dotplan provider - `dotplan edit` will open your `~/.plan` file in an editor, then sign (if `minisign` is available) and publish it to your dotplan provider after you save and exit @@ -49,3 +49,14 @@ If you set `auth.provider` in your `~/.dotplan.conf.json` file, the `register`, "relayProvider": "https://dotplan.online" } ``` + +Several other aspects can be configured via environment variables: + +- `DOTPLAN_CONFIG_PATH`: the config file to read and write (`$HOME/.dotplan.conf.json`) +- `DOTPLAN_MINISIGN_PRIVATE_KEY` the location of your private key (`$HOME/.minisign/minisign.key`) +- `DOTPLAN_PLAN_PATH` the location of your plan for the `publish` and `edit` commands (`$HOME/.plan`) +- `DOTPLAN_PLAN_SIG_PATH` where to save the signature for the `publish` and `edit` commands (`$HOME/.plan.minisig`) +- `DOTPLAN_CURL_PATH` to specify the location of `curl` +- `DOTPLAN_JQ_PATH` to specify the location of `jq` +- `DOTPLAN_DRILL_PATH` to specify the location of `drill` or `dig` +- `DOTPLAN_MINISIGN_PATH` to specify the location of `minisign` diff --git a/dotplan b/dotplan index 6414038..3a17ecd 100755 --- a/dotplan +++ b/dotplan @@ -155,8 +155,13 @@ register() ( write_config=$(read_char) echo "$write_config" if [ "$write_config" = "y" ] || [ "$write_config" = "Y" ]; then - new_config=$($jq --arg email "$register_email" --arg password "$register_password" '.auth.email=$email | .auth.password=$password' < "$config_path") + if [ -r "$config_path" ]; then + new_config=$($jq --arg email "$register_email" --arg password "$register_password" '.auth.email=$email | .auth.password=$password' < "$config_path") + else + new_config=$($jq -n --arg email "$register_email" --arg password "$register_password" '{"auth":{"email":$email,"password":$password}}') + fi echo "$new_config" > "$config_path" + chmod 0600 "$config_path" fi )