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.
 
 
 
 
 
 

62 regels
1.3 KiB

  1. #!/bin/bash
  2. ## debug
  3. # set -x
  4. . "$HOME/.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}/audio/" ]; then
  26. mkdir -m 775 -p "${NOAA_OUTPUT}/audio/"
  27. fi
  28. if [ ! -d "${METEOR_OUTPUT}/audio/" ]; then
  29. mkdir -m 775 -p "${METEOR_OUTPUT}/audio/"
  30. fi
  31. if [ ! -d "${RAMFS_AUDIO}/audio/" ]; then
  32. mkdir -m 775 -p "${RAMFS_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