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