configure.sh 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #!/bin/bash
  2. # Copyright 2015 The Kubernetes Authors.
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. # This script generates config.sh, which is a site-local config file that is not
  16. # checked into source control.
  17. # Select and configure Backup Storage Implementation.
  18. storage=gcs
  19. read -p "Backup Storage (file, gcs) [gcs]: "
  20. if [ -n "$REPLY" ]; then storage="$REPLY"; fi
  21. case "$storage" in
  22. gcs)
  23. # Google Cloud Storage
  24. project=$(gcloud config list project | grep 'project\s*=' | sed -r 's/^.*=\s*(.*)$/\1/')
  25. read -p "Google Developers Console Project [$project]: "
  26. if [ -n "$REPLY" ]; then project="$REPLY"; fi
  27. if [ -z "$project" ]; then
  28. echo "ERROR: Project name must not be empty."
  29. exit 1
  30. fi
  31. read -p "Google Cloud Storage bucket for Vitess backups: " bucket
  32. if [ -z "$bucket" ]; then
  33. echo "ERROR: Bucket name must not be empty."
  34. exit 1
  35. fi
  36. echo
  37. echo "NOTE: If you haven't already created this bucket, you can do so by running:"
  38. echo " gsutil mb gs://$bucket"
  39. echo
  40. backup_flags=$(echo -backup_storage_implementation gcs \
  41. -gcs_backup_storage_project "'$project'" \
  42. -gcs_backup_storage_bucket "'$bucket'")
  43. ;;
  44. file)
  45. # Mounted volume (e.g. NFS)
  46. read -p "Root directory for backups (usually an NFS mount): " file_root
  47. if [ -z "$file_root" ]; then
  48. echo "ERROR: Root directory must not be empty."
  49. exit 1
  50. fi
  51. echo
  52. echo "NOTE: You must add your NFS mount to the vtctld-controller-template"
  53. echo " and vttablet-pod-template as described in the Kubernetes docs:"
  54. echo " http://kubernetes.io/v1.0/docs/user-guide/volumes.html#nfs"
  55. echo
  56. backup_flags=$(echo -backup_storage_implementation file \
  57. -file_backup_storage_root "'$file_root'")
  58. ;;
  59. *)
  60. echo "ERROR: Unsupported backup storage implementation: $storage"
  61. exit 1
  62. esac
  63. echo "Saving config.sh..."
  64. echo "backup_flags=\"$backup_flags\"" > config.sh