You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

68 lines
1.5 KiB

  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. exec /usr/bin/weed $@ $ARGS
  24. ;;
  25. 'volume')
  26. ARGS="-dir=/data -max=0"
  27. if isArgPassed "-max" "$@"; then
  28. ARGS="-dir=/data"
  29. fi
  30. exec /usr/bin/weed $@ $ARGS
  31. ;;
  32. 'server')
  33. ARGS="-dir=/data -volume.max=0 -master.volumePreallocate -master.volumeSizeLimitMB=1024"
  34. if isArgPassed "-volume.max" "$@"; then
  35. ARGS="-dir=/data -master.volumePreallocate -master.volumeSizeLimitMB=1024"
  36. fi
  37. exec /usr/bin/weed $@ $ARGS
  38. ;;
  39. 'filer')
  40. ARGS=""
  41. exec /usr/bin/weed $@ $ARGS
  42. ;;
  43. 's3')
  44. ARGS="-domainName=$S3_DOMAIN_NAME -key.file=$S3_KEY_FILE -cert.file=$S3_CERT_FILE"
  45. exec /usr/bin/weed $@ $ARGS
  46. ;;
  47. 'cronjob')
  48. MASTER=${WEED_MASTER-localhost:9333}
  49. FIX_REPLICATION_CRON_SCHEDULE=${CRON_SCHEDULE-*/7 * * * * *}
  50. echo "$FIX_REPLICATION_CRON_SCHEDULE" 'echo "volume.fix.replication" | weed shell -master='$MASTER > /crontab
  51. BALANCING_CRON_SCHEDULE=${CRON_SCHEDULE-25 * * * * *}
  52. echo "$BALANCING_CRON_SCHEDULE" 'echo "volume.balance -c ALL -force" | weed shell -master='$MASTER >> /crontab
  53. echo "Running Crontab:"
  54. cat /crontab
  55. exec supercronic /crontab
  56. ;;
  57. *)
  58. exec /usr/bin/weed $@
  59. ;;
  60. esac