2020-12-26 15:08:17 -07:00
|
|
|
#!/bin/sh
|
|
|
|
|
2020-12-28 07:30:29 -07:00
|
|
|
set -e
|
|
|
|
|
2020-12-26 15:08:17 -07:00
|
|
|
rage_dir=~/.rage
|
2021-11-09 13:02:08 -07:00
|
|
|
|
2021-11-09 14:08:42 -07:00
|
|
|
. ${rage_dir}/config
|
2020-12-26 15:08:17 -07:00
|
|
|
|
|
|
|
cmd=$1
|
|
|
|
|
|
|
|
list() {
|
|
|
|
find $rage_dir -type f -name \*.age
|
|
|
|
}
|
|
|
|
|
|
|
|
if [ -z ${cmd} ]; then
|
|
|
|
list
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
|
|
|
case $cmd in
|
|
|
|
ls)
|
|
|
|
list
|
|
|
|
;;
|
2021-11-09 13:02:08 -07:00
|
|
|
re)
|
|
|
|
F=""
|
|
|
|
if [ -f $2 ]; then
|
|
|
|
F=$2
|
|
|
|
else
|
|
|
|
F=$(list | grep $2)
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Re-encrypting: '${F}'"
|
2021-11-09 14:08:42 -07:00
|
|
|
pass="$(age -i $identity -d "${F}")"
|
|
|
|
echo "$pass" | age -a -R "${recipients}" > "${F}"
|
2021-11-09 13:02:08 -07:00
|
|
|
;;
|
2021-01-16 08:42:58 -07:00
|
|
|
en)
|
|
|
|
printf 'Password: '
|
|
|
|
stty -echo
|
|
|
|
read pass
|
|
|
|
stty echo
|
|
|
|
echo ""
|
|
|
|
printf 'Location: '
|
|
|
|
read loc
|
|
|
|
echo ""
|
|
|
|
mkdir -p "$(dirname ~/.rage/${loc})"
|
2021-11-09 14:08:42 -07:00
|
|
|
echo "$pass" | age -a -R "${recipients}" > ~/.rage/${loc}.age
|
2021-01-16 08:42:58 -07:00
|
|
|
;;
|
2020-12-26 15:08:17 -07:00
|
|
|
de)
|
2021-02-01 11:47:34 -07:00
|
|
|
if [ -f $2 ]; then
|
2021-11-09 14:08:42 -07:00
|
|
|
age -i $identity -d $2
|
2021-02-01 11:47:34 -07:00
|
|
|
else
|
|
|
|
F=$(list | grep $2)
|
2021-11-09 14:08:42 -07:00
|
|
|
age -i $identity -d "${F}"
|
2021-02-01 11:47:34 -07:00
|
|
|
fi
|
2020-12-26 15:08:17 -07:00
|
|
|
;;
|
2021-05-05 11:05:01 -06:00
|
|
|
otp)
|
|
|
|
if [ -f $2 ]; then
|
2021-11-09 14:08:42 -07:00
|
|
|
age -i $identity -d $2 | oathtool -b --totp -
|
2021-05-05 11:05:01 -06:00
|
|
|
else
|
|
|
|
F=$(list | grep $2)
|
2021-11-09 14:08:42 -07:00
|
|
|
age -i $identity -d "${F}" | oathtool -b --totp -
|
2021-05-05 11:05:01 -06:00
|
|
|
fi
|
|
|
|
;;
|
2021-11-09 13:02:08 -07:00
|
|
|
push)
|
|
|
|
cd $rage_dir
|
|
|
|
git push
|
|
|
|
;;
|
|
|
|
sync)
|
|
|
|
cd $rage_dir
|
|
|
|
git pull
|
|
|
|
git push
|
|
|
|
;;
|
2020-12-26 15:08:17 -07:00
|
|
|
default)
|
|
|
|
list
|
|
|
|
esac
|