Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

update-NebulaNodeCert 1.9 KiB

před 3 roky
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #!/bin/bash
  2. POSITIONAL=()
  3. while [[ $# -gt 0 ]]
  4. do
  5. key="$1"
  6. case $key in
  7. -c|--nodecertname)
  8. NODECERTNAME="$2"
  9. shift # past argument
  10. shift # past value
  11. ;;
  12. -r|--rootpath)
  13. ROOTPATH="$2"
  14. shift # past argument
  15. shift # past value
  16. ;;
  17. *) # unknown option
  18. POSITIONAL+=("$1") # save it in an array for later
  19. shift # past argument
  20. ;;
  21. esac
  22. done
  23. set -- "${POSITIONAL[@]}" # restore positional parameters
  24. if [[ -n $1 ]]; then
  25. echo "Invalid Parameter(s) Entered: $1"
  26. exit
  27. fi
  28. DATETIME=$(date '+%Y%m%d-%H%M%S')
  29. NODENAME=$(${ROOTPATH}/nebula-cert print -path ${ROOTPATH}/${NODECERTNAME} -json | jq -s .[].details.name | sed 's/["]//g')
  30. NODEIPS=$(${ROOTPATH}/nebula-cert print -path ${ROOTPATH}/${NODECERTNAME} -json | jq -s --compact-output .[].details.ips | sed 's/[]["]//g')
  31. NODEGROUPS=$(${ROOTPATH}/nebula-cert print -path ${ROOTPATH}/${NODECERTNAME} -json | jq -s --compact-output .[].details.groups | sed 's/[]["]//g') # | sed 's/,/ /g'))
  32. CERTISCASTATUS=$(${ROOTPATH}/nebula-cert print -path ${ROOTPATH}/${NODECERTNAME} -json | jq -s --compact-output .[].details.isCa)
  33. # Create new file name variable
  34. NEWFILENAME="${NODENAME}_${DATETIME}"
  35. if [[ $CERTISCASTATUS == true ]]; then
  36. echo "Certificate is the root CA Certificate. Try again with a node certificate."
  37. exit
  38. fi
  39. if [[ $CERTISCASTATUS == false ]]; then
  40. echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
  41. echo "Node Name: ${NODENAME}"
  42. echo "Node IPs: ${NODEIPS}"
  43. echo "Node Groups: ${NODEGROUPS[@]}"
  44. echo "Certificate isCa Status: ${CERTISCASTATUS}"
  45. echo "DateTime: ${DATETIME}"
  46. echo "NEWFILENAME: ${NEWFILENAME}"
  47. echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
  48. ${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
  49. fi