瀏覽代碼

refactor of root path parameter and related vars

master
HMSheets 3 年之前
父節點
當前提交
869c64bc44
共有 1 個文件被更改,包括 10 次插入12 次删除
  1. +10
    -12
      update-NebulaNodeCert

+ 10
- 12
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

Loading…
取消
儲存