summaryrefslogtreecommitdiff
path: root/src/password-store.sh
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-xsrc/password-store.sh44
1 files changed, 23 insertions, 21 deletions
diff --git a/src/password-store.sh b/src/password-store.sh
index f0b965a..5075bb8 100755
--- a/src/password-store.sh
+++ b/src/password-store.sh
@@ -43,9 +43,10 @@ Usage:
before overwriting existing password unless forced.
$program edit pass-name
Insert a new password or edit an existing password using ${EDITOR:-vi}.
- $program generate [--no-symbols,-n] [--clip,-c] pass-name pass-length
+ $program generate [--no-symbols,-n] [--clip,-c] [--force,-f] pass-name pass-length
Generate a new password of pass-length with optionally no symbols.
Optionally put it on the clipboard and clear board after 45 seconds.
+ Prompt before overwriting existing password unless forced.
$program rm [--recursive,-r] [--force,-f] pass-name
Remove existing password or directory, optionally forcefully.
$program git git-command-args...
@@ -63,7 +64,16 @@ is_command() {
*) return 1 ;;
esac
}
-
+git_add_file() {
+ [[ -d $GIT_DIR ]] || return
+ git add "$1" || return
+ [[ -n $(git status --porcelain "$1") ]] || return
+ git commit -m "$2"
+}
+yesno() {
+ read -p "$1 [y/N] " response
+ [[ $response == "y" || $response == "Y" ]] || exit 1
+}
#
# BEGIN Platform definable
#
@@ -98,12 +108,10 @@ tmpdir() {
if [[ -d /dev/shm && -w /dev/shm && -x /dev/shm ]]; then
tmp_dir="$(TMPDIR=/dev/shm mktemp -t "$template" -d)"
else
- prompt=$(echo "Your system does not have /dev/shm, which means that it may"
+ yesno "$(echo "Your system does not have /dev/shm, which means that it may"
echo "be difficult to entirely erase the temporary non-encrypted"
echo "password file after editing. Are you sure you would like to"
- echo -n "continue? [y/N] ")
- read -p "$prompt" yesno
- [[ $yesno == "y" || $yesno == "Y" ]] || exit 1
+ echo -n "continue?")"
tmp_dir="$(mktemp -t "$template" -d)"
fi
@@ -116,13 +124,6 @@ GETOPT="getopt"
# END Platform definable
#
-function git_add_file() {
- [[ -d $GIT_DIR ]] || return
- git add "$1" || return
- [[ -n $(git status --porcelain "$1") ]] || return
- git commit -m "$2"
-}
-
program="$(basename "$0")"
command="$1"
if is_command "$command"; then
@@ -225,11 +226,7 @@ case "$command" in
path="$1"
passfile="$PREFIX/$path.gpg"
- if [[ $force -eq 0 && -e $passfile ]]; then
- prompt="An entry already exists for $path. Overwrite it [y/N]? "
- read -p "$prompt" yesno
- [[ $yesno == "y" || $yesno == "Y" ]] || exit 1
- fi
+ [[ $force -eq 0 && -e $passfile ]] && yesno "An entry already exists for $path. Overwrite it?"
mkdir -p -v "$PREFIX/$(dirname "$path")"
@@ -286,19 +283,21 @@ case "$command" in
;;
generate)
clip=0
+ force=0
symbols="-y"
- opts="$($GETOPT -o nc -l no-symbols,clip -n "$program" -- "$@")"
+ opts="$($GETOPT -o ncf -l no-symbols,clip,force -n "$program" -- "$@")"
err=$?
eval set -- "$opts"
while true; do case $1 in
-n|--no-symbols) symbols=""; shift ;;
-c|--clip) clip=1; shift ;;
+ -f|--force) force=1; shift ;;
--) shift; break ;;
esac done
if [[ $err -ne 0 || $# -ne 2 ]]; then
- echo "Usage: $program $command [--no-symbols,-n] [--clip,-c] pass-name pass-length"
+ echo "Usage: $program $command [--no-symbols,-n] [--clip,-c] [--force,-f] pass-name pass-length"
exit 1
fi
path="$1"
@@ -308,8 +307,11 @@ case "$command" in
exit 1
fi
mkdir -p -v "$PREFIX/$(dirname "$path")"
- pass="$(pwgen -s $symbols $length 1)"
passfile="$PREFIX/$path.gpg"
+
+ [[ $force -eq 0 && -e $passfile ]] && yesno "An entry already exists for $path. Overwrite it?"
+
+ pass="$(pwgen -s $symbols $length 1)"
$GPG -e -r "$ID" -o "$passfile" $GPG_OPTS <<<"$pass"
git_add_file "$passfile" "Added generated password for $path to store."
/feed2imap-go.git/commit/main.go?h=v1.2.0&id=8558205de4c9bd46aa7b4a61db7bdd1fa2f91240&follow=1'>Reorganize flag handlingRené 'Necoro' Neumann1-17/+30 2020-05-11Use stable version of gofeedRené 'Necoro' Neumann2-3/+3 2020-05-10Prepare release 0.3.0v0.3.0René 'Necoro' Neumann3-5/+6 2020-05-10Fixed linebreaks for Enclosures in text templateRené 'Necoro' Neumann1-5/+5 2020-05-10Upgrade html2textRené 'Necoro' Neumann2-5/+3 2020-05-10Switch to our own html2text fork for the time beingRené 'Necoro' Neumann3-5/+5 2020-05-10Text part in emailsRené 'Necoro' Neumann7-33/+115 2020-05-10Allow options on group level.René 'Necoro' Neumann3-5/+11 2020-05-10Renamed feed template to html templateRené 'Necoro' Neumann2-2/+2 2020-05-10Release v0.2.0v0.2.0René 'Necoro' Neumann2-2/+6 2020-05-10Fix building cacheRené 'Necoro' Neumann1-1/+3 2020-05-10Update READMERené 'Necoro' Neumann1-5/+44 2020-05-10Ignore 'dist' folder and build productsRené 'Necoro' Neumann1-0/+2 2020-05-08Print item hashes in debug modeRené 'Necoro' Neumann1-1/+7 2020-05-07Improve html renderingRené 'Necoro' Neumann2-53/+32 2020-05-07Do not assume items to be new when their published date is newer than the las...René 'Necoro' Neumann2-7/+1 2020-05-07Updating some depsRené 'Necoro' Neumann2-2/+7 2020-05-07Better detection if a text starts with html or notRené 'Necoro' Neumann2-4/+13 2020-05-07go fmtRené 'Necoro' Neumann1-3/+2 2020-05-07Add header X-Feed2Imap-GUIDRené 'Necoro' Neumann3-1/+7 2020-05-07update changelogRené 'Necoro' Neumann1-0/+1 2020-05-07FixRené 'Necoro' Neumann1-1/+1 2020-05-07Unified publishedDate and updatedDate into one (just as the old feed2imap...)René 'Necoro' Neumann5-21/+32 2020-05-06Print version during startupRené 'Necoro' Neumann1-1/+1 2020-05-06Improve templateRené 'Necoro' Neumann3-20/+28 2020-05-05Fix pipelineRené 'Necoro' Neumann1-2/+5 2020-05-05Make changelog a part of the release pipeline (untested)René 'Necoro' Neumann2-0/+12