Skip to content

Commit

Permalink
update: scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
codekow committed Sep 21, 2023
1 parent ebb7029 commit 2597c21
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 32 deletions.
11 changes: 9 additions & 2 deletions scripts/bootstrap.sh
Original file line number Diff line number Diff line change
@@ -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)
Expand Down Expand Up @@ -102,7 +109,7 @@ bootstrap_cluster(){
}

# functions
git_root
check_git_root
setup_bin
check_bin oc
# check_bin kustomize
Expand Down
23 changes: 1 addition & 22 deletions scripts/functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ source_library(){
done
}

git_root(){
check_git_root(){
if [ -d .git ] && [ -d scripts ]; then
return
else
Expand Down Expand Up @@ -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
30 changes: 22 additions & 8 deletions scripts/library/rhdp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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(){
Expand Down Expand Up @@ -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
}

0 comments on commit 2597c21

Please sign in to comment.