摘自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).