From 2597c21d598cd9ff17fce0b1548d8b29cace9e73 Mon Sep 17 00:00:00 2001 From: Cory Latschkowski Date: Thu, 21 Sep 2023 09:47:02 -0500 Subject: [PATCH] update: scripts --- scripts/bootstrap.sh | 11 +++++++++-- scripts/functions.sh | 23 +---------------------- scripts/library/rhdp.sh | 30 ++++++++++++++++++++++-------- 3 files changed, 32 insertions(+), 32 deletions(-) diff --git a/scripts/bootstrap.sh b/scripts/bootstrap.sh index d3d90763..8d884f56 100755 --- a/scripts/bootstrap.sh +++ b/scripts/bootstrap.sh @@ -1,12 +1,19 @@ #!/bin/bash set -e -# set -x + +check_shell(){ + [ "${SHELL}" = "/bin/bash" ] && return + echo "Please verify you are running this script in bash shell" +} + +check_shell # shellcheck source=/dev/null . "$(dirname "$0")/functions.sh" LANG=C SLEEP_SECONDS=8 + ARGO_NS="openshift-gitops" ARGO_CHANNEL="stable" ARGO_DEPLOY_STABLE=(cluster kam openshift-gitops-applicationset-controller openshift-gitops-redis openshift-gitops-repo-server openshift-gitops-server) @@ -102,7 +109,7 @@ bootstrap_cluster(){ } # functions -git_root +check_git_root setup_bin check_bin oc # check_bin kustomize diff --git a/scripts/functions.sh b/scripts/functions.sh index 56d1b1f7..8301f1d8 100755 --- a/scripts/functions.sh +++ b/scripts/functions.sh @@ -20,7 +20,7 @@ source_library(){ done } -git_root(){ +check_git_root(){ if [ -d .git ] && [ -d scripts ]; then return else @@ -204,25 +204,4 @@ sealed_secret_check(){ fi } -aws_stop_all_ec2(){ - RUNNING_IDS=$(aws ec2 describe-instances --filters Name=instance-state-name,Values=running --query 'Reservations[].Instances[].InstanceId' --output text | sed 's/\t/ /g') - BASTION_ID=$(aws ec2 describe-instances --filters Name=tag:Name,Values=bastion --query 'Reservations[].Instances[].InstanceId' --output text) - - echo "BASTION_ID: ${BASTION_ID}" - aws ec2 stop-instances \ - --instance-ids \ - "${RUNNING_IDS}" \ - --output text >/dev/null -} - -aws_start_ocp4_cluster(){ - CLUSTER_IDS=$(aws ec2 describe-instances --filters Name=tag:env_type,Values=ocp4-cluster --query 'Reservations[].Instances[].InstanceId' --output text | sed 's/\t/ /g') - - aws ec2 start-instances \ - --instance-ids \ - "${CLUSTER_IDS}" \ - --output text >/dev/null -} - - is_sourced || usage diff --git a/scripts/library/rhdp.sh b/scripts/library/rhdp.sh index a844ae66..9fde74c0 100644 --- a/scripts/library/rhdp.sh +++ b/scripts/library/rhdp.sh @@ -5,14 +5,7 @@ rhdp_get_uuid(){ UUID=$(oc whoami --show-server | sed 's@https://@@; s@:.*@@; s@api.*-@@; s@[.].*$@@') export UUID - echo "UUID: ${UUID}" -} - -rhdp_check_login(){ - echo "Are you on the right OCP cluster?" - oc whoami || exit 0 - - sleep 8 + echo "OCP Cluster UUID: ${UUID}" } rhdp_fix_api_certs(){ @@ -40,3 +33,24 @@ rhdp_fix_api_certs(){ oc patch apiserver cluster --type=merge -p '{"spec":{"servingCerts": {"namedCertificates": [{"names": ["'"${API_HOST_NAME}"'"], "servingCertificate": {"name": "'"${CERT_NAME}"'"}}]}}}' } + + +rhdp_aws_stop_all_ec2(){ + RUNNING_IDS=$(aws ec2 describe-instances --filters Name=instance-state-name,Values=running --query 'Reservations[].Instances[].InstanceId' --output text | sed 's/\t/ /g') + BASTION_ID=$(aws ec2 describe-instances --filters Name=tag:Name,Values=bastion --query 'Reservations[].Instances[].InstanceId' --output text) + + echo "BASTION_ID: ${BASTION_ID}" + aws ec2 stop-instances \ + --instance-ids \ + "${RUNNING_IDS}" \ + --output text >/dev/null +} + +rhdp_aws_start_ocp4_cluster(){ + CLUSTER_IDS=$(aws ec2 describe-instances --filters Name=tag:env_type,Values=ocp4-cluster --query 'Reservations[].Instances[].InstanceId' --output text | sed 's/\t/ /g') + + aws ec2 start-instances \ + --instance-ids \ + "${CLUSTER_IDS}" \ + --output text >/dev/null +}