Merge pull request #1087 from gizmocuz/ft-index

Feature: Add Index based option for remove/qr commands
This commit is contained in:
Orazio 2020-07-23 10:44:15 +02:00 committed by GitHub
commit 4b239cfdc6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 34 additions and 13 deletions

View file

@ -56,17 +56,23 @@ if [[ -z "${CERTS_TO_REVOKE}" ]]; then
STATUS=$(echo "$line" | awk '{print $1}')
if [[ "${STATUS}" = "V" ]]; then
NAME=$(echo "$line" | sed -e 's:.*/CN=::')
CERTS[$i]=${NAME}
if [ "$i" != 0 ]; then
# Prevent printing "server" certificate
printf " %s\n" "$NAME"
CERTS[$i]=${NAME}
fi
let i=i+1
fi
done <${INDEX}
i=1
len=${#CERTS[@]}
while [ $i -le ${len} ]; do
printf "%0${#len}s) %s\r\n" ${i} ${CERTS[(($i))]}
((i++))
done
printf "\n"
echo -n "::: Please enter the Name of the client to be revoked from the list above: "
echo -n "::: Please enter the Index/Name of the client to be revoked from the list above: "
read -r NAME
if [[ -z "${NAME}" ]]; then
@ -74,6 +80,11 @@ if [[ -z "${CERTS_TO_REVOKE}" ]]; then
exit 1
fi
re='^[0-9]+$'
if [[ ${NAME} =~ $re ]] ; then
NAME=${CERTS[$(($NAME))]}
fi
for((x=1;x<=i;++x)); do
if [ "${CERTS[$x]}" = "${NAME}" ]; then
VALID=1