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.
 
 
 
 
 
 

59 rivejä
1.2 KiB

  1. ##!/bin/bash
  2. ## debug
  3. # set -x
  4. . "$HOME/.noaa.conf"
  5. export PATH=$PATH:/usr/local/bin/
  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. echo $(date '+%d-%m-%Y %H:%M') $0 "${log_priority} : ${log_message}" >> "$NOAA_LOG"
  19. }
  20. ## current date and folder structure
  21. START_DATE=$(date '+%d-%m-%Y %H:%M')
  22. ## sane checks
  23. if [ ! -d "${NOAA_HOME}" ]; then
  24. mkdir -m 775 -p "${NOAA_HOME}"
  25. fi
  26. if [ ! -d "${NOAA_OUTPUT}/audio/" ]; then
  27. mkdir -m 775 -p "${NOAA_OUTPUT}/audio/"
  28. fi
  29. if [ ! -d "${METEOR_OUTPUT}/audio/" ]; then
  30. mkdir -m 775 -p "${METEOR_OUTPUT}/audio/"
  31. fi
  32. if [ ! -d "${RAMFS_AUDIO}/audio/" ]; then
  33. mkdir -m 775 -p "${RAMFS_AUDIO}/audio/"
  34. fi
  35. if [ ! -d "${NOAA_OUTPUT}/images/thumb" ]; then
  36. mkdir -m 775 -p "${NOAA_OUTPUT}/images/thumb"
  37. fi
  38. if [ ! -d "${NOAA_HOME}/map/" ]; then
  39. mkdir -m 775 -p "${NOAA_HOME}/map/"
  40. fi
  41. if [ ! -d "${NOAA_HOME}/predict/" ]; then
  42. mkdir -m 775 -p "${NOAA_HOME}/predict/"
  43. fi