diff options
Diffstat (limited to 'scripts/vyatta-comment-config.pl')
-rwxr-xr-x | scripts/vyatta-comment-config.pl | 92 |
1 files changed, 0 insertions, 92 deletions
diff --git a/scripts/vyatta-comment-config.pl b/scripts/vyatta-comment-config.pl deleted file mode 100755 index 5e3a315..0000000 --- a/scripts/vyatta-comment-config.pl +++ /dev/null @@ -1,92 +0,0 @@ -#!/usr/bin/perl - -# Author: Michael Larson <mike@vyatta.com> -# Date: 2010 -# Description: Perl script for adding comments to 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; -use File::Find; -use lib "/opt/vyatta/share/perl5"; -use Vyatta::Config; - - -sub usage() { - print "Usage: $0 <path>\n"; - exit 0; -} - -if ($#ARGV == 0) { - exit 0; -} - -#adjust for leaf node -my $i = 0; -my @path = @ARGV[0..$#ARGV-1]; -foreach my $elem (@path) { - $elem =~ s/\//%2F/g; - $elem =~ s/\s+/\//g; - $path[$i++] = $elem; -} -my $edit_level = "$ENV{VYATTA_EDIT_LEVEL}"; - -my $path = $edit_level . join '/', @path; - -my $full_path = "$ENV{VYATTA_TEMP_CONFIG_DIR}/$path"; - -if (! -e $full_path) { - $path = $edit_level . join '/', @path[0..$#path-1]; - my $leaf = "$ENV{VYATTA_TEMP_CONFIG_DIR}/$path/node.val"; - if (-e $leaf) { - $full_path = "$ENV{VYATTA_TEMP_CONFIG_DIR}/$path"; - } - else { - print "Configuation path is not valid\n"; - exit 0; - } -} - -my $config = new Vyatta::Config; -my @el = split('/',$edit_level); -if ($config->isTagNode([ @el, @path ])) { - print "Cannot set comment without value for this path\n"; - exit 0; -} -#scan for illegal characters here: '/*', '*/' -if ($ARGV[$#ARGV] =~ /\/\*|\*\//) { - print "illegal characters found in comment\n"; - exit 1; -} - - -if ($ARGV[$#ARGV] eq '') { - `rm -f $full_path/.comment`; -} -else { - my $cfile; - if (!open($cfile, '>', "$full_path/.comment")) { - print "Failed to set comment\n"; - exit 1; - } - print $cfile $ARGV[$#ARGV]; - close($cfile); -} - -`touch $ENV{VYATTA_TEMP_CONFIG_DIR}/.modified`; - -exit 0; |