summaryrefslogtreecommitdiffstats
path: root/move/etc-monitorer.pl
diff options
context:
space:
mode:
authorGuillaume Cottenceau <gc@mandriva.com>2003-11-21 22:23:41 +0000
committerGuillaume Cottenceau <gc@mandriva.com>2003-11-21 22:23:41 +0000
commit1c852901b124332c59277c13d315ea89eb59cc46 (patch)
tree7d4e69a00e9c4069fa5197ec046751c5dc7bd56a /move/etc-monitorer.pl
parent827addd21daaf25826f1c3881862c7895b66f879 (diff)
downloaddrakx-backup-do-not-use-1c852901b124332c59277c13d315ea89eb59cc46.tar
drakx-backup-do-not-use-1c852901b124332c59277c13d315ea89eb59cc46.tar.gz
drakx-backup-do-not-use-1c852901b124332c59277c13d315ea89eb59cc46.tar.bz2
drakx-backup-do-not-use-1c852901b124332c59277c13d315ea89eb59cc46.tar.xz
drakx-backup-do-not-use-1c852901b124332c59277c13d315ea89eb59cc46.zip
handle relative symlinks too
Diffstat (limited to 'move/etc-monitorer.pl')
-rwxr-xr-xmove/etc-monitorer.pl18
1 files changed, 12 insertions, 6 deletions
diff --git a/move/etc-monitorer.pl b/move/etc-monitorer.pl
index 4bb8e06ec..ccbbfde00 100755
--- a/move/etc-monitorer.pl
+++ b/move/etc-monitorer.pl
@@ -12,14 +12,20 @@ foreach my $dir (@ARGV) {
my $destdir = "/home/.sysconf/$machine_ident";
my @etcfiles = glob_("$dir/*");
foreach (@etcfiles) {
- next if $_ eq '/etc/sudoers'; #- /etc/sudoers can't be a link
- if (-f && !-l) {
- my $dest = "$destdir$_";
- mkdir_p(dirname($dest)); #- case of newly created directories
- logit("restoring broken symlink $_ -> $dest");
+ if ($_ eq '/etc/sudoers' #- /etc/sudoers can't be a link
+ || !-f
+ || -l && readlink =~ m|^/|) { #- we want to trap relative symlinks only
+ next;
+ }
+ my $dest = "$destdir$_";
+ mkdir_p(dirname($dest)); #- case of newly created directories
+ logit("restoring broken symlink $_ -> $dest");
+ if (-l) {
+ system("cp $_ $dest 2>/dev/null");
+ } else {
system("mv $_ $dest 2>/dev/null");
- symlink($dest, $_);
}
+ symlinkf($dest, $_);
}
foreach (difference2([ grep { -f && s/^\Q$destdir\E// } glob_("$destdir$dir/*") ], [ @etcfiles ])) {
logit("removing $destdir$_ because of deleted $_");