摘自http://www.opensips.org/Resources/DocsTools,opensips学习。
m4
Included on most Linuxes. This is a simple way to set up and use separate parameter files or even a good way of accomplishing INCLUDE's in your configs. Example of usage is provided by Iñaki Baz Castillo;
I strongly recommend you to use M4 to compile your opensips.cfg file:
file /etc/opensips/opensips.cfg.m4:
---------------------------------------------
debug=3
log_stderror=no
log_facility=LOG_LOCAL7
fork=yes
...
listen=MY_IP:MY_PORT
...
rewritehost("MEDIA_SERVER_IP:MEDIA_SERVER_PORT");
...
---------------------------------------------
file /etc/opensips/defines.m4 (at your home):
---------------------------------------------
divert(-1)
define(`MY_IP', `192.168.10.23')
define(`MY_PORT', `5060')
define(`MEDIA_SERVER_IP', `192.168.10.23')
define(`MEDIA_SERVER_PORT', `5065')
divert(0)dnl
---------------------------------------------
file /etc/opensips/defines.m4 (at your office):
---------------------------------------------
divert(-1)
define(`MY_IP', `123.123.123.123')
define(`MY_PORT', `5060')
define(`MEDIA_SERVER_IP', `22.22.22.22')
define(`MEDIA_SERVER_PORT', `5065')
divert(0)dnl
---------------------------------------------
Create a bash script:
/usr/local/bin/op-restart.sh:
----------------------------------------------
#!/bin/bash
DIR="/etc/opensips"
m4 $DIR/defines.m4 $DIR/opensips.cfg.m4 > $DIR/opensips.cfg
/etc/init.d/opensips restart
----------------------------------------------
So you just must change the /etc/opensips/opensips.cfg.m4 file and the
defines.m4 (this last file will be different depending on your location).
使用M4配置OpenSIPS

本文介绍如何利用M4工具简化OpenSIPS配置文件的维护工作。通过创建不同的参数文件,可以在不同环境下轻松切换配置,如家庭和办公室。文中详细展示了如何设置这些参数文件,并提供了一个bash脚本来自动完成这一过程。
1798

被折叠的 条评论
为什么被折叠?



