#!/bin/sh FILE=$1.wav echo $FILE >/rec_len.liu rcd_playtime=`/usr/bin/php /etc/scripts/getaudio_time.php $FILE` ls -lh $FILE >>/rec_len.liu echo ${rcd_playtime} >>/rec_len.liu if [ -z ${rcd_playtime} ];then echo "rcd_playtime is zero" >> /tmp/t.sql echo "$FILE" >> /tmp/t.sql exit 1 fi rcd_playtime=`echo ${rcd_playtime}|awk -F '.' '{print $1}'` if [ "${rcd_playtime}" -eq 0 ];then rm -f "$FILE" 2>/dev/null exit 1 fi cat /etc/asterisk/exten_gen.ini | sed 's/\[general]/\;\[general]/g' | tr \; \# | sed '/#!/d' | tr -d ' ' > /tmp/exten_gen.ini.tmp . /tmp/exten_gen.ini.tmp dbhost="$dbserverip" dbusername="$dbuser" dbpassword="$dbpasswd" DB="$dbname" RECORDING="t_pbx_recording" PAGINGTABLE="t_paging_paging" INTERCOMTABLE="t_paging_intercom" CONFERENCETABLE="t_paging_conference" MYSQL="/usr/bin/mysql" MYSQLCMD="${MYSQL} -h${dbhost} -u${dbusername} -p${dbpassword} ${DB}" TYPE=`echo $FILE|awk -F '/' '{print $6}'` case $TYPE in recording) SRC=`echo $FILE|awk -F '-' '{print $2}'` DST=`echo $FILE|awk -F '-' '{print $3}'` TYPE=`echo $FILE|awk -F '-' '{print $4}'` DATETIME_tmp=`echo $FILE|awk -F '-' '{print $5}'|awk -F '.' '{print $1}'` DATETIME=`date -d "@${DATETIME_tmp}" "+%Y-%m-%d %H:%M:%S"` UUID=`echo $1|awk -F '-' '{print $5}'` FILENAME="$FILE" if [ -n "${SRC}" -a -n "${DST}" -a -n "${TYPE}" -a -n "${UUID}" ];then 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}');" echo "${SQL}" | ${MYSQLCMD} fi ;; paging) SRC=`echo $FILE|awk -F '-' '{print $2}'` DATETIME_tmp=`echo $FILE|awk -F '-' '{print $3}'|awk -F '.' '{print $1}'` DATETIME=`date -d "@${DATETIME_tmp}" "+%Y-%m-%d %H:%M:%S"` UUID=`echo $1|awk -F '-' '{print $3}'` FILENAME="$FILE" if [ -n "${SRC}" -a -n "${UUID}" ];then SQL="INSERT INTO ${PAGINGTABLE} (src,record_start_time,record_filename,record_len,uniqueid,createdAt) values ('${SRC}','${DATETIME}','${FILENAME}','${rcd_playtime}','${UUID}','${DATETIME}');" echo "${SQL}" | ${MYSQLCMD} fi ;; intercom) SRC=`echo $FILE|awk -F '-' '{print $2}'` DST=`echo $FILE|awk -F '-' '{print $3}'` DATETIME_tmp=`echo $FILE|awk -F '-' '{print $4}'|awk -F '.' '{print $1}'` DATETIME=`date -d "@${DATETIME_tmp}" "+%Y-%m-%d %H:%M:%S"` UUID=`echo $1|awk -F '-' '{print $4}'` FILENAME="$FILE" if [ -n "${SRC}" -a -n "${DST}" -a -n "${UUID}" ];then SQL="INSERT INTO ${INTERCOMTABLE} (src,dest,record_start_time,record_filename,record_len,uniqueid,createdAt) values ('${SRC}','${DST}','${DATETIME}','${FILENAME}','${rcd_playtime}','${UUID}','${DATETIME}');" echo "${SQL}" | ${MYSQLCMD} fi ;; conference) CONFNUM=`echo $FILE|awk -F '-' '{print $2}'` DATETIME_tmp=`echo $FILE|awk -F '-' '{print $3}'|awk -F '.' '{print $1}'` DATETIME=`date -d "@${DATETIME_tmp}" "+%Y-%m-%d %H:%M:%S"` FILENAME="$FILE" if [ -n "${CONFNUM}" -a -n "${DATETIME}" ];then SQL="INSERT INTO ${CONFERENCETABLE} (conference_id,record_start_time,record_filename,record_len,createdAt) values ('${CONFNUM}','${DATETIME}','${FILENAME}','${rcd_playtime}','${DATETIME}');" echo "${SQL}" | ${MYSQLCMD} fi ;; esac