entrypoint.sh 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #!/bin/sh
  2. isArgPassed() {
  3. arg="$1"
  4. argWithEqualSign="$1="
  5. shift
  6. while [ $# -gt 0 ]; do
  7. passedArg="$1"
  8. shift
  9. case $passedArg in
  10. $arg)
  11. return 0
  12. ;;
  13. $argWithEqualSign*)
  14. return 0
  15. ;;
  16. esac
  17. done
  18. return 1
  19. }
  20. case "$1" in
  21. 'master')
  22. ARGS="-mdir=/data -volumePreallocate -volumeSizeLimitMB=1024"
  23. shift
  24. exec /usr/bin/weed master $ARGS $@
  25. ;;
  26. 'volume')
  27. ARGS="-dir=/data -max=0"
  28. if isArgPassed "-max" "$@"; then
  29. ARGS="-dir=/data"
  30. fi
  31. shift
  32. exec /usr/bin/weed volume $ARGS $@
  33. ;;
  34. 'server')
  35. ARGS="-dir=/data -volume.max=0 -master.volumePreallocate -master.volumeSizeLimitMB=1024"
  36. if isArgPassed "-volume.max" "$@"; then
  37. ARGS="-dir=/data -master.volumePreallocate -master.volumeSizeLimitMB=1024"
  38. fi
  39. shift
  40. exec /usr/bin/weed server $ARGS $@
  41. ;;
  42. 'filer')
  43. ARGS=""
  44. shift
  45. exec /usr/bin/weed filer $ARGS $@
  46. ;;
  47. 's3')
  48. ARGS="-domainName=$S3_DOMAIN_NAME -key.file=$S3_KEY_FILE -cert.file=$S3_CERT_FILE"
  49. shift
  50. exec /usr/bin/weed s3 $ARGS $@
  51. ;;
  52. 'cronjob')
  53. MASTER=${WEED_MASTER-localhost:9333}
  54. FIX_REPLICATION_CRON_SCHEDULE=${CRON_SCHEDULE-*/7 * * * * *}
  55. echo "$FIX_REPLICATION_CRON_SCHEDULE" 'echo "lock; volume.fix.replication; unlock" | weed shell -master='$MASTER > /crontab
  56. BALANCING_CRON_SCHEDULE=${CRON_SCHEDULE-25 * * * * *}
  57. echo "$BALANCING_CRON_SCHEDULE" 'echo "lock; volume.balance -collection ALL_COLLECTIONS -force; unlock" | weed shell -master='$MASTER >> /crontab
  58. echo "Running Crontab:"
  59. cat /crontab
  60. exec supercronic /crontab
  61. ;;
  62. *)
  63. exec /usr/bin/weed $@
  64. ;;
  65. esac