summaryrefslogtreecommitdiffstats
path: root/move/etc-monitorer.pl
diff options
context:
space:
mode:
authorGuillaume Cottenceau <gc@mandriva.com>2003-11-18 14:45:08 +0000
committerGuillaume Cottenceau <gc@mandriva.com>2003-11-18 14:45:08 +0000
commitd6c7a21b97fb99c73fd7e2a831371f053e474be6 (patch)
tree7e58840a66586310ac9b8161f84cefa068d46e7e /move/etc-monitorer.pl
parent861099c1f2fab024ac279280968082b953f77cc6 (diff)
downloaddrakx-d6c7a21b97fb99c73fd7e2a831371f053e474be6.tar
drakx-d6c7a21b97fb99c73fd7e2a831371f053e474be6.tar.gz
drakx-d6c7a21b97fb99c73fd7e2a831371f053e474be6.tar.bz2
drakx-d6c7a21b97fb99c73fd7e2a831371f053e474be6.tar.xz
drakx-d6c7a21b97fb99c73fd7e2a831371f053e474be6.zip
have system configuration files automagically saved on the usb key with dnotify and a script
Diffstat (limited to 'move/etc-monitorer.pl')
-rwxr-xr-xmove/etc-monitorer.pl20
1 files changed, 20 insertions, 0 deletions
diff --git a/move/etc-monitorer.pl b/move/etc-monitorer.pl
new file mode 100755
index 000000000..e28e06dc1
--- /dev/null
+++ b/move/etc-monitorer.pl
@@ -0,0 +1,20 @@
+#!/usr/bin/perl
+
+use MDK::Common;
+
+sub outpend { my $f = shift; local *F; open F, ">>$f" or die "outpend in file $f failed: $!\n"; print F foreach @_ }
+sub logit { outpend "/var/log/etc-monitorer.log", sprintf("[%s] @_\n", chomp_(`date`)) }
+
+my $machine_ident = cat_('/var/lib/machine_ident');
+my $sysconf = "/home/.sysconf/$machine_ident";
+
+foreach (glob("$ARGV[0]/*")) {
+ next if $_ eq '/etc/sudoers'; #- /etc/sudoers can't be a link
+ if (-f && !-l) {
+ my $dest = "/home/.sysconf/$machine_ident$_";
+ mkdir_p(dirname($dest)); #- case of newly created directories
+ logit("restoring broken symlink $_ -> $dest");
+ system("mv $_ $dest");
+ symlink($dest, $_);
+ }
+}