mirror of
https://github.com/serghey-rodin/vesta.git
synced 2025-08-02 21:04:40 -07:00
Function to search avaiable SSL certificates that could be used as main cert
This commit is contained in:
parent
f4d3f7a85f
commit
a7b54d6000
1 changed files with 97 additions and 0 deletions
97
bin/v-search-ssl-certificates
Executable file
97
bin/v-search-ssl-certificates
Executable file
|
@ -0,0 +1,97 @@
|
|||
#!/bin/bash
|
||||
# info: search ssl certificates
|
||||
# options: [FORMAT]
|
||||
#
|
||||
# The function to obtain the list of available ssl certificates.
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Argument definition
|
||||
format=${1-shell}
|
||||
|
||||
# Includes
|
||||
source $VESTA/func/main.sh
|
||||
|
||||
# JSON list function
|
||||
json_list() {
|
||||
IFS=$'\n'
|
||||
i=1
|
||||
objects=$(echo "$search_cmd" |wc -l)
|
||||
echo "{"
|
||||
for str in $search_cmd; do
|
||||
eval $str
|
||||
echo -n ' "'$i'": {
|
||||
"USER": "'$USER'",
|
||||
"DOMAIN": "'$DOMAIN'"
|
||||
}'
|
||||
if [ "$i" -lt "$objects" ]; then
|
||||
echo ','
|
||||
else
|
||||
echo
|
||||
fi
|
||||
((i++))
|
||||
done
|
||||
echo '}'
|
||||
}
|
||||
|
||||
# SHELL list function
|
||||
shell_list() {
|
||||
IFS=$'\n'
|
||||
echo "USER DOMAIN"
|
||||
echo "---- ------"
|
||||
for str in $search_cmd; do
|
||||
eval $str
|
||||
echo "$USER $DOMAIN"
|
||||
done
|
||||
}
|
||||
|
||||
# PLAIN list function
|
||||
plain_list() {
|
||||
IFS=$'\n'
|
||||
for str in $search_cmd; do
|
||||
eval $str
|
||||
echo -e "$USER\t$DOMAIN"
|
||||
done
|
||||
}
|
||||
|
||||
# CSV list function
|
||||
csv_list() {
|
||||
IFS=$'\n'
|
||||
echo "USER,DOMAIN"
|
||||
for str in $search_cmd; do
|
||||
eval $str
|
||||
echo "$USER,$DOMAIN"
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Verifications #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Action #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
search_cmd=$(grep "SSL='yes'" $VESTA/data/users/*/web.conf |\
|
||||
cut -f 1 -d ' ' |\
|
||||
sed -e "s|$VESTA/data/users/|USER='|" -e "s|/web.conf:|' |")
|
||||
|
||||
# Listing data
|
||||
case $format in
|
||||
json) json_list ;;
|
||||
plain) plain_list ;;
|
||||
csv) csv_list ;;
|
||||
shell) shell_list |column -t ;;
|
||||
esac
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Vesta #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
exit
|
Loading…
Add table
Add a link
Reference in a new issue