diff --git a/update-NebulaNodeCert b/update-NebulaNodeCert index 2e96aef..58ceb3d 100644 --- a/update-NebulaNodeCert +++ b/update-NebulaNodeCert @@ -6,18 +6,18 @@ do key="$1" case $key in - -c|--certpath) - CERTPATH="$2" + -c|--nodecertpath) + NODECERTPATH="$2" shift # past argument shift # past value ;; - -p|--nebulacertbinpath) + -b|--nebulacertbinpath) NEBULACERTBINPATH="$2" shift # past argument shift # past value ;; - -o|--outpath) - OUTPATH="$2" + -r|--rootpath) + ROOTPATH="$2" shift # past argument shift # past value ;; @@ -36,12 +36,10 @@ fi DATETIME=$(date '+%Y%m%d-%H%M%S') -NODENAME=$(${NEBULACERTBINPATH} print -path ${CERTPATH} -json | jq -s .[].details.name | sed 's/["]//g') -#### TO-DO #### -# Make NODEIPS an Array like NODEGROUPS -NODEIPS=$(${NEBULACERTBINPATH} print -path ${CERTPATH} -json | jq -s --compact-output .[].details.ips | sed 's/[]["]//g') -NODEGROUPS=$(${NEBULACERTBINPATH} print -path ${CERTPATH} -json | jq -s --compact-output .[].details.groups | sed 's/[]["]//g') # | sed 's/,/ /g')) -CERTISCASTATUS=$(${NEBULACERTBINPATH} print -path ${CERTPATH} -json | jq -s --compact-output .[].details.isCa) +NODENAME=$(${ROOTPATH}/nebula-cert print -path ${NODECERTPATH} -json | jq -s .[].details.name | sed 's/["]//g') +NODEIPS=$(${ROOTPATH}/nebula-cert print -path ${NODECERTPATH} -json | jq -s --compact-output .[].details.ips | sed 's/[]["]//g') +NODEGROUPS=$(${ROOTPATH}/nebula-cert print -path ${NODECERTPATH} -json | jq -s --compact-output .[].details.groups | sed 's/[]["]//g') # | sed 's/,/ /g')) +CERTISCASTATUS=$(${ROOTPATH}/nebula-cert print -path ${NODECERTPATH} -json | jq -s --compact-output .[].details.isCa) # Create new file name variable NEWFILENAME="${NODENAME}_${DATETIME}" @@ -60,5 +58,5 @@ if [[ $CERTISCASTATUS == false ]]; then echo "DateTime: ${DATETIME}" echo "NEWFILENAME: ${NEWFILENAME}" echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" - ${NEBULACERTBINPATH} sign -groups ${NODEGROUPS[@]} -ip ${NODEIPS} -name ${NODENAME} -ca-crt ${OUTPATH}/ca.crt -ca-key ${OUTPATH}/ca.key -out-crt ${OUTPATH}/${NEWFILENAME}.crt -out-key ${OUTPATH}/${NEWFILENAME}.key + ${ROOTPATH}/nebula-cert sign -groups ${NODEGROUPS[@]} -ip ${NODEIPS} -name ${NODENAME} -ca-crt ${ROOTPATH}/ca.crt -ca-key ${ROOTPATH}/ca.key -out-crt ${ROOTPATH}/${NEWFILENAME}.crt -out-key ${ROOTPATH}/${NEWFILENAME}.key fi \ No newline at end of file