Untitled


SUBMITTED BY: Guest

DATE: Sept. 3, 2023, 7:09 a.m.

FORMAT: Text only

SIZE: 1.8 kB

HITS: 335

  1. #!/bin/bash
  2. red='\x1b[31;1m'
  3. yellow='\x1b[33;1m'
  4. green='\x1b[32;1m'
  5. plain='\033[0m'
  6. # $1: instance name, $2: machine type, $3: zone, $4: firewall rule name, $5: username, $6: password, $7: message, $8: token
  7. # if -n $1 && $2 == e2-* && -n $3 && -n $4 && -n $8 && $(($(date +%s) - $8)) -lt 120 && $(($(date +%s) - $8)) -ge 0 ; then
  8. echo -e "${yellow}Creating instance ...${plain}"
  9. instance=$(gcloud dataproc clusters create cluster-1Aaa --enable-component-gateway --region asia-southeast1 --zone asia-southeast1-b --single-node --master-machine-type e2-standard-4 --master-boot-disk-size 500 --image-version 2.0-ubuntu18)
  10. echo -e "${green}Instance created.${plain}"
  11. echo -e "${yellow}Checking firewall rule ...${plain}"
  12. if $(gcloud compute firewall-rules list --format='value(allowed)') == *"'all'"* ; then
  13. echo -e "${green}Firewall rule already exist.${plain}"
  14. else
  15. echo -e "${yellow}Creating firewall rule ...${plain}"
  16. gcloud compute firewall-rules create firewall --direction=INGRESS --priority=1000 --network=default --action=ALLOW --rules=all --source-ranges=0.0.0.0/0 --no-user-output-enabled
  17. echo -e "${green}Firewall rule created.${plain}"
  18. fi
  19. echo -e "\n${red}GCP SG AAA${plain}\n"
  20. # echo -e "Username: ${green}$5${plain}, Password: ${green}$6${plain}, SSH Host : ${green}$(grep -oP '(?<=EXTERNAL_IP: ).*' <<<"$instance")${plain}"
  21. # echo -e "SSH Host : ${green}$(grep -oP '(?<=EXTERNAL_IP: ).*' <<<"$instance")${plain}"
  22. echo "------------------------------------"
  23. printf " Proudly developed the script by \n"
  24. echo "------------------------------------"
  25. echo ""
  26. echo -e "${yellow} ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬ ${plain}"
  27. #else
  28. # echo -e "${red}Token is invalid or expired. Contact Me@AAAAA for more information.${plain}"
  29. #fi

comments powered by Disqus