blob: 27746510b8797deae5190863332ff11e3f882899 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
#!/bin/bash
bw config server "https://{{ passwd_domain }}"
bw login --apikey --quiet
bw unlock --passwordenv BW_PASSWORD --quiet
# https://github.com/bitwarden/clients/issues/3366
function bw_get() {
local pwd
local count
local organisation=${2:-notnull}
count=$(bw list items --pretty --organizationid ${organisation} | jq -r '[.[] | select(.name=="'$1'")] | length')
if [[ "$count" -gt 1 ]]; then
echo "Multiple items found"
return 1
fi
if [[ "$count" -lt 1 ]]; then
echo "No items found"
return 1
fi
pwd=$(bw list items --pretty --organizationid ${organisation} | jq -r '.[] | select(.name=="'$1'")')
if [[ -z "$pwd" ]]; then
echo "Password not found"
return 1
fi
echo "$pwd"
}
bw_get $@
bw --quiet lock
|