From: srittau Date: Thu, 17 Jan 2002 05:59:25 +0000 (+0000) Subject: Auto-generate Perl scripts so the the path to the interpreter will be X-Git-Tag: point-backport-1-5-2~115 X-Git-Url: https://arthur.barton.de/gitweb/?a=commitdiff_plain;h=fbf2ec27deeb6001adf2fc59f9a1ed2556631e1f;p=netatalk.git Auto-generate Perl scripts so the the path to the interpreter will be set correctly. --- diff --git a/configure.in b/configure.in index 2f6d6ff0..526ca8a2 100644 --- a/configure.in +++ b/configure.in @@ -1,4 +1,4 @@ -dnl $Id: configure.in,v 1.149 2002-01-17 05:57:04 srittau Exp $ +dnl $Id: configure.in,v 1.150 2002-01-17 05:59:25 srittau Exp $ dnl configure.in for netatalk AC_INIT(bin/adv1tov2/adv1tov2.c) @@ -642,9 +642,17 @@ AC_OUTPUT([Makefile config/Makefile contrib/Makefile contrib/macusers/Makefile + contrib/macusers/macusers contrib/nu/Makefile + contrib/nu/nu contrib/printing/Makefile contrib/shell_utils/Makefile + contrib/shell_utils/afpd-mtab.pl + contrib/shell_utils/apple_cp + contrib/shell_utils/apple_mv + contrib/shell_utils/apple_rm + contrib/shell_utils/cleanappledouble.pl + contrib/shell_utils/netatalkshorternamelinks.pl contrib/timelord/Makefile distrib/Makefile distrib/config/Makefile diff --git a/contrib/macusers/Makefile.am b/contrib/macusers/Makefile.am index 18608bde..4d2c2944 100644 --- a/contrib/macusers/Makefile.am +++ b/contrib/macusers/Makefile.am @@ -1,5 +1,5 @@ # Makefile for contrib/macusers/ -bin_SCRIPTS = macusers +EXTRA_DIST = macusers.in README.macusers -EXTRA_DIST = $(bin_SCRIPTS) README.macusers +bin_SCRIPTS = macusers diff --git a/contrib/macusers/macusers b/contrib/macusers/macusers deleted file mode 100755 index cf194dd4..00000000 --- a/contrib/macusers/macusers +++ /dev/null @@ -1,90 +0,0 @@ -#!/usr/bin/perl - -use strict; -use Socket; -use vars qw($MAC_PROCESS $PS_STR $MATCH_STR $ASIP_PORT_NO $ASIP_PORT $LSOF); - -# Written for linux; may have to be modified for your brand of Unix. - -# Support for FreeBSD added by Joe Clarke . -# Support could probably be extended for *BSD, but I do not have Net or -# OpenBSD machines to test with. Code has also been cleaned up and made -# to compile under strict. -# -# The new lsof call should also be quicker as it does not involve a -# second pipeline. -# -# Support has also been added for 16 character usernames. - -$MAC_PROCESS = "afpd"; -if ( $^O eq "freebsd" ) { - $PS_STR = "-awwxouser,pid,ppid,start,command"; - $MATCH_STR = '(\w+)\s+(\d+)\s+(\d+)\s+([\d\w:]+)'; -} -else { - $PS_STR = "-ef"; - $MATCH_STR = '\s*(\w+)\s+(\d+)\s+(\d+)\s+\d+\s+([\d\w:]+)'; -} -$ASIP_PORT = "afpovertcp"; -$ASIP_PORT_NO = 548; - -# Change to 0 if you don't have lsof -$LSOF = 1; -my %mac = (); - -if ( $^O eq "freebsd" ) { - open( SOCKSTAT, "sockstat -4 | grep $MAC_PROCESS | grep -v grep |" ); - - while () { - next if ( $_ !~ /$MAC_PROCESS/ ); - $_ =~ /\S+\s+\S+\s+(\d+)\s+\d+\s+[\w\d]+\s+[\d\.:]+\s+([\d\.]+)/; - my ( $pid, $addr, $host ); - $pid = $1; - $addr = $2; - $host = gethostbyaddr( pack( 'C4', split ( /\./, $addr ) ), AF_INET ); - ($host) = ( $host =~ /(^[\w\d\-]+)/ ); - $mac{$pid} = $host; - } - print - "PID UID Username Name Logintime Mac\n"; - close(SOCKSTAT); -} -elsif ( $LSOF == 1 ) { - open( LSOF, "lsof -i :$ASIP_PORT |" ); - - while () { - next if ( $_ !~ /$ASIP_PORT/ ); - $_ =~ /\w+\s+(\d+).*->([\w\.-]+).*/; - my ( $pid, $host ); - $pid = $1; - $host = $2; - ($host) = ( $host =~ /(^[\w\d\-]+)/ ); - $mac{$pid} = $host; - } - print - "PID UID Username Name Logintime Mac\n"; - close(LSOF); -} -else { - print "PID UID Username Name Logintime\n"; -} - -open( PS, "ps $PS_STR |" ) || die "Unable to open a pipe to ``ps''"; - -while () { - next if ( $_ !~ /$MAC_PROCESS/ ); - my ( $user, $pid, $ppid, $time, $name, $uid, $t ); - $_ =~ /$MATCH_STR/; - $user = $1; - $pid = $2; - $ppid = $3; - $time = $4; - - if ( $ppid != 1 ) { - ( $t, $t, $uid, $t, $t, $t, $name, $t, $t ) = getpwnam($user); - printf "%-8d %-8d %-16s %-20s %-9s %s\n", $pid, $uid, $user, $name, - $time, $mac{$pid}; - } -} - -close(PS); diff --git a/contrib/macusers/macusers.in b/contrib/macusers/macusers.in new file mode 100644 index 00000000..5ef0eb22 --- /dev/null +++ b/contrib/macusers/macusers.in @@ -0,0 +1,90 @@ +#!@PERL@ + +use strict; +use Socket; +use vars qw($MAC_PROCESS $PS_STR $MATCH_STR $ASIP_PORT_NO $ASIP_PORT $LSOF); + +# Written for linux; may have to be modified for your brand of Unix. + +# Support for FreeBSD added by Joe Clarke . +# Support could probably be extended for *BSD, but I do not have Net or +# OpenBSD machines to test with. Code has also been cleaned up and made +# to compile under strict. +# +# The new lsof call should also be quicker as it does not involve a +# second pipeline. +# +# Support has also been added for 16 character usernames. + +$MAC_PROCESS = "afpd"; +if ( $^O eq "freebsd" ) { + $PS_STR = "-awwxouser,pid,ppid,start,command"; + $MATCH_STR = '(\w+)\s+(\d+)\s+(\d+)\s+([\d\w:]+)'; +} +else { + $PS_STR = "-ef"; + $MATCH_STR = '\s*(\w+)\s+(\d+)\s+(\d+)\s+\d+\s+([\d\w:]+)'; +} +$ASIP_PORT = "afpovertcp"; +$ASIP_PORT_NO = 548; + +# Change to 0 if you don't have lsof +$LSOF = 1; +my %mac = (); + +if ( $^O eq "freebsd" ) { + open( SOCKSTAT, "sockstat -4 | grep $MAC_PROCESS | grep -v grep |" ); + + while () { + next if ( $_ !~ /$MAC_PROCESS/ ); + $_ =~ /\S+\s+\S+\s+(\d+)\s+\d+\s+[\w\d]+\s+[\d\.:]+\s+([\d\.]+)/; + my ( $pid, $addr, $host ); + $pid = $1; + $addr = $2; + $host = gethostbyaddr( pack( 'C4', split ( /\./, $addr ) ), AF_INET ); + ($host) = ( $host =~ /(^[\w\d\-]+)/ ); + $mac{$pid} = $host; + } + print + "PID UID Username Name Logintime Mac\n"; + close(SOCKSTAT); +} +elsif ( $LSOF == 1 ) { + open( LSOF, "lsof -i :$ASIP_PORT |" ); + + while () { + next if ( $_ !~ /$ASIP_PORT/ ); + $_ =~ /\w+\s+(\d+).*->([\w\.-]+).*/; + my ( $pid, $host ); + $pid = $1; + $host = $2; + ($host) = ( $host =~ /(^[\w\d\-]+)/ ); + $mac{$pid} = $host; + } + print + "PID UID Username Name Logintime Mac\n"; + close(LSOF); +} +else { + print "PID UID Username Name Logintime\n"; +} + +open( PS, "ps $PS_STR |" ) || die "Unable to open a pipe to ``ps''"; + +while () { + next if ( $_ !~ /$MAC_PROCESS/ ); + my ( $user, $pid, $ppid, $time, $name, $uid, $t ); + $_ =~ /$MATCH_STR/; + $user = $1; + $pid = $2; + $ppid = $3; + $time = $4; + + if ( $ppid != 1 ) { + ( $t, $t, $uid, $t, $t, $t, $name, $t, $t ) = getpwnam($user); + printf "%-8d %-8d %-16s %-20s %-9s %s\n", $pid, $uid, $user, $name, + $time, $mac{$pid}; + } +} + +close(PS); diff --git a/contrib/nu/Makefile.am b/contrib/nu/Makefile.am index 49a307c9..3956ae4a 100644 --- a/contrib/nu/Makefile.am +++ b/contrib/nu/Makefile.am @@ -2,4 +2,4 @@ bin_SCRIPTS = nu -EXTRA_DIST = nu +EXTRA_DIST = nu.in diff --git a/contrib/nu/nu b/contrib/nu/nu deleted file mode 100755 index c3e3fec5..00000000 --- a/contrib/nu/nu +++ /dev/null @@ -1,28 +0,0 @@ -#! /usr/bin/perl -# -# $Id: nu,v 1.2 2001-05-07 12:49:19 rufustfirefly Exp $ -# -# nu - by Anders Brownworth anders@thehamptons.com -# modified by Ambrose Li -# -# shows netatalk users logged on -# -# usage: nu - -open(USERS, "-|") || exec("/bin/ps", "anucx"); - -while () { - push(@users, $1) if /^\s*(\d+)\s.*\bafpd\b/; -} - -close USERS; - -print "Netatalk users:\n---------------\n"; - -foreach $user (@users) -{ - if ($user) { # not root - ($name,$_,$_,$_,$_,$_,$gcos) = getpwuid($user); - print(defined $gcos && $gcos =~ /^([^,]+)/? $1: $name, "\n"); - } -} diff --git a/contrib/nu/nu.in b/contrib/nu/nu.in new file mode 100755 index 00000000..3755fe3e --- /dev/null +++ b/contrib/nu/nu.in @@ -0,0 +1,28 @@ +#!@PERL@ +# +# $Id: nu.in,v 1.1 2002-01-17 05:59:25 srittau Exp $ +# +# nu - by Anders Brownworth anders@thehamptons.com +# modified by Ambrose Li +# +# shows netatalk users logged on +# +# usage: nu + +open(USERS, "-|") || exec("/bin/ps", "anucx"); + +while () { + push(@users, $1) if /^\s*(\d+)\s.*\bafpd\b/; +} + +close USERS; + +print "Netatalk users:\n---------------\n"; + +foreach $user (@users) +{ + if ($user) { # not root + ($name,$_,$_,$_,$_,$_,$gcos) = getpwuid($user); + print(defined $gcos && $gcos =~ /^([^,]+)/? $1: $name, "\n"); + } +} diff --git a/contrib/shell_utils/afpd-mtab.pl b/contrib/shell_utils/afpd-mtab.pl deleted file mode 100755 index 6f7dba59..00000000 --- a/contrib/shell_utils/afpd-mtab.pl +++ /dev/null @@ -1,20 +0,0 @@ -#! /usr/bin/perl -# -# Create an afpd.mtab on standard output from the mtab-format file on standard -# input. -# -# afpd-mtab.pl < /etc/mtab > /etc/afpd.mtab -# -# Modification history: -# -# created. -- rgr, 9-Apr-01. -# - -print("# afpd.mtab, generated by afpd-mtab.pl on ", - `date`); -while (<>) { - ($device, $mount_point, $fstype) = split; - next - if $device eq 'none' || $mount_point eq '/boot'; - printf("%2d %-10s %s\n", ++$did_index, $device, $mount_point); -} diff --git a/contrib/shell_utils/afpd-mtab.pl.in b/contrib/shell_utils/afpd-mtab.pl.in new file mode 100644 index 00000000..798af378 --- /dev/null +++ b/contrib/shell_utils/afpd-mtab.pl.in @@ -0,0 +1,22 @@ +#!@PERL@ +# +# $Id: afpd-mtab.pl.in,v 1.1 2002-01-17 05:59:25 srittau Exp $ +# +# Create an afpd.mtab on standard output from the mtab-format file on standard +# input. +# +# afpd-mtab.pl < /etc/mtab > /etc/afpd.mtab +# +# Modification history: +# +# created. -- rgr, 9-Apr-01. +# + +print("# afpd.mtab, generated by afpd-mtab.pl on ", + `date`); +while (<>) { + ($device, $mount_point, $fstype) = split; + next + if $device eq 'none' || $mount_point eq '/boot'; + printf("%2d %-10s %s\n", ++$did_index, $device, $mount_point); +} diff --git a/contrib/shell_utils/apple_cp b/contrib/shell_utils/apple_cp deleted file mode 100644 index f1d7f8aa..00000000 --- a/contrib/shell_utils/apple_cp +++ /dev/null @@ -1,96 +0,0 @@ -#! /usr/bin/perl -# -# $Header: /home/ralph/netatalk/rsync/netatalk/contrib/shell_utils/Attic/apple_cp,v 1.3 2001-10-16 18:27:27 lancel Exp $ -# -# $Log: apple_cp,v $ -# Revision 1.3 2001-10-16 18:27:27 lancel -# Updated perl. -# -# Fixed a failing test where $to wasn't a directory, but -# didn't check that $from was only a single file, result file to file -# always failed. -# -# Fixed the .AppleDouble variable being sent to the split_dir_file -# function, it was mistakenly sending $from instead of $to, result cp -# $from $from, same file. -# -# Revision 1.2 2000/08/09 14:12:06 rufustfirefly -# /usr/local/bin/perl -> /usr/bin/perl and portability fixes -# -# Revision 1.1 2000/08/09 14:08:06 rufustfirefly -# Shell utils from http://www.-genome.wi.mit.edu/ftp/distribution/software/Bass/bass-1.29/apple_util/ (initial import) -# -# Revision 1.1 1996/04/03 02:13:12 lstein -# Added all these files because they're essential utilities. -# -# Revision 1.2 1996/02/09 18:44:44 will -# fix to usage string -# -# Revision 1.1 1996/02/09 18:21:35 will -# Initial revision -# -# - -$USAGE = < 1) { die $USAGE; } - -foreach $from (@from) { - if (!-f $from) { - print STDERR "file $from does not exist\n"; - die $USAGE; - } - - if (!-d $to && @from >1) { - print STDERR "directory $to does not exist\nCan't copy multiple files into one file.\n"; - die $USAGE; - } - - $cmd = "cp '$from' '$to'"; - system $cmd || die "error executing $cmd"; - - ($from_dir, $from_file) = split_dir_file($from); - - if (-d $to) { - if (!-d "$to/.AppleDouble") { - mkdir("$to/.AppleDouble", 0777); - } - $cmd = "cp '$from_dir/.AppleDouble/$from_file' '$to/.AppleDouble/$from_file'"; - } else { - ($to_dir, $to_file) = split_dir_file($to); - if (!-d "$to_dir/.AppleDouble") { - mkdir("$to_dir/.AppleDouble", 0777); - } - $cmd = "cp '$from_dir/.AppleDouble/$from_file' '$to_dir/.AppleDouble/$to_file'"; - } - - system $cmd || die "error executing $cmd"; -} - -# split a file path into a directory and file name. -sub split_dir_file { - my $path = shift; - - @path_elems = split(/\//, $path); - - my $file = pop(@path_elems); - my $dir; - if (!@path_elems) { - $dir = '.'; - } else { - $dir = join('/', @path_elems); - } - - $dir, $file; -} - - diff --git a/contrib/shell_utils/apple_cp.in b/contrib/shell_utils/apple_cp.in new file mode 100755 index 00000000..b8a75ab5 --- /dev/null +++ b/contrib/shell_utils/apple_cp.in @@ -0,0 +1,67 @@ +#!@PERL@ +# +# $Id: apple_cp.in,v 1.1 2002-01-17 05:59:25 srittau Exp $ + +$USAGE = < 1) { die $USAGE; } + +foreach $from (@from) { + if (!-f $from) { + print STDERR "file $from does not exist\n"; + die $USAGE; + } + + if (!-d $to && @from >1) { + print STDERR "directory $to does not exist\nCan't copy multiple files into one file.\n"; + die $USAGE; + } + + $cmd = "cp '$from' '$to'"; + system $cmd || die "error executing $cmd"; + + ($from_dir, $from_file) = split_dir_file($from); + + if (-d $to) { + if (!-d "$to/.AppleDouble") { + mkdir("$to/.AppleDouble", 0777); + } + $cmd = "cp '$from_dir/.AppleDouble/$from_file' '$to/.AppleDouble/$from_file'"; + } else { + ($to_dir, $to_file) = split_dir_file($to); + if (!-d "$to_dir/.AppleDouble") { + mkdir("$to_dir/.AppleDouble", 0777); + } + $cmd = "cp '$from_dir/.AppleDouble/$from_file' '$to_dir/.AppleDouble/$to_file'"; + } + + system $cmd || die "error executing $cmd"; +} + +# split a file path into a directory and file name. +sub split_dir_file { + my $path = shift; + + @path_elems = split(/\//, $path); + + my $file = pop(@path_elems); + my $dir; + if (!@path_elems) { + $dir = '.'; + } else { + $dir = join('/', @path_elems); + } + + $dir, $file; +} + + diff --git a/contrib/shell_utils/apple_mv b/contrib/shell_utils/apple_mv deleted file mode 100644 index ae5c5ded..00000000 --- a/contrib/shell_utils/apple_mv +++ /dev/null @@ -1,101 +0,0 @@ -#! /usr/bin/perl -# -# $Header: /home/ralph/netatalk/rsync/netatalk/contrib/shell_utils/Attic/apple_mv,v 1.3 2001-10-17 05:21:52 lancel Exp $ -# -# $Log: apple_mv,v $ -# Revision 1.3 2001-10-17 05:21:52 lancel -# Added error checking against multiple files to one file. Eliminated -# depreciated special variable. $ARGV($#ARGV) to $ARGV(-1) -# -# Revision 1.2 2000/08/09 14:12:06 rufustfirefly -# /usr/local/bin/perl -> /usr/bin/perl and portability fixes -# -# Revision 1.1 2000/08/09 14:08:06 rufustfirefly -# Shell utils from http://www.-genome.wi.mit.edu/ftp/distribution/software/Bass/bass-1.29/apple_util/ (initial import) -# -# Revision 1.2 1996/06/14 18:06:58 lstein -# Fixed bugs in the character escaping routines. -# -# Revision 1.2 1996/02/09 18:44:44 will -# fix to usage string -# -# Revision 1.1 1996/02/09 18:21:35 will -# Initial revision -# -# - -$USAGE = < 1) { die $USAGE; } - -foreach $from (@from) { - if (!-f $from) { - print STDERR "file $from does not exist\n"; - die $USAGE; - } - - if (!-d $to && @from >1) { - print STDERR "directory $to does not exist\nCan't move multiple files into one file.\n"; - die $USAGE; - } - - $from = escape_bad_chars($from); - $to = escape_bad_chars($to); - $cmd = "mv $from $to"; - system $cmd || die "error executing $cmd"; - - ($from_dir, $from_file) = split_dir_file($from); - - if (-d $to) { - if (!-d "$to/.AppleDouble") { - mkdir("$to/.AppleDouble", 0777); - } - $cmd = "mv $from_dir/.AppleDouble/$from_file $to/.AppleDouble/$from_file"; - } else { - ($to_dir, $to_file) = split_dir_file($to); - - if (!-d $to_dir) { - print STDERR "directory $to does not exist\n"; - die $USAGE; - } - - if (!-d "$to_dir/.AppleDouble") { - mkdir("$to_dir/.AppleDouble", 0777); - } - $cmd = "mv $from_dir/.AppleDouble/$from_file $to_dir/.AppleDouble/$to_file"; - } - - system $cmd || die "error executing $cmd"; -} - -sub escape_bad_chars { - my($file) = @_; - $file=~s/([^a-zA-Z0-9.-_])/\\$1/; - return $file; -} - -# split a file path into a directory and file name. -sub split_dir_file { - my $path = shift; - - @path_elems = split(/\//, $path); - - my $file = pop(@path_elems); - my $dir; - if (!@path_elems) { - $dir = '.'; - } else { - $dir = join('/', @path_elems); - } - - $dir, $file; -} - - diff --git a/contrib/shell_utils/apple_mv.in b/contrib/shell_utils/apple_mv.in new file mode 100755 index 00000000..79cf579f --- /dev/null +++ b/contrib/shell_utils/apple_mv.in @@ -0,0 +1,79 @@ +#!@PERL@ +# +# $Id: apple_mv.in,v 1.1 2002-01-17 05:59:25 srittau Exp $ + +$USAGE = < 1) { die $USAGE; } + +foreach $from (@from) { + if (!-f $from) { + print STDERR "file $from does not exist\n"; + die $USAGE; + } + + if (!-d $to && @from >1) { + print STDERR "directory $to does not exist\nCan't move multiple files into one file.\n"; + die $USAGE; + } + + $from = escape_bad_chars($from); + $to = escape_bad_chars($to); + $cmd = "mv $from $to"; + system $cmd || die "error executing $cmd"; + + ($from_dir, $from_file) = split_dir_file($from); + + if (-d $to) { + if (!-d "$to/.AppleDouble") { + mkdir("$to/.AppleDouble", 0777); + } + $cmd = "mv $from_dir/.AppleDouble/$from_file $to/.AppleDouble/$from_file"; + } else { + ($to_dir, $to_file) = split_dir_file($to); + + if (!-d $to_dir) { + print STDERR "directory $to does not exist\n"; + die $USAGE; + } + + if (!-d "$to_dir/.AppleDouble") { + mkdir("$to_dir/.AppleDouble", 0777); + } + $cmd = "mv $from_dir/.AppleDouble/$from_file $to_dir/.AppleDouble/$to_file"; + } + + system $cmd || die "error executing $cmd"; +} + +sub escape_bad_chars { + my($file) = @_; + $file=~s/([^a-zA-Z0-9.-_])/\\$1/; + return $file; +} + +# split a file path into a directory and file name. +sub split_dir_file { + my $path = shift; + + @path_elems = split(/\//, $path); + + my $file = pop(@path_elems); + my $dir; + if (!@path_elems) { + $dir = '.'; + } else { + $dir = join('/', @path_elems); + } + + $dir, $file; +} + + diff --git a/contrib/shell_utils/apple_rm b/contrib/shell_utils/apple_rm deleted file mode 100644 index 784ebff0..00000000 --- a/contrib/shell_utils/apple_rm +++ /dev/null @@ -1,57 +0,0 @@ -#! /usr/bin/perl -# -# $Header: /home/ralph/netatalk/rsync/netatalk/contrib/shell_utils/Attic/apple_rm,v 1.2 2000-08-09 14:12:06 rufustfirefly Exp $ -# -# $Log: apple_rm,v $ -# Revision 1.2 2000-08-09 14:12:06 rufustfirefly -# /usr/local/bin/perl -> /usr/bin/perl and portability fixes -# -# Revision 1.1 2000/08/09 14:08:06 rufustfirefly -# Shell utils from http://www.-genome.wi.mit.edu/ftp/distribution/software/Bass/bass-1.29/apple_util/ (initial import) -# -# Revision 1.1 1996/04/03 02:13:14 lstein -# Added all these files because they're essential utilities. -# -# Revision 1.1 1996/02/09 18:21:35 will -# Initial revision -# -# - -$USAGE = < -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# 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. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# - -require 5; -use Getopt::Std; - -sub usage { - print STDERR </.AppleDouble) - 2) fixes permissions on .AppleDouble files to match corresponding data file (minus x bits) - 3) fixes owner/group of .AppleDouble files to match corresponding data file (root only) - -Options: - -r Recursively check all subdirectories of each directory - -R Like -r but follows symbolic links to directories (warning: no loop-checking is done) - -p Preview: no deletions or changes are actually made - -v Verbose -EOF - exit 1; -} - -$isroot = ($> == 0); - -sub S_ISDIR { - my($mode) = @_; - return (($mode & 0170000) == 0040000); -} -sub S_ISREG { - my($mode) = @_; - return (($mode & 0170000) == 0100000); -} -sub S_ISLNK { - my($mode) = @_; - return (($mode & 0170000) == 0120000); -} - - -sub do_dir { - my($dir) = @_; - my($f, $havead, @dirlist, $mode, $uid, $gid, $fn); - my(%dm, %du, %dg); - - print STDERR "Scanning $dir ...\n" if($opt_v); - - $havead = -d "$dir/.AppleDouble"; - - # there's nothing more to do if we're not recursive and there's no .AppleDouble - return if(!$havead && !$opt_r); - - opendir DIR, $dir or do { - warn "Can't opendir $dir: $!\n"; - return; - }; - while(defined($f = readdir DIR)) { - next if($f eq "."); - next if($f eq ".."); - next if($f eq ".AppleDouble"); - next if($f eq ".AppleDesktop"); - - (undef, undef, $mode, undef, $uid, $gid) = lstat "$dir/$f"; - next if(!defined($mode)); - - if(S_ISLNK($mode)) { - (undef, undef, $mode, undef, $uid, $gid) = stat "$dir/$f"; - next if(!defined($mode)); - next if(S_ISDIR($mode) && !$opt_R); - } - if(S_ISDIR($mode)) { - push @dirlist, $f if($opt_r); - } elsif(S_ISREG($mode)) { - if($havead) { - $dm{$f} = $mode & 0666; - $du{$f} = $uid; - $dg{$f} = $gid; - } - } else { - warn "Ignoring special file: $dir/$f\n"; - } - } - closedir DIR; - - if($havead) { - if(opendir DIR, "$dir/.AppleDouble") { - while(defined($f = readdir DIR)) { - next if($f eq "."); - next if($f eq ".."); - next if($f eq ".Parent"); - - $fn = "$dir/.AppleDouble/$f"; - (undef, undef, $mode, undef, $uid, $gid) = stat $fn; - next if(!defined($mode)); - - if(S_ISDIR($mode)) { - warn "Found subdirectory $f in $dir/.AppleDouble\n"; - next; - } - unless(exists $dm{$f}) { - print STDERR "Deleting $fn ...\n" if($opt_v); - if($opt_p) { - print "rm '$fn'\n"; - } else { - unlink "$fn" or warn "Can't unlink $fn: $!\n"; - } - next; - } - $mode = $mode & 07777; - if($mode != $dm{$f}) { - printf STDERR "Changing permissions from %o to %o on $fn\n", $mode, $dm{$f} if($opt_v); - if($opt_p) { - printf "chmod %o '$fn'\n", $dm{$f}; - } else { - chmod $dm{$f}, $fn or warn "Can't chmod $fn: $!\n"; - } - } - if($isroot && ($uid != $du{$f} || $gid != $dg{$f})) { - print STDERR "Changing owner from $uid:$gid to $du{$f}:$dg{$f} on $fn\n" if($opt_v); - if($opt_p) { - print "chown $du{$f}:$dg{$f} '$fn'\n"; - } else { - chown $du{$f}, $dg{$f}, $fn or warn "Can't chown $fn: $!\n"; - } - } - } - closedir DIR; - } else { - warn "Can't opendir $dir/.AppleDouble: $!\n"; - } - } - - if($opt_r) { - foreach $f ( @dirlist ) { - do_dir("$dir/$f"); - } - } -} - -usage unless(getopts 'prRv'); -usage if(@ARGV == 0); - -if($opt_R) { - $opt_r = 1; -} - -foreach $d ( @ARGV ) { - do_dir $d; -} - diff --git a/contrib/shell_utils/cleanappledouble.pl.in b/contrib/shell_utils/cleanappledouble.pl.in new file mode 100644 index 00000000..a299349c --- /dev/null +++ b/contrib/shell_utils/cleanappledouble.pl.in @@ -0,0 +1,169 @@ +#!@PERL@ +# +# $Id: cleanappledouble.pl.in,v 1.1 2002-01-17 05:59:25 srittau Exp $ +# +# cleanappledouble.pl +# Copyright (C) 2001 Heath Kehoe +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# 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. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# + +require 5; +use Getopt::Std; + +sub usage { + print STDERR </.AppleDouble) + 2) fixes permissions on .AppleDouble files to match corresponding data file (minus x bits) + 3) fixes owner/group of .AppleDouble files to match corresponding data file (root only) + +Options: + -r Recursively check all subdirectories of each directory + -R Like -r but follows symbolic links to directories (warning: no loop-checking is done) + -p Preview: no deletions or changes are actually made + -v Verbose +EOF + exit 1; +} + +$isroot = ($> == 0); + +sub S_ISDIR { + my($mode) = @_; + return (($mode & 0170000) == 0040000); +} +sub S_ISREG { + my($mode) = @_; + return (($mode & 0170000) == 0100000); +} +sub S_ISLNK { + my($mode) = @_; + return (($mode & 0170000) == 0120000); +} + + +sub do_dir { + my($dir) = @_; + my($f, $havead, @dirlist, $mode, $uid, $gid, $fn); + my(%dm, %du, %dg); + + print STDERR "Scanning $dir ...\n" if($opt_v); + + $havead = -d "$dir/.AppleDouble"; + + # there's nothing more to do if we're not recursive and there's no .AppleDouble + return if(!$havead && !$opt_r); + + opendir DIR, $dir or do { + warn "Can't opendir $dir: $!\n"; + return; + }; + while(defined($f = readdir DIR)) { + next if($f eq "."); + next if($f eq ".."); + next if($f eq ".AppleDouble"); + next if($f eq ".AppleDesktop"); + + (undef, undef, $mode, undef, $uid, $gid) = lstat "$dir/$f"; + next if(!defined($mode)); + + if(S_ISLNK($mode)) { + (undef, undef, $mode, undef, $uid, $gid) = stat "$dir/$f"; + next if(!defined($mode)); + next if(S_ISDIR($mode) && !$opt_R); + } + if(S_ISDIR($mode)) { + push @dirlist, $f if($opt_r); + } elsif(S_ISREG($mode)) { + if($havead) { + $dm{$f} = $mode & 0666; + $du{$f} = $uid; + $dg{$f} = $gid; + } + } else { + warn "Ignoring special file: $dir/$f\n"; + } + } + closedir DIR; + + if($havead) { + if(opendir DIR, "$dir/.AppleDouble") { + while(defined($f = readdir DIR)) { + next if($f eq "."); + next if($f eq ".."); + next if($f eq ".Parent"); + + $fn = "$dir/.AppleDouble/$f"; + (undef, undef, $mode, undef, $uid, $gid) = stat $fn; + next if(!defined($mode)); + + if(S_ISDIR($mode)) { + warn "Found subdirectory $f in $dir/.AppleDouble\n"; + next; + } + unless(exists $dm{$f}) { + print STDERR "Deleting $fn ...\n" if($opt_v); + if($opt_p) { + print "rm '$fn'\n"; + } else { + unlink "$fn" or warn "Can't unlink $fn: $!\n"; + } + next; + } + $mode = $mode & 07777; + if($mode != $dm{$f}) { + printf STDERR "Changing permissions from %o to %o on $fn\n", $mode, $dm{$f} if($opt_v); + if($opt_p) { + printf "chmod %o '$fn'\n", $dm{$f}; + } else { + chmod $dm{$f}, $fn or warn "Can't chmod $fn: $!\n"; + } + } + if($isroot && ($uid != $du{$f} || $gid != $dg{$f})) { + print STDERR "Changing owner from $uid:$gid to $du{$f}:$dg{$f} on $fn\n" if($opt_v); + if($opt_p) { + print "chown $du{$f}:$dg{$f} '$fn'\n"; + } else { + chown $du{$f}, $dg{$f}, $fn or warn "Can't chown $fn: $!\n"; + } + } + } + closedir DIR; + } else { + warn "Can't opendir $dir/.AppleDouble: $!\n"; + } + } + + if($opt_r) { + foreach $f ( @dirlist ) { + do_dir("$dir/$f"); + } + } +} + +usage unless(getopts 'prRv'); +usage if(@ARGV == 0); + +if($opt_R) { + $opt_r = 1; +} + +foreach $d ( @ARGV ) { + do_dir $d; +} + diff --git a/contrib/shell_utils/netatalkshorternamelinks.pl b/contrib/shell_utils/netatalkshorternamelinks.pl deleted file mode 100755 index a0177efc..00000000 --- a/contrib/shell_utils/netatalkshorternamelinks.pl +++ /dev/null @@ -1,38 +0,0 @@ -#! /usr/bin/perl -# -# $Id: netatalkshorternamelinks.pl,v 1.2 2001-05-07 14:16:47 rufustfirefly Exp $ -# -# (c) 2000 Christian Wolff, scarabaeus@scarabaeus.org -# quick hack to create symbolic links for files with names over 31 chars long -# - -$searchpath='/data/mp3/'; -$destpath='/data/mac_mp3/'; - -# only if you dare! -`rm -rf ${destpath}*`; -foreach $f (`find $searchpath -name '*.mp3'`) { - chomp $f; - $f=~s/^$searchpath//; - if ($f=~/^(.*)\/(.*)$/) { - ($path,$file)=($1,$2); - } else { - ($path,$file)=('',$f); - } - $shortpath=''; - for $splitpath (split /\//,$path) { - if (length $splitpath > 31) { - # keep the last 2 chars of the directory name - $splitpath=substr($splitpath,0,29).substr($splitpath,-2,2); - } - $shortpath.="${splitpath}/"; - mkdir $destpath.$shortpath,0755; - } - $shortfile=$file; - if (length $file > 31) { - # keep the extension of 4 chars - $shortfile=substr($file,0,27).substr($file,-4,4); - } - `ln -sf ${searchpath}${f} ${destpath}${shortpath}${shortfile}`; -} - diff --git a/contrib/shell_utils/netatalkshorternamelinks.pl.in b/contrib/shell_utils/netatalkshorternamelinks.pl.in new file mode 100644 index 00000000..1c4f2b77 --- /dev/null +++ b/contrib/shell_utils/netatalkshorternamelinks.pl.in @@ -0,0 +1,38 @@ +#!@PERL@ +# +# $Id: netatalkshorternamelinks.pl.in,v 1.1 2002-01-17 05:59:25 srittau Exp $ +# +# (c) 2000 Christian Wolff, scarabaeus@scarabaeus.org +# quick hack to create symbolic links for files with names over 31 chars long +# + +$searchpath='/data/mp3/'; +$destpath='/data/mac_mp3/'; + +# only if you dare! +`rm -rf ${destpath}*`; +foreach $f (`find $searchpath -name '*.mp3'`) { + chomp $f; + $f=~s/^$searchpath//; + if ($f=~/^(.*)\/(.*)$/) { + ($path,$file)=($1,$2); + } else { + ($path,$file)=('',$f); + } + $shortpath=''; + for $splitpath (split /\//,$path) { + if (length $splitpath > 31) { + # keep the last 2 chars of the directory name + $splitpath=substr($splitpath,0,29).substr($splitpath,-2,2); + } + $shortpath.="${splitpath}/"; + mkdir $destpath.$shortpath,0755; + } + $shortfile=$file; + if (length $file > 31) { + # keep the extension of 4 chars + $shortfile=substr($file,0,27).substr($file,-4,4); + } + `ln -sf ${searchpath}${f} ${destpath}${shortpath}${shortfile}`; +} +