aboutsummaryrefslogtreecommitdiffstats
path: root/config/snort-dev/bin
diff options
context:
space:
mode:
authorrobiscool <robrob2626@yahoo.com>2009-12-20 11:16:38 -0800
committerrobiscool <robrob2626@yahoo.com>2009-12-20 11:17:15 -0800
commitee65b76ebb2fc0ba3446381995aa6dadbb095edc (patch)
treefead73fd40a61bcf33782aeb4247a2f84a1b232d /config/snort-dev/bin
parent6102105a07880d0dafb02c33019e23fe9491ec1c (diff)
downloadpfsense-packages-ee65b76ebb2fc0ba3446381995aa6dadbb095edc.tar.gz
pfsense-packages-ee65b76ebb2fc0ba3446381995aa6dadbb095edc.tar.bz2
pfsense-packages-ee65b76ebb2fc0ba3446381995aa6dadbb095edc.zip
snort-dev, adjust xml, snort.inc and paths
Diffstat (limited to 'config/snort-dev/bin')
-rw-r--r--config/snort-dev/bin/oinkmaster_contrib/snort_rename.pl100
1 files changed, 100 insertions, 0 deletions
diff --git a/config/snort-dev/bin/oinkmaster_contrib/snort_rename.pl b/config/snort-dev/bin/oinkmaster_contrib/snort_rename.pl
new file mode 100644
index 00000000..e5f0d39e
--- /dev/null
+++ b/config/snort-dev/bin/oinkmaster_contrib/snort_rename.pl
@@ -0,0 +1,100 @@
+#!/usr/bin/perl -w
+
+#usage: rename perl_expression [files]
+my $usage = qq{rename [-v] s/pat/repl/ [filenames...]\t (c)2001 hellweg\@snark.de
+rename files read from the commandline or stdin
+
+License to use, modify and redistribute granted to each and every lifeform on
+this planet (as long as credit to hellweg\@snark.de remains). No guarantee that
+'rename' does or does not perform the way you want...
+
+} ;
+$verbose = 0 ;
+$quiet = 0 ;
+
+$op=shift || 0 ;
+if($op eq "-v") {
+ $verbose++ ; $quiet = 0 ;
+ $op=shift || 0 ;
+}
+if($op eq "-q") {
+ $quiet++ ; $verbose = 0 ;
+ $op=shift || 0 ;
+}
+if($op =~ /^-h/) {
+ print $usage; exit(0) ;
+}
+
+if(! $op) {
+ print $usage; exit(-1) ;
+}
+
+if (!@ARGV) {
+ @ARGV = <STDIN>;
+}
+
+$count=0 ;
+my($m, $d, $y, $T) ;
+for (@ARGV) {
+ chomp ;
+ if(-e $_) {
+ $was = $_;
+ if($op =~ /\$[Tdym]/) {
+ my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime((stat($_))[9]);
+ $m = sprintf("%0.2i", $mon+1);
+ $d = sprintf("%0.2i", $mday);
+ $y = $year + 1900 ;
+ $T = "$y$m$d" ;
+ }
+ eval $op;
+ die $@ if $@;
+ if(-f $_) { print("! exists already: $was -> $_ \n") unless $quiet ; }
+ else {
+ if(rename($was, $_)) {
+ print("$was -> $_\n") if $verbose ;
+ $count++;
+ } else {
+ if(/\//) {
+ # maybe we need to create dirs?
+ my $createRes = createDirs($_) ;
+ if($createRes) {
+ print("! fauled to create $createRes for $_\n")
+ unless $quiet ;
+ }
+ else { # try again
+ if(rename($was, $_)) {
+ print("$was -> $_\n") if $verbose ;
+ $count++;
+ } else {
+ print("! failed to rename $was -> $_ \n")
+ unless $quiet ;
+ }
+ }
+ }
+ else {
+ print("! failed to rename $was -> $_ \n") unless $quiet ;
+ }
+ }
+ }
+ }
+ else { print("! not found: $_ \n") ; }
+}
+print("renamed $count files\n") if $verbose ;
+
+
+sub createDirs { # return the dir we failed to create or 0
+ my $file = shift ;
+ my @dirs = split /\//, $file ;
+ pop @dirs ; # don't try to mkdir the file itself
+ my $current = "" ;
+ $current = "/" if ($file =~ /^\//) ;
+ foreach (@dirs) {
+ $current .= $_ ;
+ if(! -d $current) {
+ mkdir $current, 0700 || return $current ;
+ print "mkdir $current\n" if ($verbose) ;
+ }
+ $current .= "/" ;
+ }
+ return 0 ; # success
+}