您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #!/bin/bash
  2. ## debug
  3. # set -x
  4. . ~/.noaa.conf
  5. declare -A levels=([DEBUG]=0 [INFO]=1 [WARN]=2 [ERROR]=3)
  6. log_level=${LOG_LEVEL}
  7. ## log function
  8. log() {
  9. local log_message=$1
  10. local log_priority=$2
  11. #check if level exists
  12. [[ ${levels[$log_priority]} ]] || return 1
  13. #check if level is enough
  14. (( ${levels[$log_priority]} < ${levels[$log_level]} )) && return 2
  15. #log here
  16. echo "${log_priority} : ${log_message}"
  17. }
  18. ## current date and folder structure
  19. START_DATE=$(date '+%d-%m-%Y %H:%M')
  20. FOLDER_DATE="$(date +%Y)/$(date +%m)/$(date +%d)"
  21. ## sane checks
  22. if [ ! -d "${NOAA_HOME}" ]; then
  23. mkdir -m 775 -p "${NOAA_HOME}"
  24. fi
  25. if [ ! -d "${NOAA_OUTPUT}" ]; then
  26. mkdir -m 775 -p "${NOAA_OUTPUT}"
  27. fi
  28. if [ ! -d "${METEOR_OUTPUT}" ]; then
  29. mkdir -m 775 -p "${METEOR_OUTPUT}"
  30. fi
  31. if [ ! -d "${NOAA_AUDIO}/audio/" ]; then
  32. mkdir -m 775 -p "${NOAA_AUDIO}/audio/"
  33. fi
  34. if [ ! -d "${NOAA_OUTPUT}/image/" ]; then
  35. mkdir -m 775 -p "${NOAA_OUTPUT}/image/"
  36. fi
  37. if [ ! -d "${NOAA_HOME}/map/" ]; then
  38. mkdir -m 775 -p "${NOAA_HOME}/map/"
  39. fi
  40. if [ ! -d "${NOAA_HOME}/predict/" ]; then
  41. mkdir -m 775 -p "${NOAA_HOME}/predict/"
  42. fi
  43. if [ ! -d "${NOAA_OUTPUT}/image/${FOLDER_DATE}" ]; then
  44. mkdir -m 775 -p "${NOAA_OUTPUT}/image/${FOLDER_DATE}"
  45. fi