From 85fa0483ffeaf672f394c395b174baa4791bad0a Mon Sep 17 00:00:00 2001 From: Guillaume Cottenceau Date: Thu, 20 Nov 2003 17:47:22 +0000 Subject: etc-monitorer now also handles removal of files --- move/etc-monitorer.pl | 10 ++++++++-- move/move.pm | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) (limited to 'move') diff --git a/move/etc-monitorer.pl b/move/etc-monitorer.pl index fa8fa6aa5..4bb8e06ec 100755 --- a/move/etc-monitorer.pl +++ b/move/etc-monitorer.pl @@ -9,14 +9,20 @@ my $machine_ident = cat_('/var/lib/machine_ident'); my $sysconf = "/home/.sysconf/$machine_ident"; foreach my $dir (@ARGV) { - foreach (glob_("$dir/*")) { + 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 = "/home/.sysconf/$machine_ident$_"; + my $dest = "$destdir$_"; mkdir_p(dirname($dest)); #- case of newly created directories logit("restoring broken symlink $_ -> $dest"); system("mv $_ $dest 2>/dev/null"); symlink($dest, $_); } } + foreach (difference2([ grep { -f && s/^\Q$destdir\E// } glob_("$destdir$dir/*") ], [ @etcfiles ])) { + logit("removing $destdir$_ because of deleted $_"); + unlink "$destdir$_"; + } } diff --git a/move/move.pm b/move/move.pm index 1f2760edb..a126a4b4a 100644 --- a/move/move.pm +++ b/move/move.pm @@ -452,7 +452,7 @@ sub install2::startMove { if (cat_('/proc/mounts') =~ m|\s/home\s|) { output '/var/lib/machine_ident', machine_ident(); run_program::run('/usr/bin/etc-monitorer.pl', uniq map { dirname($_) } chomp_(`find /etc -type f`)); - run_program::raw({ detach => 1 }, '/usr/bin/dnotify', '-MCR', '/etc', '-r', '-e', '/usr/bin/etc-monitorer.pl', '{}') or die "dnotify not found!"; + run_program::raw({ detach => 1 }, '/usr/bin/dnotify', '-MCRD', '/etc', '-r', '-e', '/usr/bin/etc-monitorer.pl', '{}') or die "dnotify not found!"; } #- allow user customisation of startup through /etc/rc.d/rc.local -- cgit v1.2.1