dotfiles

$HOME is where the <3 is
git clone git://git.alexkarle.com/dotfiles.git
Log | Files | Refs | Submodules | README

commit 9accb8e941495a87e9ea7f743d9ef1b3c788de31 (patch)
parent ae3d6b345dac2b470e571c2e64d3a2034f1792b0
Author: Alex Karle <alex@karle.co>
Date:   Wed, 27 May 2020 20:32:09 -0400

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.

Diffstat:
Abin/psync | 30++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+), 0 deletions(-)

diff --git a/bin/psync 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