common.sh 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. # A library of common helper functions for Ubuntus & Debians.
  16. function detect-minion-image() {
  17. if [[ -z "${KUBE_NODE_IMAGE=-}" ]]; then
  18. detect-image
  19. KUBE_NODE_IMAGE=$AWS_IMAGE
  20. fi
  21. }
  22. function generate-minion-user-data {
  23. # We pipe this to the ami as a startup script in the user-data field. Requires a compatible ami
  24. echo "#! /bin/bash"
  25. echo "SALT_MASTER='${MASTER_INTERNAL_IP}'"
  26. echo "DOCKER_OPTS='${EXTRA_DOCKER_OPTS:-}'"
  27. echo "readonly NON_MASQUERADE_CIDR='${NON_MASQUERADE_CIDR:-}'"
  28. echo "readonly DOCKER_STORAGE='${DOCKER_STORAGE:-}'"
  29. grep -v "^#" "${KUBE_ROOT}/cluster/aws/templates/common.sh"
  30. grep -v "^#" "${KUBE_ROOT}/cluster/aws/templates/format-disks.sh"
  31. grep -v "^#" "${KUBE_ROOT}/cluster/aws/templates/salt-minion.sh"
  32. }
  33. function check-minion() {
  34. local minion_ip=$1
  35. local output=$(ssh -oStrictHostKeyChecking=no -i "${AWS_SSH_KEY}" ${SSH_USER}@$minion_ip sudo docker ps -a 2>/dev/null)
  36. if [[ -z "${output}" ]]; then
  37. ssh -oStrictHostKeyChecking=no -i "${AWS_SSH_KEY}" ${SSH_USER}@$minion_ip sudo service docker start > $LOG 2>&1
  38. echo "not working yet"
  39. else
  40. echo "working"
  41. fi
  42. }