From 74c6686b582fee0a5d8d6a19d1af9c6384093624 Mon Sep 17 00:00:00 2001 From: Daniil Baturin Date: Fri, 20 Jun 2014 11:01:41 +0700 Subject: Add ovpnbundle.pl --- admin-tools/README | 2 +- admin-tools/ovpnbundle.pl | 81 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 82 insertions(+), 1 deletion(-) create mode 100755 admin-tools/ovpnbundle.pl diff --git a/admin-tools/README b/admin-tools/README index 7d72e55..d2da1fe 100755 --- a/admin-tools/README +++ b/admin-tools/README @@ -3,5 +3,5 @@ This directory is for administration tools. Files: ravpnlist.pl Export remote-acces VPN user list to plain text or CSV. dhcpremember.pl Generate static mapping commands from DHCP leases. - +ovpnbundle.pl Join OpenVPN config, CA, client cert, and client key into one file. diff --git a/admin-tools/ovpnbundle.pl b/admin-tools/ovpnbundle.pl new file mode 100755 index 0000000..2b753d6 --- /dev/null +++ b/admin-tools/ovpnbundle.pl @@ -0,0 +1,81 @@ +#!/usr/bin/env perl +# +# Removes private information from Vyatta config files. +# +# Copyright (C) 2014 Daniil Baturin +# +# Permission is hereby granted, free of charge, to any person obtaining a copy of +# this software and associated documentation files (the "Software"), to deal in +# the Software without restriction, including without limitation the rights to +# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +# of the Software, and to permit persons to whom the Software is furnished to do +# so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + + +use strict; +use warnings; + +## Bundled config template +my $template = < +__CA__ + + + +__CERT__ + + + +__KEY__ + + +EOF +## End template + +sub read_file +{ + my $file = shift; + open(FILE, $file) or die "Can't read file $file [$!]\n"; + my $contents = do { local $/; }; + close (FILE); + return($contents); +} + +## main() +if( $#ARGV != 3 ) +{ + die("Usage: $0 "); +} + +my $config_file = $ARGV[0]; +my $ca_file = $ARGV[1]; +my $cert_file = $ARGV[2]; +my $key_file = $ARGV[3]; + +## Read files +my $config = read_file($config_file); +my $ca = read_file($ca_file); +my $cert = read_file($cert_file); +my $key = read_file($key_file); + +## Process the template +$template =~ s/__CONFIG__/$config/; +$template =~ s/__CA__/$ca/; +$template =~ s/__CERT__/$cert/; +$template =~ s/__KEY__/$key/; + +print $template; -- cgit v1.2.3