[go: up one dir, main page]

Menu

[r170]: / utils / pac_from_mcm.pl  Maximize  Restore  History

Download this file

86 lines (65 with data), 2.6 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#!/usr/bin/perl
###################################################################
# This file is part of PAC( Perl Auto Connector)
#
# Copyright (C) 2010-2014 David Torrejon Vaquerizas
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
###################################################################
$|++;
###################################################################
# START: Import Modules
BEGIN
{
use FindBin qw ( $RealBin $Bin $Script );
push( @INC, $RealBin . '/../lib' );
}
# Standard
use strict;
use warnings;
use YAML qw ( LoadFile DumpFile );
# PAC modules
use PACUtils;
# END: Import Modules
###################################################################
###################################################################
# START: Define GLOBAL variables
my %CFG;
# END: Define GLOBAL variables
###################################################################
my $in_file = shift or die "ERROR: You must provide an input file!!";
my $out_file = shift or die "ERROR: You must provide an outpout file!!";
open( F_IN, $in_file ) or die "ERROR: Could not open input file '$in_file' for reading ($!)";
my @lines = <F_IN>;
close F_IN;
my $header = shift( @lines );
_cfgSanityCheck( \%CFG );
$CFG{'defaults'}{'version'} = '1';
foreach my $line ( @lines )
{
chomp $line;
$line =~ s/^\"|\"$//go;
my @fields = split( /\"*,\"*/o, $line );
$CFG{'environments'}{$fields[8]}{$fields[0]}{'description'} = $fields[9];
$CFG{'environments'}{$fields[8]}{$fields[0]}{'title'} = $fields[0];
$CFG{'environments'}{$fields[8]}{$fields[0]}{'ip'} = $fields[3];
$CFG{'environments'}{$fields[8]}{$fields[0]}{'port'} = $fields[4];
$CFG{'environments'}{$fields[8]}{$fields[0]}{'user'} = $fields[5];
$CFG{'environments'}{$fields[8]}{$fields[0]}{'pass'} = $fields[6];
$CFG{'environments'}{$fields[8]}{$fields[0]}{'method'} = lc( $fields[1] );
}
_cfgSanityCheck( \%CFG );
_cipherCFG( \%CFG );
DumpFile( $out_file, \%CFG );
exit 0;