25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.

56 satır
1.6 KiB

  1. #!/bin/bash
  2. POSITIONAL=()
  3. while [[ $# -gt 0 ]]
  4. do
  5. key="$1"
  6. case $key in
  7. -c|--certpath)
  8. CERTPATH="$2"
  9. shift # past argument
  10. shift # past value
  11. ;;
  12. -p|--nebulacertbinpath)
  13. NEBULACERTBINPATH="$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=$(${NEBULACERTBINPATH} print -path ${CERTPATH} -json | jq -s .[].details.name | sed 's/["]//g')
  30. #### TO-DO ####
  31. # Make NODEIPS an Array like NODEGROUPS
  32. NODEIPS=$(${NEBULACERTBINPATH} print -path ${CERTPATH} -json | jq -s --compact-output .[].details.ips | sed 's/[]["]//g')
  33. NODEGROUPS=($(${NEBULACERTBINPATH} print -path ${CERTPATH} -json | jq -s --compact-output .[].details.groups | sed 's/[]["]//g' | sed 's/,/ /g'))
  34. CERTISCASTATUS=$(${NEBULACERTBINPATH} print -path ${CERTPATH} -json | jq -s --compact-output .[].details.isCa)
  35. # Create new file name variable
  36. NEWFILENAME="${NODENAME}_${DATETIME}"
  37. if [[ $CERTISCASTATUS == true ]]; then
  38. echo "Certificate is the root CA Certificate. Try again with a node certificate."
  39. exit
  40. fi
  41. if [[ $CERTISCASTATUS == false ]]; then
  42. echo "Node Name: ${NODENAME}"
  43. echo "Node IPs: ${NODEIPS}"
  44. echo "Node Groups: ${NODEGROUPS[@]}"
  45. echo "Certificate isCa Status: ${CERTISCASTATUS}"
  46. echo "DateTime: ${DATETIME}"
  47. echo "NEWFILENAME: ${NEWFILENAME}"
  48. fi