Hallo, und auch gleich vielleicht ein Lösungsvorschlag: chmod(1) kennt "--reference=file", wenn Du also ein vergleichbares System zur Hand hast und beide zeitgleich mounten kannst, sollte das damit funktionieren (mit etwas "find"-Magie...) Kannst Du den Script im Anhang versuchen, den hatte ich mir mal für einen ähnlichen Zweck gemacht. Ich weise aber ausdrücklich darauf hin, daß der Script für nichts zu gebrauchen ist, auch nicht für den eigentlichen Verwendungszweck. Du wirst also vorher ein Backup brauchen! Best regards from Dresden Viele Grüße aus Dresden Heiko Schlittermann -- SCHLITTERMANN.de ---------------------------- internet & unix support - Heiko Schlittermann HS12-RIPE ----------------------------------------- gnupg encrypted messages are welcome - key ID: 48D0359B --------------- gnupg fingerprint: 3061 CFBF 2D88 F034 E8D2 7E92 EE4E AC98 48D0 359B -
#! /usr/bin/perl # $Id: permer.pl 31 2004-09-23 06:47:35Z heiko $ # $URL: svn://svn/projects/permer/trunk/permer.pl $ # Started as a quick hack because I messed up the permissions of my /etc # and had an old(!) backup from where I wanted to restore the # permissions only. //.hs Wed, 22 Sep 2004 22:53:51 +0200 my $USAGE = <<'#'; Usage: $ME dir > FILE # save permissions to file or $ME [opts] dir < File # restore permissions from file --help --create-symlinks --verbose # use strict; use warnings; use File::Find; use File::stat; use File::Basename; use AppConfig; my @CONF = ( { CASE => 1 }, "create-symlinks" => { ARGS => "!", default => 0 }, "help" => { ARGS => "!", default => 0 }, "verbose" => { ARGS => "!", default => 0 }, ); my $ME = basename $0; my $FS = "\0|"; my $RS = "\0\n"; my $conf = new AppConfig(@CONF) or die "$ME: config problem\n"; $conf->getopt(\@ARGV); print(eval "\"$USAGE\""), exit 0 if $conf->help; die eval "\"$USAGE\"\n" if @ARGV != 1 or (-t STDIN and -t STDOUT); chdir $ARGV[0] or die "Can't chdir to $ARGV[0]: $!\n"; if (-t STDIN and !-t STDOUT) { print STDERR "backup mode..."; find({ bydepth => 1, wanted => sub { my $stat = lstat $_; warn "skipping $File::Find::name\n" if not -l $_ || -f _ || -d _; # store the relevant data, # for symlinks store the target, for all # other store the mode print join("\0|", (-l $_ ? "l" : "-"), $File::Find::name, (-l _ ? readlink($_) : sprintf("%04o", $stat->mode & 07777)), $stat->uid, $stat->gid, $stat->mtime, $stat->atime), $RS; }, }, "."); print STDERR "\n"; exit 0; } if (!-t STDIN) { -t STDOUT; # for sake of warnings print STDERR "restore mode...\n"; $/ = $RS; while (<STDIN>) { chomp; my ($type, $name, $mode, $uid, $gid, $mtime, $atime) = split /\Q$FS\E/; print "$type $name $mode $uid/$gid \n" if $conf->verbose; # do not touch existing symlinks -l $name and next; # create new symlinks? if ($type eq "l") { next if not $conf->get("create-symlinks"); symlink($mode, $name) or warn "$name: can't create symlink to $mode: $!\n"; next; } # rest -e $name or warn("missing: $name\n"), next; chmod oct($mode), $name or warn "$name: can't chmod to $mode: $!\n"; chown $uid, $gid, $name or warn "$name: can't chown to $uid:$gid: $!\n"; utime $atime, $mtime, $name or warn "$name: can't utime to $atime/$mtime: $!\n"; } print STDERR "\n"; exit 0; } # vim:sts=4 sw=4 aw ai sm:
Attachment:
signature.asc
Description: Digital signature