Browse Source

TT#72350 read default values from config file

Change-Id: I0b6c0e6e6e43c1df3b9ede1c711a5f83bd4543f6
(cherry picked from commit 83f2cb03d8)
changes/24/36424/1
Richard Fuchs 6 years ago
parent
commit
0b4a03d4f7
1 changed files with 18 additions and 0 deletions
  1. +18
    -0
      utils/rtpengine-ctl

+ 18
- 0
utils/rtpengine-ctl View File

@ -5,16 +5,34 @@ use warnings;
use IO::Socket::INET;
use Getopt::Long;
use Config::Tiny;
my $ip;
my $port;
my $conffile = '/etc/rtpengine/rtpengine.conf';
my $listen;
my $optret = GetOptions(
'help|h' => sub { showusage(); exit 0; },
'ip=s' => \$ip,
'port=i' => \$port,
'config-file=s' => \$conffile,
);
if (-f $conffile) {
my $config = Config::Tiny->read($conffile);
$config or die "Failed to read config file: " . Config::Tiny->errstr;
$listen = $config->{rtpengine}{'listen-cli'}
if $config->{rtpengine};
if ($listen =~ /^\d+$/) {
$port //= $listen;
}
else {
$ip //= $listen;
}
}
if ($ip && $ip =~ s/:(\d+)$//) {
$port = $1;
}


Loading…
Cancel
Save