aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMitchell Riedstra <mitch@riedstra.dev>2025-12-13 10:10:21 -0500
committerMitchell Riedstra <mitch@riedstra.dev>2025-12-13 10:10:21 -0500
commit51a82abad5cd1c98cbfe94cf36fcca7bb30acf01 (patch)
tree081cca0583319a6c17a76a074e115c47afd4915a
parent2f6e52f82c69ca5aedfbd7c73a63f8fb20bb39f6 (diff)
downloaddpw-51a82abad5cd1c98cbfe94cf36fcca7bb30acf01.tar.gz
dpw-51a82abad5cd1c98cbfe94cf36fcca7bb30acf01.tar.xz
Add an auto-sync function to dpw-age
-rwxr-xr-xdpw-age22
1 files changed, 20 insertions, 2 deletions
diff --git a/dpw-age b/dpw-age
index 3966621..87f5dd9 100755
--- a/dpw-age
+++ b/dpw-age
@@ -23,6 +23,7 @@ umask "$UMASK"
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}"
# No user overrides
DPW_AGE_RECIPIENTS_FILE=""
@@ -36,6 +37,17 @@ _git_commit() {
cd "${DPW_AGE_DIR}"
git add --all
git commit -am "DPW Auto-commit: $1"
+ _git_sync
+}
+
+# Auto push/pull
+_git_sync() {
+ [ $USE_GIT -eq 0 ] && return
+ [ "$DPW_AGE_AUTO_SYNC" != "YES" ] && return
+ cd "${DPW_AGE_DIR}"
+ git fetch
+ git merge
+ git push
}
_set_age_recipients() {
@@ -66,7 +78,6 @@ echo "No '${DPW_AGE_RECIPIENT_SUFFIX}' files found, is '$DPW_AGE_DIR' initialize
exit 1
}
-
# Interface
show() {
@@ -232,6 +243,7 @@ Where command may be one of:
list
insert
rm
+ reencrypt
init
The 'init' command has its own help page.
@@ -241,12 +253,18 @@ dpw-age is influnced by the following enviornment variables:
DPW_AGE_DIR="${DPW_AGE_DIR}"
DPW_AGE_KEY="${DPW_AGE_KEY}
DPW_AGE_RECIPIENT_SUFFIX="${DPW_AGE_RECIPIENT_SUFFIX}"
+DPW_AGE_AUTO_SYNC="${DPW_AGE_AUTO_SYNC}"
PASSWORD_STORE_UMASK="${UMASK}"
-If the above are unset, defaults are shown.
+If the above are set their values are shown, if unset the defaults are shown.
+
+Note on DPW_AGE_AUTO_SYNC, if set to "YES" and DPW_AGE_DIR is a git repository
+then it will automatically fetch, merge, and push for every action. This
+will require you to have set an upstream for the branch you're on.
EOF
}
+if [ -z "$1" ] ; then _help ; exit 1; fi
act="$1"; shift
case $act in
show) show "$@" ;;