run_gluster.sh 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #!/usr/bin/env 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. DIR="$(mktemp -d)"
  16. function start()
  17. {
  18. mount -t tmpfs test "$DIR"
  19. chmod 755 "$DIR"
  20. cp /vol/* "$DIR/"
  21. /usr/sbin/glusterd -p /run/glusterd.pid
  22. gluster volume create test_vol "$(hostname -i):$DIR" force
  23. gluster volume start test_vol
  24. }
  25. function stop()
  26. {
  27. gluster --mode=script volume stop test_vol force
  28. kill "$(cat /run/glusterd.pid)"
  29. umount "$DIR"
  30. rm -rf "$DIR"
  31. exit 0
  32. }
  33. trap stop TERM
  34. start "$@"
  35. while true; do
  36. sleep 5
  37. done