適用 DD-WRT 平台的 Wakeup Call。
特色:不需 PHP 環境
context ael-wakeup_call-start { 5556 => goto ael-wakeup_call-main|s|1; }; context ael-wakeup_call-main { s => { Answer(); Wait(1); Set(CALLER=${CALLERID(number)}); Set(TIMEOUT(digit)=5); Set(TIMEOUT(response)=10); Background(welcome); Background(for-wakeup-call); Background(press-1); Background(to-cancel-wakeup); Background(press-2); WaitExten(10); endcall: Wait(1); Playback(goodbye); Hangup(); }; 1 => { Wait(1); Playback(please-enter-the); Playback(time); Playback(for); Playback(your); Read(WTIME|wakeup-call|4); Set(HOUR=${WTIME:0:2}); Set(MIN=${WTIME:2:2}); if ( $[${WTIME:0:2} < 24] & $[${WTIME:2:2} < 60] ) { Playback(rqsted-wakeup-for); SayNumber(${HOUR}); Playback(digits/oclock); SayNumber(${MIN}); NoOp(Making the callfile ---->); AGI(wakeup.sh|${WTIME}|${CALLER}); goto s|endcall; } else { Playback(please-try-again); goto 1|1; }; Hangup(); }; 2 => { AGI(wakeup.sh|Cancel|${CALLER}); Wait(1); Playback(wakeup-call-cancelled); goto s|endcall; }; i => goto s|1; };
#!/bin/sh # This AGI is written by alang (2009-11-8) # $1 = <1020|cancel> time for wakeup call or cancel it # $2 = <201> extension for caller # # Constant CALL_SPOOL_DIR='/opt/var/spool/asterisk/outgoing' CALL_TMP_DIR='/tmp' CALL_MAXRETRIES='3' CALL_RETRY_TIME='60' CALL_WAIT_TIME='60' WAKEUPCALL_ID='"WakeUP" <*62>' APPLICATION='MusicOnHold' CALL_CONTEXT='default' # Generally, this is the default context name of an extension. # Function make_callfile() { CALLFILE="$WTIME.ext.$CALLER.call" #note use of '-' in '-EOF1' - Escapes tab at beginning of lines cat > $CALL_TMP_DIR/$CALLFILE <<-EOF1 Channel: Local/$CALLER@$CALL_CONTEXT MaxRetries: $CALL_MAXRETRIES RetryTime: $CALL_RETRY_TIME WaitTime: $CALL_WAIT_TIME CallerID: $WAKEUPCALL_ID Application: $APPLICATION EOF1 # modify the time of the callfile with the command 'touch' H_WTIME=${WTIME:0:2} M_WTIME=${WTIME:2:2} ##echo "H_WTIME=$H_WTIME and M_WTIME=$M_WTIME" DATE_NOW=`date +%Y-%m-%d` TIME_NOW=`date +%s` TIME_WAKEUP=`date --date "$DATE_NOW +$H_WTIME hours +$M_WTIME minutes"` SEC_WAKEUP=`date --date "$TIME_WAKEUP" +%s` ##echo "TIME_WAKEUP --> $TIME_WAKEUP" if [ "$SEC_WAKEUP" -le "$TIME_NOW" ]; then # add 1 day to $TIME_WAKEUP TIME_WAKEUP=`date --date "$TIME_WAKEUP 1 days"` fi TIME_TOUCH=`date --date "$TIME_WAKEUP" +%Y%m%d%H%M` ##echo "TIME_TOUCH --> $TIME_TOUCH" touch -t $TIME_TOUCH "$CALL_TMP_DIR/$WTIME.ext.$CALLER.call" mv "$CALL_TMP_DIR/$WTIME.ext.$CALLER.call" "$CALL_SPOOL_DIR/$WTIME.ext.$CALLER.call" } clean_callfile() { rm -f $CALL_SPOOL_DIR/*.ext.$CALLER.call > /dev/null 2>&1 } # Main if [ "x$1" != "x" ]; then WTIME="$1"; else exit 1; fi if [ "x$2" != "x" ]; then CALLER="$2"; else exit 1; fi # Clean the old wakeup-call of the extension before making an new wakeup-call clean_callfile [ $WTIME == "Cancel" -o $WTIME == "cancel" ] && exit 0 make_callfile #EOF
Images 0 | ||
---|---|---|
No images to display in the gallery. |
Wakeup Call - DD-WRT版 安裝步驟心得如下:
一.用nano或vi修改/opt/etc/asterisk/extensions.ael檔案,在最底部空白處加上一行#include "/opt/etc/asterisk/wakeup.ael",其餘內容不變動:
nano /opt/etc/asterisk/extensions.ael
.
.
.
#include "/opt/etc/asterisk/wakeup.ael"
二.用nano或vi建立如alang站長之wakeup.ael檔案全部內容,路徑為/opt/etc/asterisk/wakeup.ael,另為了習慣用法,我把檔案內原第二行之5556改為*62,其餘內容不變動:
nano /opt/etc/asterisk/wakeup.ael
context ael-wakeup_call-start {
*62 => goto ael-wakeup_call-main|s|1;
};
.
.
.
三.用nano或vi建立如alang站長之wakeup.sh檔案全部內容,路徑為/opt/var/lib/asterisk/agi-bin/wakeup.sh,另因我的分機之context是設定為from-internal,所以在檔案內第十四行之CALL_CONTEXT='default'須改為CALL_CONTEXT='from-internal',其餘內容不變動:
nano /opt/var/lib/asterisk/agi-bin/wakeup.sh
#!/bin/sh
# This AGI is written by alang (2009-11-8)
# $1 = <1020|cancel> time for wakeup call or cancel it
# $2 = <201> extension for caller
#
# Constant
CALL_SPOOL_DIR='/opt/var/spool/asterisk/outgoing'
CALL_TMP_DIR='/tmp'
CALL_MAXRETRIES='3'
CALL_RETRY_TIME='60'
CALL_WAIT_TIME='60'
WAKEUPCALL_ID='"WakeUP" <*62>'
APPLICATION='MusicOnHold'
CALL_CONTEXT='from-internal' # Generally, this is the default context name of an extension.
# Function
.
.
.
建立完成後再下如下指令:
chmod 755 /opt/var/lib/asterisk/agi-bin/wakeup.sh
四.將wakeup.ael檔案內第一個context也就是第一行之ael-wakeup_call-start要include在/opt/etc/asterisk/extensions_custom.conf之[from-internal]之內:
nano /opt/etc/asterisk/extensions_custom.conf
.
.
.
[from-internal]
include => ael-wakeup_call-start
.
.
.
五.所需之相關module如 res_musiconhold.so, func_moh.so, pbx_ael.so等要打開:
nano /opt/etc/asterisk/modules.conf
load => res_musiconhold.so
load => func_moh.so
load => pbx_ael.so
.
.
.
或RAM記憶體在32M以上時可用autoload=yes
autoload=yes
.
.
.
六.下指令asterisk -rx "module reload"或reboot重開機後從註冊之分機撥*62就可進入wakeup-call設定語音,輸入時間為廿四小時制之四位數.
asterisk -rx "module reload"
或
reboot
七.收工,以上如有疏漏之處,請alang站長指正.
如果不介意,你可以直接編輯此篇的原文,這個 Wiki 系統就是提供大伙來共同編輯這些技術文章,不用擔心會有文字誤刪情形,系統會紀錄每次修改的版本,必要時也可作內容恢復,其實就是類似國外的 voip-info.org 也是集眾人智慧的 Wiki (共筆)系統。
期待能在這看到你更多的分享文章。^_^
- 寫作教學
http://www.osslab.org.tw/OSSLab_wiki_%E6%95%99%E5%AD%A6%E4%B8%93%E5%8C%BA
- 寫作練習,可在這練習編輯的技巧
http://www.osslab.org.tw/OSSLab_FAQ/OSSLab_%E7%AB%99%E5%8B%99%E5%8F%8D%E6%87%89%E8%88%87%E6%96%B9%E5%90%91/%E6%B2%99%E7%9B%92%E6%B8%AC%E8%A9%A6%E9%A0%81