From 9accb8e941495a87e9ea7f743d9ef1b3c788de31 Mon Sep 17 00:00:00 2001 From: Alex Karle Date: Wed, 27 May 2020 20:32:09 -0400 Subject: [PATCH] bin: Add psync, a tool to sync pash passwords pash is a simple password manager that stores each password as a GPG encrypted key (see submodules for link). I like to backup to a central, always on, host in my apartment (defaulting to a raspberry pi) so that I can easily transfer passwords between my desktop and laptop. There's a slight chance of password loss with the "sync" action (i.e. someone else updated a password that you have a stale copy of), so it defaults to needing to specify push/pull/sync for safety. --- bin/psync | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100755 bin/psync diff --git a/bin/psync b/bin/psync new file mode 100755 index 0000000..b0b805b --- /dev/null +++ b/bin/psync @@ -0,0 +1,30 @@ +#!/bin/sh +# Synchronize pash passwords with a central host +PHOST=${PSYNC_HOST:="raspberrypi"} +PUSER=${PSYNC_USER:="pi"} + +die() { + echo "$1" 1>&2 + exit 1 +} + +push() { + rsync -av $HOME/.local/share/pash/ $PUSER@$PHOST:.local/share/pash/ +} + +pull() { + rsync -av $PUSER@$PHOST:.local/share/pash/ $HOME/.local/share/pash/ +} + +sync() { + # Assume current passwords are latest (push then pull) + push + pull +} + +case "$1" in + push) push ;; + pull) pull ;; + sync) sync ;; + *) die "usage: psync push|pull|sync" +esac -- libgit2 0.28.4