diff options
| -rw-r--r-- | LICENSE | 13 | ||||
| -rw-r--r-- | README | 21 | ||||
| -rwxr-xr-x | angou | 59 |
3 files changed, 93 insertions, 0 deletions
| @@ -0,0 +1,13 @@ | |||
| 1 | Copyright 2021 Shokara Kou | ||
| 2 | |||
| 3 | Permission to use, copy, modify, and distribute this software for any purpose | ||
| 4 | with or without fee is hereby granted, provided that the above copyright notice | ||
| 5 | and this permission notice appear in all copies. | ||
| 6 | |||
| 7 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH | ||
| 8 | REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND | ||
| 9 | FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, | ||
| 10 | INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM | ||
| 11 | LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR | ||
| 12 | OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR | ||
| 13 | PERFORMANCE OF THIS SOFTWARE. | ||
| @@ -0,0 +1,21 @@ | |||
| 1 | angou (暗号) | ||
| 2 | ============ | ||
| 3 | A simple password manager written in POSIX shell. | ||
| 4 | |||
| 5 | Dependencies | ||
| 6 | ------------ | ||
| 7 | - POSIX-compliant environment | ||
| 8 | - gnupg | ||
| 9 | - tree (for listing all your passwords and their directories) | ||
| 10 | - a simple version is available in https://github.com/pyr/tree | ||
| 11 | and in OpenBSD's ports | ||
| 12 | - xsel (for copying password to clipboard, but can be changed to a different | ||
| 13 | command with the ANGOU_CLIPBOARD command that accepts stdin) | ||
| 14 | |||
| 15 | Why should I use this over password-store? | ||
| 16 | ------------------------------------------ | ||
| 17 | Don't. For a serious answer, it's because this doesn't depend on bash. | ||
| 18 | |||
| 19 | Migrating from password-store | ||
| 20 | ----------------------------- | ||
| 21 | Set the ANGOU_DIR environment variable to your password store directory. | ||
| @@ -0,0 +1,59 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | |||
| 3 | # sets the directory with all your passwords | ||
| 4 | ANGOU_DIR=${ANGOU_DIR:-"$HOME/.angou/"} | ||
| 5 | # sets the command to copy into your clipboard (must accept stdin) | ||
| 6 | ANGOU_CLIPBOARD=${ANGOU_CLIPBOARD:-"xsel -ib"} | ||
| 7 | |||
| 8 | mkdir -p "$ANGOU_DIR" | ||
| 9 | cd "$ANGOU_DIR" || exit | ||
| 10 | |||
| 11 | # print the directory structure of ANGOU_DIR | ||
| 12 | list() { | ||
| 13 | tree "$@" | ||
| 14 | } | ||
| 15 | |||
| 16 | # decrypt and print a password from ANGOU_DIR | ||
| 17 | view() { | ||
| 18 | gpg -qd "${1%%.gpg}".gpg | ||
| 19 | } | ||
| 20 | |||
| 21 | # copy the first line from view to clipboard | ||
| 22 | copy() { | ||
| 23 | view "$1" | "$ANGOU_CLIPBOARD" | ||
| 24 | } | ||
| 25 | |||
| 26 | # create new or existing password in ANGOU_DIR | ||
| 27 | edit() { | ||
| 28 | tmpfile="$(mktemp)" | ||
| 29 | |||
| 30 | # edit a copy of a password if it already exists | ||
| 31 | test [ -f "${1**.gpg}".gpg] && cp "$1" "$tmpfile" | ||
| 32 | |||
| 33 | "${VISUAL:-${EDITOR:-ed}}" "$tmpfile" | ||
| 34 | |||
| 35 | mkdir -p "$(dirname "$1")" | ||
| 36 | mv "$tmpfile" "${1%%.gpg}".gpg | ||
| 37 | } | ||
| 38 | |||
| 39 | # print usage | ||
| 40 | usage() { | ||
| 41 | printf "Usage: %s [help|view|copy|edit|list [file or directory]]\n" "$1" | ||
| 42 | printf "\tThe view and edit commands expect a file as an argument,\n" | ||
| 43 | printf "\twhile the list commands expect a directory as an argument.\n" | ||
| 44 | printf "\tThe arguments for view, edit, and list are relative to\n" | ||
| 45 | printf "\t\$ANGOU_DIR which is currently set to %s\n\n" "$ANGOU_DIR" | ||
| 46 | |||
| 47 | printf "\tThe list command is the default option if only a file or\n" | ||
| 48 | printf "\tdirectory is passed as an argument\n" | ||
| 49 | } | ||
| 50 | |||
| 51 | option="$1" | ||
| 52 | case "$option" in | ||
| 53 | help) usage "$0" ;; | ||
| 54 | view) view "$2" ;; | ||
| 55 | copy) copy "$2" ;; | ||
| 56 | edit) edit "$2" ;; | ||
| 57 | list) shift && list "$@" ;; # fallthrough isn't in posix sh? | ||
| 58 | *) list "$@" ;; | ||
| 59 | esac | ||
