coopaging_storage.sh 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. #!/bin/sh
  2. FILE=$1.wav
  3. echo $FILE >/rec_len.liu
  4. rcd_playtime=`/usr/bin/php /etc/scripts/getaudio_time.php $FILE`
  5. ls -lh $FILE >>/rec_len.liu
  6. echo ${rcd_playtime} >>/rec_len.liu
  7. if [ -z ${rcd_playtime} ];then
  8. echo "rcd_playtime is zero" >> /tmp/t.sql
  9. echo "$FILE" >> /tmp/t.sql
  10. exit 1
  11. fi
  12. rcd_playtime=`echo ${rcd_playtime}|awk -F '.' '{print $1}'`
  13. if [ "${rcd_playtime}" -eq 0 ];then
  14. rm -f "$FILE" 2>/dev/null
  15. exit 1
  16. fi
  17. cat /etc/asterisk/exten_gen.ini | sed 's/\[general]/\;\[general]/g' | tr \; \# | sed '/#!/d' | tr -d ' ' > /tmp/exten_gen.ini.tmp
  18. . /tmp/exten_gen.ini.tmp
  19. dbhost="$dbserverip"
  20. dbusername="$dbuser"
  21. dbpassword="$dbpasswd"
  22. DB="$dbname"
  23. RECORDING="t_pbx_recording"
  24. PAGINGTABLE="t_paging_paging"
  25. INTERCOMTABLE="t_paging_intercom"
  26. CONFERENCETABLE="t_paging_conference"
  27. MYSQL="/usr/bin/mysql"
  28. MYSQLCMD="${MYSQL} -h${dbhost} -u${dbusername} -p${dbpassword} ${DB}"
  29. TYPE=`echo $FILE|awk -F '/' '{print $6}'`
  30. case $TYPE in
  31. recording)
  32. SRC=`echo $FILE|awk -F '-' '{print $2}'`
  33. DST=`echo $FILE|awk -F '-' '{print $3}'`
  34. TYPE=`echo $FILE|awk -F '-' '{print $4}'`
  35. DATETIME_tmp=`echo $FILE|awk -F '-' '{print $5}'|awk -F '.' '{print $1}'`
  36. DATETIME=`date -d "@${DATETIME_tmp}" "+%Y-%m-%d %H:%M:%S"`
  37. UUID=`echo $1|awk -F '-' '{print $5}'`
  38. FILENAME="$FILE"
  39. if [ -n "${SRC}" -a -n "${DST}" -a -n "${TYPE}" -a -n "${UUID}" ];then
  40. SQL="INSERT INTO ${RECORDING} (src,dest,call_type,record_start_time,record_filename,record_len,uniqueid,createdAt) values ('${SRC}','${DST}','${TYPE}','${DATETIME}','${FILENAME}','${rcd_playtime}','${UUID}','${DATETIME}');"
  41. echo "${SQL}" | ${MYSQLCMD}
  42. fi
  43. ;;
  44. paging)
  45. SRC=`echo $FILE|awk -F '-' '{print $2}'`
  46. DATETIME_tmp=`echo $FILE|awk -F '-' '{print $3}'|awk -F '.' '{print $1}'`
  47. DATETIME=`date -d "@${DATETIME_tmp}" "+%Y-%m-%d %H:%M:%S"`
  48. UUID=`echo $1|awk -F '-' '{print $3}'`
  49. FILENAME="$FILE"
  50. if [ -n "${SRC}" -a -n "${UUID}" ];then
  51. SQL="INSERT INTO ${PAGINGTABLE} (src,record_start_time,record_filename,record_len,uniqueid,createdAt) values ('${SRC}','${DATETIME}','${FILENAME}','${rcd_playtime}','${UUID}','${DATETIME}');"
  52. echo "${SQL}" | ${MYSQLCMD}
  53. fi
  54. ;;
  55. intercom)
  56. SRC=`echo $FILE|awk -F '-' '{print $2}'`
  57. DST=`echo $FILE|awk -F '-' '{print $3}'`
  58. DATETIME_tmp=`echo $FILE|awk -F '-' '{print $4}'|awk -F '.' '{print $1}'`
  59. DATETIME=`date -d "@${DATETIME_tmp}" "+%Y-%m-%d %H:%M:%S"`
  60. UUID=`echo $1|awk -F '-' '{print $4}'`
  61. FILENAME="$FILE"
  62. if [ -n "${SRC}" -a -n "${DST}" -a -n "${UUID}" ];then
  63. SQL="INSERT INTO ${INTERCOMTABLE} (src,dest,record_start_time,record_filename,record_len,uniqueid,createdAt) values ('${SRC}','${DST}','${DATETIME}','${FILENAME}','${rcd_playtime}','${UUID}','${DATETIME}');"
  64. echo "${SQL}" | ${MYSQLCMD}
  65. fi
  66. ;;
  67. conference)
  68. CONFNUM=`echo $FILE|awk -F '-' '{print $2}'`
  69. DATETIME_tmp=`echo $FILE|awk -F '-' '{print $3}'|awk -F '.' '{print $1}'`
  70. DATETIME=`date -d "@${DATETIME_tmp}" "+%Y-%m-%d %H:%M:%S"`
  71. FILENAME="$FILE"
  72. if [ -n "${CONFNUM}" -a -n "${DATETIME}" ];then
  73. SQL="INSERT INTO ${CONFERENCETABLE} (conference_id,record_start_time,record_filename,record_len,createdAt) values ('${CONFNUM}','${DATETIME}','${FILENAME}','${rcd_playtime}','${DATETIME}');"
  74. echo "${SQL}" | ${MYSQLCMD}
  75. fi
  76. ;;
  77. esac