about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorNova li Gensokyo <novaburst@kalli.st>2021-12-05 14:46:17 +0000
committerNova li Gensokyo <novaburst@kalli.st>2021-12-05 14:46:17 +0000
commit5079a58c5b348aa26af06951d0b31cc25de9f843 (patch)
tree5ed4a34dbce3800f9f0d753f1d4ea7e8c56740c3
downloadayu-5079a58c5b348aa26af06951d0b31cc25de9f843.tar.gz
# * NOTE: Comments in this file WILL DEGRADE PERFORMANCE. *
-rw-r--r--COPYING10
-rw-r--r--README10
-rwxr-xr-xayu72
-rw-r--r--ayu.mdoc20
4 files changed, 112 insertions, 0 deletions
diff --git a/COPYING b/COPYING
new file mode 100644
index 0000000..c643d83
--- /dev/null
+++ b/COPYING
@@ -0,0 +1,10 @@
+Discordian Public License (DPL)
+
+All Rights Reversed Ⓚ 3187 Nova li Gensokyo <novaburst@kalli.st>
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
diff --git a/README b/README
new file mode 100644
index 0000000..d286406
--- /dev/null
+++ b/README
@@ -0,0 +1,10 @@
+ayu
+===
+
+Not-so standard unix password manager, written in (mostly) posix shell
+
+Dependencies
+------------
+
+- age
+- tree
diff --git a/ayu b/ayu
new file mode 100755
index 0000000..4848531
--- /dev/null
+++ b/ayu
@@ -0,0 +1,72 @@
+#!/bin/sh
+
+# Path to the program's directory
+ayu_dir="$HOME/.config/ayu"
+
+# Path to the age(1) keys
+ayu_key="$ayu_dir/age.key"
+ayu_pub="$ayu_dir/age.pub"
+
+# Path to the password store
+ayu_store="$HOME/.ayu"
+
+test -d $ayu_dir || mkdir -p $ayu_dir
+test -d $ayu_store || mkdir -p $ayu_store
+
+
+if ! [ -f $ayu_key ];then
+	printf "First generate your own age(1) key with age-keygen(1) and place it as $ayu_key. \n"
+	exit 1
+fi
+
+cd $ayu_store
+
+list() {
+	tree $ayu_store
+}
+
+edit() {
+	test -d "$1" && usage && exit
+
+	tmpfile="$(mktemp)"
+
+	# if the password already exists, decrypt and edit it instead
+	test -f "${1%%.age}".age && age --decrypt --identity=$age_pub "${1%%.age}".age > $tmpfile
+
+	vi "$tmpfile"
+
+	mkdir -p "$(dirname "$1")"
+	age --encrypt -R $ayu_pub -o $tmpfile.age $tmpfile
+
+	mv $tmpfile.age "${1%%.age}".age
+	rm $tmpfile
+}
+
+usage() {
+	printf "$0 [ edit | list | new | view ] \n"
+}
+
+view() {
+	if [ -f "${1%%.age}".age ];then
+		age --decrypt --identity=$ayu_key .age
+	elif [ -d "${1:-.}" ];then
+		tree "${1:-.}"
+	else
+		usage
+		exit
+	fi
+}
+case $1 in
+	list)
+		list
+		;;
+	edit | new)
+		edit $2
+		;;
+	view)
+		view $2
+		;;
+	*)
+		list
+		;;
+esac
diff --git a/ayu.mdoc b/ayu.mdoc
new file mode 100644
index 0000000..ed2107e
--- /dev/null
+++ b/ayu.mdoc
@@ -0,0 +1,20 @@
+.Dd 2021-12-05
+.Dt ayu 1
+.Os
+.Sh NAME
+.Nm ayu
+.Nd Not-so standard unix password manager
+.Sh SYNOPSIS
+.Nm ayu
+.Op edit
+.Ar entry
+.Pp
+.Nm ayu
+.Op view
+.Ar entry
+.Pp
+.Nm ayu
+.Op list
+.Sh AUTHORS
+.An Nova li Gensokyo
+.Mt novaburst@kalli.st