-
-
Save making/ff28a958f410dd611eb7 to your computer and use it in GitHub Desktop.
start-stop.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Set for 1.5.x Jobs | |
export BUNDLE_GEMFILE=/home/tempest-web/tempest/web/bosh.Gemfile | |
if [ "$1" == "shut" ] || [ "$1" == "start" ]; | |
then | |
echo "Running PCF $1 Process..." | |
else | |
echo "Only shut or start are valid args!" | |
exit 1 | |
fi | |
#Target good deployment | |
export CF_DEPLOYMENT=`bundle exec bosh deployments | awk '{print $2}' | grep "cf-"` | |
bundle exec bosh deployment /var/tempest/workspaces/default/deployments/${CF_DEPLOYMENT}.yml | |
declare -a bootOrder=( | |
diego_cell | |
nats | |
consul_server | |
etcd_server | |
nfs_server | |
ccdb | |
uaadb | |
consoledb | |
cloud_controller | |
ha_proxy | |
router | |
health_manager | |
clock_global | |
cloud_controller_worker | |
uaa | |
dea | |
diego_brain | |
diego_database | |
doppler | |
loggregator_trafficcontroller | |
collector | |
mysql | |
mysql_proxy | |
) | |
if [ "$1" == "shut" ]; then | |
jobVMs=$(bundle exec bosh vms --detail | grep running | grep partition | awk -F '|' '{ print $2 }') | |
bundle exec bosh vm resurrection disable | |
for (( i=${#bootOrder[@]}-1; i>=0; i-- )); do | |
for x in $jobVMs; do | |
jobId=$(echo "$x" | awk -F "/" '{ print $1 }') | |
instanceId=$(echo "$x" | awk -F "/" '{ print $2 }') | |
jobType=$(echo "$jobId" | awk -F "-" '{ print $1 }') | |
if [ "$jobType" == "${bootOrder[$i]}" ]; | |
then | |
#echo MATCHVAL---${bootOrder[$i]} JOBTYPE----$jobType JOBID----$jobId Instance-------$instanceId | |
bundle exec bosh -n stop "${jobId}" "${instanceId}" | |
fi | |
done; | |
done | |
fi | |
if [ "$1" == "start" ]; then | |
startJobVMs=$(bundle exec bosh vms --detail| grep partition | awk -F '|' '{ print $2 }') | |
bundle exec bosh vm resurrection enable | |
for i in "${bootOrder[@]}"; do | |
for x in $startJobVMs; do | |
jobId=$(echo "$x" | awk -F "/" '{ print $1 }') | |
instanceId=$(echo "$x" | awk -F "/" '{ print $2 }') | |
jobType=$(echo "$jobId" | awk -F "-" '{ print $1 }') | |
if [ "$i" == "$jobType" ]; | |
then | |
if [ "diego_cell" == "$jobType" ]; | |
then | |
echo FOUND "DIEGO CELL" "$jobId" instanceID "$instanceId" | |
bundle exec bosh -n recreate "$jobId" "$instanceId" --force --skip-drain | |
else | |
echo FOUND "$jobId" instanceID "$instanceId" | |
bundle exec bosh -n start "$jobId" "$instanceId" | |
fi | |
fi | |
done; | |
done | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment