提交 ff81c16a authored 作者: Brian West's avatar Brian West

add template for voipuser.org

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@6664 d0543943-73ff-0310-b7d9-9358b9ac24b2
上级 08713944
<!-- Working FWD dialup in and outbound -->
<include>
<user id="%VUUSERNAME%">
<gateways>
<gateway name="sip.voipuser.org">
<param name="username" value="%VUUSERNAME%"/>
<param name="password" value="%VUPASSWORD%"/>
<param name="expire-seconds" value="600"/>
<param name="register" value="true"/>
<param name="retry_seconds" value="30"/>
<param name="extension" value="%VUEXTENSION%"/>
<param name="context" value="public"/>
</gateway>
</gateways>
<params>
<param name="password" value="%VUPASSWORD%"/>
</params>
</user>
</include>
...@@ -12,159 +12,169 @@ use File::Copy; ...@@ -12,159 +12,169 @@ use File::Copy;
my $PREFIX = "/usr/local/freeswitch"; my $PREFIX = "/usr/local/freeswitch";
my $providers = { my $providers = {
"1" => "FWD", "1" => "FWD",
"2" => "SP", "2" => "SP",
"3" => "IS", "3" => "IS",
"4" => "AL", "4" => "AL",
"5" => "SB" "5" => "SB",
}; "6" => "VU"
};
my $FWD = { my $FWD = {
"type" => "network", "type" => "network",
"register" => "true", "register" => "true",
"fields" => [number, password, extension], "fields" => [number, password, extension],
"domain" => "pulver.com", "domain" => "pulver.com",
"dialprefix" => "1-393" "dialprefix" => "1-393"
}; };
my $SP = { my $SIPHONE = {
"type" => "network", "type" => "network",
"register" => "true", "register" => "true",
"fields" => [username, password, extension], "fields" => [username, password, extension],
"domain" => "sipphone.com", "domain" => "sipphone.com",
"dialprefix" => "1-747, 1-222" "dialprefix" => "1-747, 1-222"
}; };
my $IS = { my $IDEASIP = {
"type" => "network", "type" => "network",
"register" => "true", "register" => "true",
"fields" => [username, password, extension], "fields" => [username, password, extension],
"domain" => "ideasip.com", "domain" => "ideasip.com",
"dialprefix" => "1-101" "dialprefix" => "1-101"
}; };
my $AL = { my $VOIPUSER = {
"type" => "pstn", "type" => "network",
"register" => "true", "register" => "true",
"fields" => [username, password, extension], "fields" => [username, password, extension],
"domain" => "asterlink.com", "domain" => "voipuser.org"
}; };
my $SB = { my $ASTERLINK = {
"type" => "peer", "type" => "pstn",
"domain" => "sipbroker.com", "register" => "true",
"dialprefix" => "*XXX" "fields" => [username, password, extension],
}; "domain" => "asterlink.com",
};
my $SIPBROKER = {
"type" => "peer",
"domain" => "sipbroker.com",
"dialprefix" => "*XXX"
};
my $TEMPLATES = { my $TEMPLATES = {
"FWD" => $FWD, "FWD" => $FWD,
"SP" => $SP, "SP" => $SIPPHONE,
"IS" => $IS, "IS" => $IDEASIP,
"AL" => $AL, "AL" => $ASTERLINK,
"SB" => $SB "SB" => $SIPBROKER,
}; "VU" => $VOIPUSER
};
print "\n" x 60; print "\n" x 60;
&welcome; &welcome;
sub welcome { sub welcome {
print <<WELCOME print <<WELCOME
Welcome to the FreeSWITCH setup assistant. Welcome to the FreeSWITCH setup assistant.
1. Configure Free World Dialup 1. Configure Free World Dialup
2. Configure SIPPhone.com 2. Configure SIPPhone.com
3. Configure ideaSIP.com 3. Configure ideaSIP.com
4. Configure Asterlink.com 4. Configure Asterlink.com
5. Configure SIPBroker.com 5. Configure SIPBroker.com
6. Configure voipuser.org
X. Exit X. Exit
WELCOME WELCOME
; ;
print "Which provider do you wish to setup? "; print "Which provider do you wish to setup? ";
my $i = <STDIN>; my $i = <STDIN>;
chomp($i); chomp($i);
if ($i =~ m/X|x/) { if ($i =~ m/X|x/) {
print "Thanks you!\n"; exit; print "Thanks you!\n"; exit;
} elsif ($i > 5) { } elsif ($i > 6) {
print "Invalid Choice\n"; &welcome; print "Invalid Choice\n"; &welcome;
} else { } else {
if (exists($providers->{$i})) { if (exists($providers->{$i})) {
configure_sip_provider($providers->{$i}); configure_sip_provider($providers->{$i});
} }
}; };
&welcome; &welcome;
} }
sub configure_sip_provider($) { sub configure_sip_provider($) {
my $provider = shift; my $provider = shift;
my $template = $TEMPLATES->{$provider}; my $template = $TEMPLATES->{$provider};
my $config; my $config;
my $check = 1; my $check = 1;
foreach $field (@{$template->{fields}}) { foreach $field (@{$template->{fields}}) {
print "\nPlease your $template->{domain} $field: "; print "\nPlease your $template->{domain} $field: ";
$tmp = "$provider" . uc($field); $tmp = "$provider" . uc($field);
$i = <STDIN>; $i = <STDIN>;
chomp($i); chomp($i);
$config->{$tmp} = $i; $config->{$tmp} = $i;
} }
while($check) { while($check) {
$check = &are_you_sure; $check = &are_you_sure;
}; };
if ($template->{type} eq "network" || $template->{type} eq "pstn") { if ($template->{type} eq "network" || $template->{type} eq "pstn") {
do_config($provider, $config); do_config($provider, $config);
} }
if ($template->{dialprefix}) { if ($template->{dialprefix}) {
enable_extension($provider, $config); enable_extension($provider, $config);
} }
print "\n\n\nConfiguration Complete!!!\n\n\n\n\n"; print "\n\n\nConfiguration Complete!!!\n\n\n\n\n";
sleep(2); sleep(2);
&welcome; &welcome;
} }
sub enable_extension($$) { sub enable_extension($$) {
my $provider = shift; my $provider = shift;
my $config = shift; my $config = shift;
my $todo = $TEMPLATES->{$provider}; my $todo = $TEMPLATES->{$provider};
copy("$PREFIX/conf/dialplan/extensions/$todo->{domain}.noload", "$PREFIX/conf/dialplan/extensions/$todo->{domain}.xml"); copy("$PREFIX/conf/dialplan/extensions/$todo->{domain}.noload", "$PREFIX/conf/dialplan/extensions/$todo->{domain}.xml");
print "\nExtension prefix $todo->{dialprefix} enabled for dialing $todo->{domain}...\n"; print "\nExtension prefix $todo->{dialprefix} enabled for dialing $todo->{domain}...\n";
} }
sub do_config($$) { sub do_config($$) {
my $provider = shift; my $provider = shift;
my $config = shift; my $config = shift;
my $todo = $TEMPLATES->{$provider}; my $todo = $TEMPLATES->{$provider};
open(TEMPLATE, "<$PREFIX/conf/directory/default/$todo->{domain}.noload"); open(TEMPLATE, "<$PREFIX/conf/directory/default/$todo->{domain}.noload");
@lines = <TEMPLATE>; @lines = <TEMPLATE>;
close(TEMPLATE); close(TEMPLATE);
open(CONFIG, ">$PREFIX/conf/directory/default/$todo->{domain}.xml"); open(CONFIG, ">$PREFIX/conf/directory/default/$todo->{domain}.xml");
foreach $line (@lines) { foreach $line (@lines) {
foreach $key (sort keys %{$config}) { foreach $key (sort keys %{$config}) {
$line =~ s/%$key%/$config->{$key}/g; $line =~ s/%$key%/$config->{$key}/g;
}
print CONFIG $line;
} }
print CONFIG $line; close(CONFIG);
} print "Config Created...\n";
close(CONFIG);
print "Config Created...\n";
} }
sub are_you_sure { sub are_you_sure {
my $sure = 1; my $sure = 1;
while($sure) { while($sure) {
print "Are you sure? (yes/no)"; print "Are you sure? (yes/no)";
$i = <STDIN>; $i = <STDIN>;
chomp($i); chomp($i);
if($i =~ m/No|no|NO|n/) { if($i =~ m/No|no|NO|n/) {
&welcome; &welcome;
} elsif ($i =~ m/Yes|yes|YES|y/) { } elsif ($i =~ m/Yes|yes|YES|y/) {
return 0; return 0;
}
} }
}
} }
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论