summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniil Baturin <daniil@baturin.org>2014-06-20 11:01:41 +0700
committerDaniil Baturin <daniil@baturin.org>2014-06-20 11:01:41 +0700
commit74c6686b582fee0a5d8d6a19d1af9c6384093624 (patch)
tree60d8b3286af0f6378f36e42766950c637f1ebee9
parent6b3f5362482c01d7cd7b6f9b177af6b2e19d6f9a (diff)
downloadvyos-utils-misc-74c6686b582fee0a5d8d6a19d1af9c6384093624.tar.gz
vyos-utils-misc-74c6686b582fee0a5d8d6a19d1af9c6384093624.zip
Add ovpnbundle.pl
-rwxr-xr-xadmin-tools/README2
-rwxr-xr-xadmin-tools/ovpnbundle.pl81
2 files changed, 82 insertions, 1 deletions
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 <daniil@baturin.org>
+#
+# 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 = <<EOF;
+
+__CONFIG__
+
+<ca>
+__CA__
+</ca>
+
+<cert>
+__CERT__
+</cert>
+
+<key>
+__KEY__
+</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 $/; <FILE> };
+ close (FILE);
+ return($contents);
+}
+
+## main()
+if( $#ARGV != 3 )
+{
+ die("Usage: $0 <config file> <CA cert file> <cert file> <key file>");
+}
+
+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;