Cisco-Conf

 view release on metacpan or  search on metacpan

Makefile.PL  view on Meta::CPAN

test :: all
	\$(NOOP)

install ::
	if [ `perl -e 'print \$\$>'` -ne 0 ]; then                           \\
	    echo "Sorry, but you must be root to install this module.";      \\
	    exit 1;                                                          \\
	fi
	$perl -MFile::Path -e 'mkpath(["$etcdir", "$tftpdir"], 1, 0755)'
	chown root \$(INSTALLSCRIPT)/cisconf
	chmod 4755 \$(INSTALLSCRIPT)/cisconf
	chown root $etcdir
	chmod 700 $etcdir
	if [ -f "$etcdir/configuration" ]; then                              \\
	    echo "Not overwriting existing configfile $etcdir/configuration";\\
	else                                                                 \\
	    cp configuration "$etcdir/configuration";                        \\
	fi

EOF
}

sub libscan {

lib/Cisco/Conf.pm  view on Meta::CPAN

	local $/ = undef;
	$fh = IO::File->new($file, "r");
	if (!$fh  ||  !defined($configuration = $fh->getline())  ||
	    !$fh->close()) {
	    die "Error while reading $file: $!";
	}
    }

    my $tmpFile = $tmpDir . "/cisconf.$$";
    $fh = IO::File->new($tmpFile, "w");
    if (!$fh  ||  !chmod(0600, $tmpFile)  ||
	!chown($<, $(, $tmpFile)  ||  !$fh->print($configuration)  ||
	!$fh->flush()  ||  !$fh->close()) {
	unlink $tmpFile;
	die "Error while creating temporary file $tmpFile: $!";
    }

    my $pid = fork();
    if (!defined($pid)) {
	unlink $tmpFile;
	die "Cannot fork: $!";

lib/Cisco/Conf.pm  view on Meta::CPAN

	    $tftp_client_file = $1;
	} else {
	    print STDERR("Warning: TFTP prefix $prefix doesn't match file",
			 " name $tftp_client_file.\n");
	}
    }

    # Create an empty file $file
    my $fh;
    if (!($fh = IO::File->new($file, "w"))  ||	!$fh->close()  ||
	!chmod(0666, $file)) {
	die "Cannot create $file: $!";
    }

    my $cmd = $self->_Login();
    if (!$cmd->print("copy running-config tftp")) {
	die "Output error: $!";
    }
    $cmd->waitfor('/\[(\d+\.\d+\.\d+\.\d+)?\]\? /');
    if (!$cmd->print($self->{'_local_addr'})) {
	die "Output error: $!";

lib/Cisco/Conf.pm  view on Meta::CPAN

	if ($tftp_client_file =~ /^\Q$prefix\E(.*)/) {
	    $tftp_client_file = $1;
	} else {
	    print STDERR("Warning: TFTP prefix $prefix doesn't match file",
			 " name $tftp_client_file.\n");
	}
    }

    # Change the file permissions of $file to 0444, so that it's
    # readable by the TFTP server
    if (!chmod(0444, $file)) {
	die "Cannot make $file readable: $!";
    }

    my $cmd = $self->_Login();
    if (!$cmd->print("copy tftp running-config")) {
	die "Output error: $!";
    }
    my($prematch, $match) = 
	$cmd->waitfor('/\[(host|\d+\.\d+\.\d+\.\d+)?\]\? /');
    if ($match eq "[host]") {



( run in 0.432 second using v1.01-cache-2.11-cpan-8d75d55dd25 )