diff options
| -rw-r--r-- | .gitignore | 1 | ||||
| -rw-r--r-- | README | 6 | ||||
| -rwxr-xr-x | angou | 11 | ||||
| -rwxr-xr-x | contrib/random | 22 |
4 files changed, 38 insertions, 2 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b25c15b --- /dev/null +++ b/.gitignore | |||
| @@ -0,0 +1 @@ | |||
| *~ | |||
| @@ -12,6 +12,10 @@ Dependencies | |||
| 12 | - can possibly be replaced with ls if you add ANGOU_LIST in your ~/.profile | 12 | - can possibly be replaced with ls if you add ANGOU_LIST in your ~/.profile |
| 13 | - xsel (for copying password to clipboard, but can be changed to a different | 13 | - xsel (for copying password to clipboard, but can be changed to a different |
| 14 | command with the ANGOU_CLIPBOARD command that accepts stdin) | 14 | command with the ANGOU_CLIPBOARD command that accepts stdin) |
| 15 | - a password generator | ||
| 16 | - script uses contrib/random from this repo by default and expects it in your | ||
| 17 | path | ||
| 18 | - can change by setting ANGOU_GEN_USER and ANGOU_GEN_PASS in your ~/.profile | ||
| 15 | 19 | ||
| 16 | Configuration | 20 | Configuration |
| 17 | ------------- | 21 | ------------- |
| @@ -42,4 +46,4 @@ Set the ANGOU_DIR environment variable to your password store directory. | |||
| 42 | Auto-complete | 46 | Auto-complete |
| 43 | ------------- | 47 | ------------- |
| 44 | If you use ksh, all you'd have to do is source contrib/autocomplete.ksh in your | 48 | If you use ksh, all you'd have to do is source contrib/autocomplete.ksh in your |
| 45 | kshrc. \ No newline at end of file | 49 | kshrc. |
| @@ -6,6 +6,9 @@ ANGOU_DIR=${ANGOU_DIR:-"$HOME/.angou/"} | |||
| 6 | ANGOU_CLIPBOARD=${ANGOU_CLIPBOARD:-"xsel -i"} | 6 | ANGOU_CLIPBOARD=${ANGOU_CLIPBOARD:-"xsel -i"} |
| 7 | # sets command to use when listing directory structure | 7 | # sets command to use when listing directory structure |
| 8 | ANGOU_LIST=${ANGOU_LIST:-"tree"} | 8 | ANGOU_LIST=${ANGOU_LIST:-"tree"} |
| 9 | # custom command for generating passwords/users | ||
| 10 | ANGOU_GEN_PASS=${ANGOU_GEN_PASS:-"random pass"} | ||
| 11 | ANGOU_GEN_USER=${ANGOU_GEN_USER:-"random user"} | ||
| 9 | 12 | ||
| 10 | mkdir -p "$ANGOU_DIR" | 13 | mkdir -p "$ANGOU_DIR" |
| 11 | cd "$ANGOU_DIR" || exit | 14 | cd "$ANGOU_DIR" || exit |
| @@ -35,6 +38,11 @@ edit() { | |||
| 35 | 38 | ||
| 36 | tmpfile="$(mktemp)" | 39 | tmpfile="$(mktemp)" |
| 37 | 40 | ||
| 41 | if [ "$2" = "generate" ]; then | ||
| 42 | $ANGOU_GEN_PASS >"$tmpfile" | ||
| 43 | echo "Username: $($ANGOU_GEN_USER)" >>"$tmpfile" | ||
| 44 | fi | ||
| 45 | |||
| 38 | # edit a copy of a password if it already exists | 46 | # edit a copy of a password if it already exists |
| 39 | [ -f "$1" ] && $ANGOU_DECRYPT "$1" > "$tmpfile" | 47 | [ -f "$1" ] && $ANGOU_DECRYPT "$1" > "$tmpfile" |
| 40 | 48 | ||
| @@ -46,7 +54,7 @@ edit() { | |||
| 46 | 54 | ||
| 47 | # print usage | 55 | # print usage |
| 48 | usage() { | 56 | usage() { |
| 49 | printf "Usage: %s [help|copy|edit|view [file or directory]]\n" "$0" | 57 | printf "Usage: %s [help|copy|edit|generate|view [file or directory]]\n" "$0" |
| 50 | printf "\tThe edit and copy command expects a file as an argument,\n" | 58 | printf "\tThe edit and copy command expects a file as an argument,\n" |
| 51 | printf "\twhile the view command expects a directory as an argument.\n" | 59 | printf "\twhile the view command expects a directory as an argument.\n" |
| 52 | printf "\tThe arguments for view and edit are relative to\n" | 60 | printf "\tThe arguments for view and edit are relative to\n" |
| @@ -61,6 +69,7 @@ case "$option" in | |||
| 61 | help) usage ;; | 69 | help) usage ;; |
| 62 | copy) copy "$2" ;; | 70 | copy) copy "$2" ;; |
| 63 | edit) edit "$2" ;; | 71 | edit) edit "$2" ;; |
| 72 | generate) edit "$2" generate ;; | ||
| 64 | view) view "$2" ;; | 73 | view) view "$2" ;; |
| 65 | *) view "$1" ;; | 74 | *) view "$1" ;; |
| 66 | esac | 75 | esac |
diff --git a/contrib/random b/contrib/random new file mode 100755 index 0000000..10ddda7 --- /dev/null +++ b/contrib/random | |||
| @@ -0,0 +1,22 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | # Simple random string generator for passwords and usernames | ||
| 3 | # $LEN initial declaration commented out for runtime LEN config | ||
| 4 | |||
| 5 | LC_ALL=C | ||
| 6 | #LEN=${LEN:-24} | ||
| 7 | ALPHA="A-Za-z" | ||
| 8 | NUM="0-9" | ||
| 9 | SPECIAL='!"#$%&'\''()*+,-./:;<=>?@[\]^_`{|}~' | ||
| 10 | |||
| 11 | random() { | ||
| 12 | </dev/urandom tr -dc "${ALPHA}${NUM}${SPECIAL}" | /bin/dd bs=1 count=${LEN:-32} 2>/dev/null ; echo | ||
| 13 | } | ||
| 14 | |||
| 15 | case $1 in | ||
| 16 | pass) | ||
| 17 | random ;; | ||
| 18 | user) | ||
| 19 | LEN=${LEN:-12} SPECIAL='' random ;; | ||
| 20 | *) | ||
| 21 | printf "Usage: $0 pass|user\nSet LEN environment variable for length" ;; | ||
| 22 | esac | ||
