Better default path handling (#7)
* Better handling of default store * Add store name as a settings param
This commit is contained in:
11
PROTOCOL.md
11
PROTOCOL.md
@@ -64,15 +64,17 @@ Settings are applied using the following priority, highest first:
|
||||
### Global Settings
|
||||
|
||||
| Setting | Description | Default |
|
||||
| ------- | ---------------------------------------------------- | ------- |
|
||||
| ------------ | ---------------------------------------------------- | ------- |
|
||||
| gpgPath | Optional path to gpg binary | `null` |
|
||||
| stores | List of password stores with store-specific settings | `null` |
|
||||
| defaultStore | Store-specific settings for default store | `{}` |
|
||||
| stores | List of password stores with store-specific settings | `{}` |
|
||||
|
||||
### Store-specific Settings
|
||||
|
||||
| Setting | Description | Default |
|
||||
| ------- | ---------------------------------------------------- | ------- |
|
||||
| | | |
|
||||
| ------------ | ---------------------------------------------------- | ------- |
|
||||
| name | Store name (same as the store key) | <key> |
|
||||
| path | Path to the password store directory | `""` |
|
||||
|
||||
## Actions
|
||||
|
||||
@@ -99,6 +101,7 @@ is alive, determine the version at startup, and provide per-store defaults.
|
||||
“version”: <int>
|
||||
“response”: {
|
||||
"defaultPath": "/path/to/default/store",
|
||||
"defaultSettings": <raw contents of $defaultPath/.browserpass.json>,
|
||||
“storeSettings”: {
|
||||
“storeName”: <raw contents of storePath/.browserpass.json>
|
||||
}
|
||||
|
@@ -96,6 +96,13 @@ function configure()
|
||||
[ -n "$PASSWORD_STORE_DIR" ] || PASSWORD_STORE_DIR="~/.password-store"
|
||||
OUTPUT="$(jq -n --arg defaultPath "$PASSWORD_STORE_DIR" '.defaultPath = $defaultPath')"
|
||||
|
||||
STOREPATH=$(echo "$PASSWORD_STORE_DIR" | sed 's/^~/$HOME/' | envsubst)
|
||||
if [ -f "$STOREPATH/.browserpass.json" ]; then
|
||||
OUTPUT=$(jq --arg settings "$(cat "$STOREPATH/.browserpass.json")" '.defaultSettings = $settings' <<< "$OUTPUT")
|
||||
else
|
||||
OUTPUT=$(jq '.defaultSettings = ""' <<< "$OUTPUT")
|
||||
fi
|
||||
|
||||
for STORE in "${!STORES[@]}"; do
|
||||
OUTPUT=$(jq --arg store "$STORE" --arg settings "${STORES[$STORE]}" '.storeSettings[$store] = $settings' <<< "$OUTPUT")
|
||||
done
|
||||
|
Reference in New Issue
Block a user