From a18f9be500dfa1afdfa06ccfa0fa35b28ad18457 Mon Sep 17 00:00:00 2001 From: ChrisLiu Date: Mon, 26 Sep 2022 11:45:51 +0800 Subject: [PATCH] update gencerts.sh Signed-off-by: ChrisLiu --- hack/gencerts.sh | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/hack/gencerts.sh b/hack/gencerts.sh index 868b528e..57ffdc6c 100644 --- a/hack/gencerts.sh +++ b/hack/gencerts.sh @@ -17,8 +17,7 @@ # Generates a CA certificate, a server key, and a server certificate signed by the CA. set -e -SCRIPT=`basename ${BASH_SOURCE[0]}` - +SCRIPT=$(basename "${BASH_SOURCE[0]}") function usage { cat<< EOF Usage: $SCRIPT @@ -117,10 +116,10 @@ if [[ "$IN_POD" == "true" ]]; then TOKEN=$(cat /var/run/secrets/kubernetes.io/serviceaccount/token) # Base64 encode secrets and then remove the trailing newline to avoid issues in the curl command - ca_cert=$(cat ${TMP_DIR}/ca-cert.pem | base64 | tr -d '\n') - ca_key=$(cat ${TMP_DIR}/ca-key.pem | base64 | tr -d '\n') - server_cert=$(cat ${TMP_DIR}/server-cert.pem | base64 | tr -d '\n') - server_key=$(cat ${TMP_DIR}/server-key.pem | base64 | tr -d '\n') + ca_cert=$(cmd file | ${TMP_DIR}/ca-cert.pem | base64 | tr -d '\n') + ca_key=$(cmd file | ${TMP_DIR}/ca-key.pem | base64 | tr -d '\n') + server_cert=$(cmd file | ${TMP_DIR}/server-cert.pem | base64 | tr -d '\n') + server_key=$(cmd file | ${TMP_DIR}/server-key.pem | base64 | tr -d '\n') # Create the secret resource echo "Creating a secret for the certificate and keys" @@ -166,5 +165,5 @@ else fi # Clean up after we're done. -printf "\nDeleting ${TMP_DIR}.\n" +printf "\nDeleting %s.\n" "${TMP_DIR}" rm -rf ${TMP_DIR}