Skip to content

Commit

Permalink
gceworker: confirm before stopping
Browse files Browse the repository at this point in the history
I accidentally executed the previous command in a terminal and that
happened to be `gceworker.sh stop`. It stopped the VM in the middle of
something, which was unfortunate. This commit adds a prompt, you have
to type "yes" if you really mean it. We also put this prompt for the
`delete` command and add the `--quiet` flag so we don't get the
prompts from `gcloud`.

Release note: None
  • Loading branch information
RaduBerinde committed Oct 11, 2019
1 parent 57b02dd commit d868455
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions scripts/gceworker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,24 @@ case "${cmd}" in
gcloud compute ssh "${NAME}" --ssh-flag="-A" "$@"
;;
stop)
read -r -p "This will stop the VM. Are you sure? [yes] " response
response=${response,,} # to lowercase
if [[ $response != "yes" ]]; then
echo Aborting
exit 1
fi
gcloud compute instances stop "${NAME}"
;;
delete|destroy)
read -r -p "This will delete the VM! Are you sure? [yes] " response
response=${response,,} # to lowercase
if [[ $response != "yes" ]]; then
echo Aborting
exit 1
fi
status=0
gcloud compute firewall-rules delete "${NAME}-mosh" || status=$((status+1))
gcloud compute instances delete "${NAME}" || status=$((status+1))
gcloud compute firewall-rules delete "${NAME}-mosh" --quiet || status=$((status+1))
gcloud compute instances delete "${NAME}" --quiet || status=$((status+1))
exit ${status}
;;
ssh)
Expand Down

0 comments on commit d868455

Please sign in to comment.