Changeset 23 in code
Legend:
- Unmodified
- Added
- Removed
-
trunk/Makefile
r18 r23 1 1 PREFIX=/usr/local 2 2 3 install: install-bin install-examples install-man 4 uninstall: uninstall-bin uninstall-examples uninstall-man 3 fmt: 4 shfmt --posix --write kanako 5 5 6 install -bin:6 install: 7 7 install -Dm0755 kanako ${DESTDIR}${PREFIX}/bin/kanako 8 install-examples:9 8 install -Dm0600 kanako.conf.example ${DESTDIR}${PREFIX}/share/examples/kanako/kanako.conf 10 install-man:11 9 install -Dm0600 kanako.mdoc ${DESTDIR}${PREFIX}/share/man/man1/kanako.1 12 10 install -Dm0600 kanako.conf.mdoc ${DESTDIR}${PREFIX}/share/man/man5/kanako.conf.5 13 uninstall -bin:11 uninstall: 14 12 rm -f ${PREFIX}/bin/kanako 15 uninstall-examples: 16 rm -f ${PREFIX}/share/examples/kanako/kanako.conf ${PREFIX}/share/exmaples/kanako/kanakomenu.conf 17 uninstall-man: 13 rm -f ${PREFIX}/share/examples/kanako/kanako.conf 18 14 rm -f ${PREFIX}/share/man/man1/kanako.1 ${PREFIX}/share/man/man5/kanako.conf.5 -
trunk/kanako
r22 r23 7 7 8 8 if test -d "${kanako_store_dir}"; then 9 9 cd "${kanako_store_dir}" 10 10 else 11 12 13 11 printf "Password store not found!\n" 12 printf "Create it with mkdir -p %s\n" "$kanako_store_dir" 13 exit 1 14 14 fi 15 15 16 16 if test -f "${kanako_conf_dir}/kanako.conf"; then 17 . "${kanako_conf_dir}/kanako.conf"; 17 . "${kanako_conf_dir}/kanako.conf" 18 18 else 19 20 21 22 19 printf "Configuration file has not been found!\n" 20 printf "Copy kanako.conf from the examples directory,\n" 21 printf "and edit accordingly.\n" 22 exit 1 23 23 fi 24 24 25 25 copy() { 26 26 view "$1" | "${kanako_clip_cmd}" 27 27 } 28 28 edit() { 29 # FIXME: Need a way to find out if file exists 30 ${kanako_encrypt_cmd} ${kanako_decrypt_args} ${1%%.enc}.enc > ${1%%.enc} 31 "${EDITOR:-${EDITOR:-vi}}" "${1%%.enc}" 32 ${kanako_encrypt_cmd} ${kanako_encrypt_args} ${1%%.enc} > ${1%%.enc}.enc 33 rm "${1%%.enc}" 29 if [ -f ${1%%.enc}.enc ]; then 30 ${kanako_encrypt_cmd} ${kanako_decrypt_args} ${1%%.enc}.enc >${1%%.enc} 31 "${EDITOR:-${EDITOR:-vi}}" "${1%%.enc}" 32 ${kanako_encrypt_cmd} ${kanako_encrypt_args} ${1%%.enc} >${1%%.enc}.enc 33 rm "${1%%.enc}" 34 else 35 printf "%s does not exist, maybe there was a typo on your end?\n" "${1%%.enc}.enc" 36 fi 34 37 } 35 38 gen() { 36 39 printf "%s\n" $(strings </dev/urandom | dd bs=1 count="${1:-30}" 2>/dev/null | tr -d ' \t\n\r') 37 40 } 38 41 list() { 39 40 $(which tree) "${kanako_store_dir}/" | sed 's/\.enc//g'41 42 $(which tree) "${1:-.}" | sed 's/\.enc//g'43 42 if [ -z "$1" ]; then 43 $(which tree) "${kanako_store_dir}/" | sed 's/\.enc//g' 44 else 45 $(which tree) "${1:-.}" | sed 's/\.enc//g' 46 fi 44 47 } 45 48 new() { 46 49 test -d "$1" && usage 47 50 48 49 51 tmpfile="$(mktemp)" 52 "${EDITOR:-${EDITOR:-vi}}" "${tmpfile}" 50 53 51 52 ${kanako_encrypt_cmd} ${kanako_encrypt_args} ${tmpfile} >${1%%.enc}.enc53 54 mkdir -p "$(dirname "$1")" 55 ${kanako_encrypt_cmd} ${kanako_encrypt_args} ${tmpfile} >${1%%.enc}.enc 56 rm ${tmpfile} 54 57 } 55 58 delete_directory() { 56 59 rm -r -I "$1" 57 60 } 58 61 delete_file() { 59 62 rm -i "${1}${2}".enc 60 63 } 61 64 usage() { 62 63 64 65 65 printf "Usage: %s [-c|-e|-g|-l|-n|-R|-r|-v [file or directory]]\n" "$0" 66 printf "The arguments for all switches are relative to \${kanako_store_dir}\n" 67 printf "which is located at %s\n" "${kanako_store_dir}" 68 exit 1 66 69 } 67 70 view() { 68 69 ${kanako_encrypt_cmd} ${kanako_decrypt_args} "${1%%.enc}".enc70 71 list "${1:-.}"72 73 usage74 fi 71 if [ -f "${1%%.enc}".enc ]; then 72 ${kanako_encrypt_cmd} ${kanako_decrypt_args} "${1%%.enc}".enc 73 elif [ -d "${1:-.}" ]; then 74 list "${1:-.}" 75 else 76 usage 77 fi 75 78 } 76 79 77 80 case $1 in 78 79 80 81 -l) list $2;;82 83 84 85 86 81 -c) copy $2 ;; 82 -e) edit $2 ;; 83 -g) gen $2 ;; 84 -l) list $2 ;; 85 -n) new $2 ;; 86 -R) delete_directory $2 ;; 87 -r) delete_file $2 ;; 88 -v) view $2 ;; 89 *) usage ;; 87 90 esac -
trunk/kanako.mdoc
r22 r23 7 7 .Sh SYNOPSIS 8 8 .Nm 9 .Fl c Ar args 10 .Fl e Ar args 11 .Fl g Ar args 12 .Fl l 13 .Fl n Ar args 14 .Fl r Ar args 15 .Fl R Ar args 16 .Fl v Ar args 9 .Op Fl ceglnrRv 10 .Op Ar args 17 11 .Sh DESCRIPTION 18 12 It is a clean rewrite of
Note:
See TracChangeset
for help on using the changeset viewer.