Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

62 строки
2.0 KiB

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