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

64 行
1.2 KiB

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