📄 exportcerts
字号:
## OpenCA - CA Command## (c) 1998-2001 by Massimiliano Pala and OpenCA Group#### File Name: exportCerts## Brief: Export Certificates## Description: Export newly issued certificates to removable media## Parameters: my $cmdName = "exportCerts";if ( $cmd !~ /$cmdName/i ) { configError( "Wrong Command Usage ($cmd over $cmdName)!" ); exit 1;}## GNU Tar suggested for exporting Issued Certificates## to the CA. We use the GNU tar because of its availability## for all the platforms and its stability.## Get required parameters from the configuration filemy $creat = getRequired( 'CreateArchive' );my $test = getRequired( 'TestArchive' );my $dest = getRequired( 'ExportDev' );my $dir = getRequired( 'NewCertsDir' );my $cadir = getRequired( 'OpencaDir' );my ( @lastExport );## Build the right $cmd with substitution of the $dest## with the 'ExportDest' and in 'TestArchive'my $arc = $query->subVar( $creat, '$dest', $dest );my $test = $query->subVar( $test, '$dest', $dest );print startLogPage("Certificates Exporting" );print addLogSection("Certificate Exporting ... ");if( not chdir( "$dir" )) { addErrorLog( "Failed changing dir to $dir." ); closePage(); exit 1;}## Now Let's Open the Directoryopendir ( CERTS , "$dir" ) || configError("Directory NOT found $dir!"); @certsList = grep(/pem/, readdir( CERTS ) );closedir( CERTS );if( $#certsList < 0 ) { print addLogLine( "Ok." ); print addLogLine("<I><OL>No Certificates to be exported.</OL></I>"); print closeLogSection(); closePage(); exit;}$ret = `$arc *.pem 2>&1`;if( $? != 0 ) { print addErrorLog("Archiving Failed to $dest!"); print addLogLine( "$arc" ); closePage(); exit 1;}print addLogLine( "Ok." );print addPreLogLine( $ret );print closeLogSection();print addLogSection("Testing Created Archive ... ");$ret = `$test 2>&1`;if( $? != 0 ) { print addErrorLog("Check Failed on $dest!"); closePage(); exit;}print addLogLine( "Ok." );print addPreLogLine( $ret );print closeLogSection();print addLogSection ("Removing Temporary Files ... ");$ret = "";foreach $file ( @certsList ) { my $tmpLine, $line, $txt = ""; ( $tmpLine ) = ( $file =~ /([a-f\d]+)\.pem/i ); push ( @lastImport, $tmpLine ); foreach $line (@lastImport) { $txt .= "$line\n"; }; unlink( "$cadir/stuff/lastExport.txt" ); save( FILENAME=>"$cadir/stuff/lastExport.txt", DATA=>$txt ); unlink( "$dir/$file" ); $ret .= "Deleted '$dir/$file'\n";}print addLogLine( "Ok." );print addPreLogLine( $ret );print closeLogSection();closePage();1;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -