28 lines
681 B
Bash
Executable File
28 lines
681 B
Bash
Executable File
#!/bin/sh
|
|
set -euf
|
|
|
|
PASSAGE_DIR="${PASSAGE_DIR:-$HOME/.passage/store}"
|
|
PASSAGE_IDENTITIES_FILE="${PASSAGE_IDENTITIES_FILE:-$HOME/.passage/identities}"
|
|
PASSAGE_ROOT="${PASSAGE_DIR%/*}"
|
|
STORE_LOCK="$PASSAGE_ROOT/store.tar.age"
|
|
|
|
lock() {
|
|
[ -d "$PASSAGE_DIR" ] && agetar -e -R "$PASSAGE_DIR/.age-recipients" -o "$STORE_LOCK" "$PASSAGE_DIR" && rm -rf "$PASSAGE_DIR"
|
|
}
|
|
|
|
unlock() {
|
|
[ -f "$STORE_LOCK" ] && agetar -d -i "$PASSAGE_ROOT/identities" -o "$PASSAGE_ROOT" "$STORE_LOCK" && rm -rf "$STORE_LOCK"
|
|
}
|
|
|
|
while getopts :lu OPT; do
|
|
case "$OPT" in
|
|
l) lock ;;
|
|
u) unlock ;;
|
|
*) exit 1 ;;
|
|
esac
|
|
done
|
|
|
|
[ -d "$PASSAGE_DIR" ] && STATE=UNLOCKED
|
|
|
|
echo "Password store is ${STATE:-LOCKED}"
|