summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Larson <slioch@slioch.vyatta.com>2010-05-26 11:14:13 -0700
committerMichael Larson <slioch@slioch.vyatta.com>2010-05-26 11:14:13 -0700
commitfeb1fbcefdedffcec672834a04d6279b229624c3 (patch)
tree88b9088e97afd9f7e002b7ad862d1fce9d038d63
parent32942dd4bde84317490aea4b41bcb5808c4b6b65 (diff)
downloadvyatta-cfg-feb1fbcefdedffcec672834a04d6279b229624c3.tar.gz
vyatta-cfg-feb1fbcefdedffcec672834a04d6279b229624c3.zip
script that will remove migration comments from configuration file. to remove these comments from the comments in the action configuration the user should:
1) save their current configuration 2) run this script on the saved configuration 3) reload their configuration (which will strip the migration comments from the active configuration tree)
-rw-r--r--Makefile.am1
-rw-r--r--scripts/vyatta-strip-migration-comments.pl71
2 files changed, 72 insertions, 0 deletions
diff --git a/Makefile.am b/Makefile.am
index 6d3cbe1..da03a83 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -61,6 +61,7 @@ sbin_SCRIPTS += scripts/vyatta-irqaffin
sbin_SCRIPTS += scripts/vyatta-auto-irqaffin.pl
sbin_SCRIPTS += scripts/vyatta-check-typeless-node.pl
sbin_SCRIPTS += scripts/vyatta-exists
+sbin_SCRIPTS += scripts/vyatta-strip-migration-comments.pl
share_perl5_DATA = lib/Vyatta/Config.pm
share_perl5_DATA += lib/Vyatta/Misc.pm
diff --git a/scripts/vyatta-strip-migration-comments.pl b/scripts/vyatta-strip-migration-comments.pl
new file mode 100644
index 0000000..6bc6152
--- /dev/null
+++ b/scripts/vyatta-strip-migration-comments.pl
@@ -0,0 +1,71 @@
+#!/usr/bin/perl
+
+# Author: Michael Larson <mike@vyatta.com>
+# Date: 2010
+# Description: Perl script for activating/deactivating portions of the configuration
+
+# **** License ****
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License version 2 as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# This code was originally developed by Vyatta, Inc.
+# Portions created by Vyatta are Copyright (C) 2006, 2007, 2008, 2009, 2010 Vyatta, Inc.
+# All Rights Reserved.
+# **** End License ****
+
+use strict;
+use warnings;
+
+
+# Looking for a comment something like this...
+#
+# /* --- CONFIGURATION COMMENTED OUT DURING MIGRATION BELOW ---
+# resp-time 5
+# --- CONFIGURATION COMMENTED OUT DURING MIGRATION ABOVE --- */
+#
+#
+#
+
+my $file = $ARGV[0];
+
+if (!defined $file) {
+ $file = "/opt/vyatta/etc/config/config.boot";
+}
+
+print "copying original configuration file to $file.boot.strip-migration-comments-bu\n";
+`cp $file $file.boot.strip-migration-comments-bu`;
+
+open(MYINPUTFILE, "<$file")
+ or die "Error! Unable to open file for input \"$file\". $!";
+
+my $contents = "";
+my $in_mig_com = 0;
+while(<MYINPUTFILE>) {
+ if ($_ =~ /CONFIGURATION COMMENTED OUT DURING MIGRATION BELOW/) {
+ $in_mig_com = 1;
+ }
+ elsif ($_ =~ /CONFIGURATION COMMENTED OUT DURING MIGRATION ABOVE/) {
+ $in_mig_com = 0;
+ }
+ elsif ($in_mig_com == 1) {
+ #do nothing here
+ }
+ else {
+ $contents .= $_;
+ }
+}
+close(MYINPUTFILE);
+
+open(MYOUTPUTFILE, ">$file")
+ or die "Error! Unable to open file for output \"$file\". $!";
+
+print MYOUTPUTFILE $contents;
+close(MYOUTPUTFILE);
+
+print "done\n";