summaryrefslogtreecommitdiff
path: root/password-store.sh
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-xpassword-store.sh44
1 files changed, 41 insertions, 3 deletions
diff --git a/password-store.sh b/password-store.sh
index 4730133..58e7dcd 100755
--- a/password-store.sh
+++ b/password-store.sh
@@ -4,6 +4,10 @@ umask 077
PREFIX="$HOME/.password-store"
ID="$PREFIX/.gpg-id"
+GIT="$PREFIX/.git"
+
+export GIT_DIR="$GIT"
+export GIT_WORK_TREE="$PREFIX"
usage() {
cat <<_EOF
@@ -24,6 +28,10 @@ Usage:
Generate a new password of pass-length with optionally no symbols.
$0 --remove pass-name
Remove existing password.
+ $0 --push
+ If the password store is a git repository, push the latest changes.
+ $0 --pull
+ If the password store is a git repository, pull the latest changes.
$0 --help
Show this text.
_EOF
@@ -68,13 +76,18 @@ elif [[ $1 == "--insert" ]]; then
fi
mkdir -p -v "$PREFIX/$(dirname "$2")"
+ passfile="$PREFIX/$2.gpg"
if [[ $ml -eq 0 ]]; then
echo -n "Enter password for $2: "
- head -n 1 | gpg -e -r "$ID" > "$PREFIX/$2.gpg"
+ head -n 1 | gpg -e -r "$ID" > "$passfile"
else
echo "Enter contents of $2 and press Ctrl+D when finished:"
echo
- cat | gpg -e -r "$ID" > "$PREFIX/$2.gpg"
+ cat | gpg -e -r "$ID" > "$passfile"
+ fi
+ if [[ -d $GIT ]]; then
+ git add "$passfile"
+ git commit -m "Added given password for $2 to store."
fi
elif [[ $1 == "--generate" ]]; then
if [[ $# -lt 3 ]]; then
@@ -92,7 +105,12 @@ elif [[ $1 == "--generate" ]]; then
fi
mkdir -p -v "$PREFIX/$(dirname "$2")"
pass="$(pwgen -s $symbols $3 1)"
- echo $pass | gpg -e -r "$ID" > "$PREFIX/$2.gpg"
+ passfile="$PREFIX/$2.gpg"
+ echo $pass | gpg -e -r "$ID" > "$passfile"
+ if [[ -d $GIT ]]; then
+ git add "$passfile"
+ git commit -m "Added generated password for $2 to store."
+ fi
echo "The generated password to $2 is:"
echo "$pass"
elif [[ $1 == "--remove" ]]; then
@@ -106,6 +124,26 @@ elif [[ $1 == "--remove" ]]; then
exit 1
fi
rm -i -v "$passfile"
+ if [[ -d $GIT ]] && ! [[ -f "$passfile" ]]; then
+ git rm -f "$passfile"
+ git commit -m "Removed $2 from store."
+ fi
+elif [[ $1 == "--push" ]]; then
+ if [[ -d $GIT ]]; then
+ shift
+ exec git push $@
+ else
+ echo "Error: the password store is not a git repository."
+ exit 1
+ fi
+elif [[ $1 == "--pull" ]]; then
+ if [[ -d $GIT ]]; then
+ shift
+ exec git pull $@
+ else
+ echo "Error: the password store is not a git repository."
+ exit 1
+ fi
elif [[ $# -eq 1 ]]; then
passfile="$PREFIX/$1.gpg"
if ! [[ -f $passfile ]]; then
'logsubject'>Make add redirect to addRené 'Necoro' Neumann1-1/+1 2010-07-27Add datepicker to add/editRené 'Necoro' Neumann3-3/+23 2010-07-27Fix sizes of datepickerRené 'Necoro' Neumann1-3/+3 2010-07-27Add jQuery UI -- DatepickerRené 'Necoro' Neumann17-0/+1168 2010-07-27Add category manipulation supportRené 'Necoro' Neumann10-6/+85 2010-07-26Konstante KostenRené 'Necoro' Neumann1-1/+1 2010-07-26Added link to edit the constant stuffRené 'Necoro' Neumann1-1/+1 2010-07-26Added addition and modification of constant stuffRené 'Necoro' Neumann3-8/+106 2010-07-05Only show right nav arrow, if the following month is not in the futureRené 'Necoro' Neumann2-14/+20 2010-07-05Add month navigationRené 'Necoro' Neumann6-5/+35 2010-07-05Add iconRené 'Necoro' Neumann2-1/+2 2010-07-05change cursorRené 'Necoro' Neumann1-0/+5 2010-07-05Some restructuringRené 'Necoro' Neumann3-28/+45 2010-07-05Closed/Open imagesRené 'Necoro' Neumann4-0/+146 2010-05-25Move page templates into their own folderRené 'Necoro' Neumann5-5/+7 2010-05-25Added the ability to edit an expenseRené 'Necoro' Neumann3-9/+34 2010-05-12FixRené 'Necoro' Neumann1-2/+2 2010-05-12Show more detailsRené 'Necoro' Neumann4-19/+42 2010-05-12Create new form each timeRené 'Necoro' Neumann1-24/+26 2010-05-10Fix redirect in AddRené 'Necoro' Neumann1-1/+1 2010-05-10Added the 'add expense' stuffRené 'Necoro' Neumann4-3/+69