Simplify bin/pass-otpuri
This commit is contained in:
parent
ed8980474e
commit
2893864401
|
@ -1,31 +1,11 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
# Generates an OTP-auth url (written for pass-otp)
|
# Interactively generates an OTP-auth url (written for pass-otp)
|
||||||
#
|
#
|
||||||
# Example: passotpuri LABEL SECRET [QUERYSTRING]
|
# Example: passotpuri LABEL SECRET [QUERYSTRING]
|
||||||
|
|
||||||
type=totp
|
read -p "Enter the label or issuer:" label
|
||||||
issuer=
|
read -p "Enter its OTP secret:" secret
|
||||||
while getopts tih opt; do
|
read -p "Enter type (leave blank for totp):" type
|
||||||
case $opt in
|
|
||||||
t) type="$OPTARG" ;;
|
|
||||||
i) issuer="$OPTARG" ;;
|
|
||||||
h) cat <<EOL
|
|
||||||
Usage: $0 [-iuldypLSU] [topic1] [topic2] [...]
|
|
||||||
|
|
||||||
-t Set type (defaults to totp)
|
echo "otpauth://${type:-totp}/$label?secret=$secret&issuer=${issuer:-$label}"
|
||||||
-i Issuer
|
|
||||||
EOL
|
|
||||||
exit
|
|
||||||
;;
|
|
||||||
*) >&2 echo "Aborted."
|
|
||||||
exit 1 ;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
shift $((OPTIND-1))
|
|
||||||
|
|
||||||
label="$1"
|
|
||||||
secret="$2"
|
|
||||||
args="${3:+&$3}"
|
|
||||||
|
|
||||||
echo "otpauth://$type/$label?secret=$secret&issuer=${issuer:-$label}$args"
|
|
||||||
|
|
Loading…
Reference in a new issue