一个简单的auth perl程序

来源:互联网 发布:js div显示隐藏 编辑:程序博客网 时间:2024/04/30 15:46

my @in_ip_yd=qw(....);
my @out_ip_yd=(....);

sub sync_auth_yd

{
    my ($in_ip,$out_ip) = @_; 
    my @in_ip = @$in_ip;
    my @out_ip = @$out_ip;
    foreach $var (@out_ip)
    {   
        my(undef,undef,$tmp,$out_suffix)= split /\./,$var;
        foreach $j (@in_ip)
        {   
            my(undef,undef,undef,$in_suffix)= split /\./,$j;
            if($in_suffix == $out_suffix)
            {   
                if(! -e $in_suffix)
                {   
                    mkdir $in_suffix or die "cannot make $in_suffix directory:$!\n";
                }   
                open $template,"<","auth_config.cnf.template";
                open $cnf,">","$in_suffix/auth_config.cnf";
                while(<$template>)
                {   
                    s/\$outip/$var/;
                    s/\$inip/$j/;
                    s/\$cliinip/$j/;
                    s/\$mport/10400/;
                    s/\$idc/1/;
                    s/\$port/4828/;
                    if($in_suffix == 97) 
                    {   
                        s/max_connection = 30000/max_connection = 20000/;
                        s/max_wait_list = 22000/max_wait_list = 19000/;

                    }   

               print $cnf $_;
                }
                close $template;
                close $cnf;
                #$tmp=`rsync -z $in_suffix/auth_config.cnf $j::gwconf/redis.rc --port=7874`;
                unlink "$in_suffix/auth_config.cnf";
                rmdir $in_suffix
            }
        }
    }
}

sync_auth_yd(\@in_ip_yd,\@out_ip_yd);

0 0
原创粉丝点击