From d3cc83edf2ec7dc2997c07faaa58af6571cf1f5a Mon Sep 17 00:00:00 2001 From: Victor Seva Date: Fri, 5 Jul 2013 15:12:57 +0200 Subject: [PATCH] config_debug.pl: now changes the "spce." entry on /etc/hosts --- config_debug.pl | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/config_debug.pl b/config_debug.pl index 4a66c329..fa8cb1a8 100755 --- a/config_debug.pl +++ b/config_debug.pl @@ -1,26 +1,48 @@ -#!/usr/bin/perl -wCSD - +#!/usr/bin/perl +use Tie::File; use strict; use warnings; use YAML::Tiny; my $yaml = YAML::Tiny->new; my $file = "/etc/ngcp-config/config.yml"; +my @array; $yaml = YAML::Tiny->read($file) or die "File $file could not be read"; +my ($action, $domain) = @ARGV; + +$action = 'off' unless defined($action); +$domain = 'spce.test' unless defined($domain); -if ($#ARGV eq 0 && lc($ARGV[0]) eq "off") +if (lc($action) eq "off") { $yaml->[0]->{kamailio}{lb}{debug} = 'no'; $yaml->[0]->{kamailio}{proxy}{debug} = 'no'; $yaml->[0]->{checktools}{sip_check_enable} = 1; + + tie @array, 'Tie::File', '/etc/hosts' or die ('Can set test domain on /etc/hosts'); + for (@array) + { + s/\Q$domain\E\ /spce. /; + } + untie @array; + } else { $yaml->[0]->{kamailio}{lb}{debug} = 'no'; $yaml->[0]->{kamailio}{proxy}{debug} = 'yes'; $yaml->[0]->{checktools}{sip_check_enable} = 0; + + tie @array, 'Tie::File', '/etc/hosts' or die ('Can set test domain on /etc/hosts'); + for (@array) + { + s/spce\.\s+/$domain /; + } + untie @array; } open(my $fh, '>', "$file") or die "Could not open $file for writing"; print $fh $yaml->write_string() or die "Could not write YAML to $file"; + +#EOF