3
# Copyright (c) 2008 Zivios, LLC.
5
# This file is part of Zivios.
7
# Zivios is free software: you can redistribute it and/or modify
8
# it under the terms of the GNU General Public License as published by
9
# the Free Software Foundation, either version 3 of the License, or
10
# (at your option) any later version.
12
# Zivios is distributed in the hope that it will be useful,
13
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
17
# You should have received a copy of the GNU General Public License
18
# along with Zivios. If not, see <http://www.gnu.org/licenses/>.
21
# @copyright Copyright (c) 2008 Zivios, LLC. (http://www.zivios.org)
22
# @license http://www.zivios.org/legal/license
23
# @version $Id: addattendant 1019 2008-09-08 07:26:34Z gmustafa $
25
use lib "/opt/zivios/asterisk/lib";
31
GetOptions ("name:s" => \$name,
32
"secret=s" => \$secret,
33
"authuser:s" => \$authuser,
35
"username:s" => \$username,
36
"fromdomain:s" => \$fromdomain,
37
"fromuser:s" => \$fromuser,
39
"callerid:s" => \$callerid,
42
"context:s" => \$context,
43
"mailbox:s" => \$mailbox,
44
"allow=s" => \$allowc,
45
"insecure:s" => \$insecure,
46
"canreinvite:s" => \$canreinvite,
48
"qualify:s" => \$qualify,
49
"expiry:s" => \$expiry,
50
"dtmfmode:s" => \$dtmfmode,
52
"callgroup:i" => \$callgroup,
53
"pickupgroup:i" => \$pickupgroup,
55
"register" => \$register);
58
@allow = split(' ',$allowc);
60
my $rc = new Asterisk::config(file=>'/etc/asterisk/sip.conf',keep_resource_array=>0);
62
$rc->assign_addsection(section=>$username);
63
$rc->assign_append(point=>'foot',section=>$username,data=>"secret=$secret");
64
$rc->assign_append(point=>'foot',section=>$username,data=>"type=$type");
65
$rc->assign_append(point=>'foot',section=>$username,data=>"host=$host");
66
$rc->assign_append(point=>'foot',section=>$username,data=>"context=$context");
67
$rc->assign_append(point=>'foot',section=>$username,data=>"disallow=all");
69
$rc->assign_append(point=>'foot',section=>$username,data=>"allow=$_");
71
if ($callgroup ne "") { $rc->assign_append(point=>'foot',section=>$username,data=>"callgroup=$callgroup"); }
72
if ($port ne "") { $rc->assign_append(point=>'foot',section=>$username,data=>"port=$port"); }
73
if ($pickupgroup ne "") { $rc->assign_append(point=>'foot',section=>$username,data=>"pickupgroup=$pickupgroup"); }
74
if ($callerid ne "") { $rc->assign_append(point=>'foot',section=>$username,data=>"callerid=$callerid"); }
75
if ($mailbox ne "") { $rc->assign_append(point=>'foot',section=>$username,data=>"mailbox=".$mailbox."\@default"); }
76
if ($qualify ne "") { $rc->assign_append(point=>'foot',section=>$username,data=>"qualify=$qualify"); }
77
if ($expiry ne "") { $rc->assign_append(point=>'foot',section=>$username,data=>"expiry=$expiry"); }
78
if ($nat ne "") { $rc->assign_append(point=>'foot',section=>$username,data=>"nat=$nat"); }
79
if ($insecure ne "") { $rc->assign_append(point=>'foot',section=>$username,data=>"insecure=$insecure"); }
80
if ($fromdomain ne "") { $rc->assign_append(point=>'foot',section=>$username,data=>"fromdomain=$fromdomain"); }
81
if ($fromuser ne "") { $rc->assign_append(point=>'foot',section=>$username,data=>"fromuser=$fromuser"); }
82
if ($username ne "") { $rc->assign_append(point=>'foot',section=>$username,data=>"username=$username"); }
83
if ($dtmfmode ne "") { $rc->assign_append(point=>'foot',section=>$username,data=>"dtmfmode=$dtmfmode"); }
84
if ($canreinvite ne "") { $rc->assign_append(point=>'foot',section=>$username,data=>"canreinvite=$canreinvite"); }
85
if ($auth ne "") { $rc->assign_append(point=>'foot',section=>$username,data=>"auth=$auth"); }
86
if ($authuser ne "") { $rc->assign_append(point=>'foot',section=>$username,data=>"authuser=$authuser"); }
89
$rc->assign_append(point=>'foot',section=>'general',data=>"register => ".$username.":".$secret."\@".$host."/".$username);
91
my $rcexten = new Asterisk::config(file=>'/etc/asterisk/extensions.conf',keep_resource_array=>0);
93
$rcexten->assign_append(point=>'foot',section=>'globals',data=>"TRUNK_". $name . "=SIP/".$username);
94
$rcexten->assign_addsection(section=>$context);
97
$rcexten->assign_append(point=>'foot',section=>'internal',data=>"exten => ".$exten.",1,Macro(sip-vm)");
100
$rcexten->save_file();