aboutsummaryrefslogtreecommitdiff
path: root/dpw-age
diff options
context:
space:
mode:
authorMitchell Riedstra <mitch@riedstra.dev>2025-12-17 18:43:57 -0500
committerMitchell Riedstra <mitch@riedstra.dev>2025-12-17 18:43:57 -0500
commit2ebc6e0e9e27f75fccfdb3b7baede6dc166859c2 (patch)
treed77fcbdb77a78d87fc37613aa8277a6549a4a518 /dpw-age
parent014c2ee5eb6b4ba8b16b2e81ac71b13ecf401081 (diff)
downloaddpw-2ebc6e0e9e27f75fccfdb3b7baede6dc166859c2.tar.gz
dpw-2ebc6e0e9e27f75fccfdb3b7baede6dc166859c2.tar.xz
Add a sync function and ability to expose the configured backend through the dpw frontend
Diffstat (limited to 'dpw-age')
-rwxr-xr-xdpw-age13
1 files changed, 8 insertions, 5 deletions
diff --git a/dpw-age b/dpw-age
index 079e2ee..0c72b73 100755
--- a/dpw-age
+++ b/dpw-age
@@ -1,5 +1,5 @@
#!/bin/sh
-# Copyright 2021 Mitchell Riedstra
+# Copyright 2025 Mitchell Riedstra
#
# Permission to use, copy, modify, and/or distribute this software for any purpose
# with or without fee is hereby granted, provided that the above copyright notice
@@ -24,6 +24,8 @@ DPW_AGE_DIR="${DPW_AGE_DIR:-$HOME/.dpw-age}"
DPW_AGE_KEY="${DPW_AGE_KEY:-$HOME/.dpw-age-key}"
DPW_AGE_RECIPIENT_SUFFIX="${DPW_AGE_RECIPIENT_SUFFIX:-.recipients}"
DPW_AGE_AUTO_SYNC="${DPW_AGE_AUTO_SYNC:-NO}"
+DPW_AGE_BIN="${DPW_AGE_BIN:-age}"
+age="$DPW_AGE_BIN"
# No user overrides
DPW_AGE_RECIPIENTS_FILE=""
@@ -32,6 +34,7 @@ USE_GIT=0
# Helper functions
+
_git_commit() {
[ $USE_GIT -eq 0 ] && return
cd "${DPW_AGE_DIR}"
@@ -97,7 +100,7 @@ sync() {
show() {
pth="$1"; shift
#shellcheck disable=SC2086
-exec age -i "${DPW_AGE_KEY}" -d < "${DPW_AGE_DIR}/${pth}.age"
+exec "$age" -i "${DPW_AGE_KEY}" -d < "${DPW_AGE_DIR}/${pth}.age"
}
@@ -106,7 +109,7 @@ pth="$1"; shift
_set_age_recipients "$pth"
mkdir -p "$DPW_AGE_DIR/$(dirname "$pth")"
#shellcheck disable=SC2086
-age -R "$DPW_AGE_RECIPIENTS_FILE" -e \
+"$age" -R "$DPW_AGE_RECIPIENTS_FILE" -e \
> "${DPW_AGE_DIR}/${pth}.age"
_git_commit "Insert: $pth"
}
@@ -226,9 +229,9 @@ grep -q YUBIKEY "${DPW_AGE_KEY}" \
&& echo "Detected yubikey, you may need to tap it..."
# Test the key and recipients before we get too far along
tmpf="$(mktemp)"
-echo "testing our key... works!" | age -R "${DPW_AGE_RECIPIENTS_FILE}" -e \
+echo "testing our key... works!" | "$age" -R "${DPW_AGE_RECIPIENTS_FILE}" -e \
> "$tmpf"
-age -i "${DPW_AGE_KEY}" -d < "$tmpf"
+"$age" -i "${DPW_AGE_KEY}" -d < "$tmpf"
if [ $USE_GIT -eq 1 ] ; then
git init