mirror of
https://github.com/myvesta/vesta.git
synced 2024-12-21 11:31:21 -08:00
86 lines
2.0 KiB
Bash
Executable File
86 lines
2.0 KiB
Bash
Executable File
#!/bin/bash
|
|
# info: list letsencrypt key
|
|
# options: USER [FORMAT]
|
|
#
|
|
# The function for obtaining the letsencrypt key thumbprint
|
|
|
|
|
|
#----------------------------------------------------------#
|
|
# Variable&Function #
|
|
#----------------------------------------------------------#
|
|
|
|
# Argument definition
|
|
user=$1
|
|
format=${2-shell}
|
|
|
|
# Includes
|
|
source $VESTA/func/main.sh
|
|
|
|
# JSON list function
|
|
json_list() {
|
|
echo '{'
|
|
echo ' "'$user'": {
|
|
"EMAIL": "'$EMAIL'",
|
|
"EXPONENT": "'$EXPONENT'",
|
|
"MODULUS": "'$MODULUS'",
|
|
"THUMB": "'$THUMB'",
|
|
"KID": "'$KID'"
|
|
}'
|
|
echo '}'
|
|
}
|
|
|
|
# SHELL list function
|
|
shell_list() {
|
|
echo "USER: $user"
|
|
echo "EMAIL: $EMAIL"
|
|
echo "THUMB: $THUMB"
|
|
echo "EXPONENT: $EXPONENT"
|
|
echo "MODULUS: $MODULUS"
|
|
echo "KID: $KID"
|
|
}
|
|
|
|
# PLAIN list function
|
|
plain_list() {
|
|
echo -e "$user\t$EMAIL\t$EXPONENT\t$MODULUS\t$THUMB\t$KID"
|
|
}
|
|
|
|
# CSV list function
|
|
csv_list() {
|
|
echo "USER,EMAIL,EXPONENT,MODULUS,THUMB,KID"
|
|
echo "$user,$EMAIL,$EXPONENT,$MODULUS,$THUMB,$KID"
|
|
}
|
|
|
|
|
|
#----------------------------------------------------------#
|
|
# Verifications #
|
|
#----------------------------------------------------------#
|
|
|
|
check_args '1' "$#" 'USER [FORMAT]'
|
|
is_format_valid 'user'
|
|
is_object_valid 'user' 'USER' "$user"
|
|
if [ ! -e "$USER_DATA/ssl/le.conf" ]; then
|
|
check_result $E_NOTEXIST "LetsEncrypt user account doesn't exist"
|
|
fi
|
|
|
|
|
|
#----------------------------------------------------------#
|
|
# Action #
|
|
#----------------------------------------------------------#
|
|
|
|
source $USER_DATA/ssl/le.conf
|
|
|
|
# Listing data
|
|
case $format in
|
|
json) json_list ;;
|
|
plain) plain_list ;;
|
|
csv) csv_list ;;
|
|
shell) shell_list ;;
|
|
esac
|
|
|
|
|
|
#----------------------------------------------------------#
|
|
# Vesta #
|
|
#----------------------------------------------------------#
|
|
|
|
exit
|