summaryrefslogtreecommitdiffstats
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
parent861099c1f2fab024ac279280968082b953f77cc6 (diff)
downloaddrakx-backup-do-not-use-d6c7a21b97fb99c73fd7e2a831371f053e474be6.tar
drakx-backup-do-not-use-d6c7a21b97fb99c73fd7e2a831371f053e474be6.tar.gz
drakx-backup-do-not-use-d6c7a21b97fb99c73fd7e2a831371f053e474be6.tar.bz2
drakx-backup-do-not-use-d6c7a21b97fb99c73fd7e2a831371f053e474be6.tar.xz
drakx-backup-do-not-use-d6c7a21b97fb99c73fd7e2a831371f053e474be6.zip
have system configuration files automagically saved on the usb key with dnotify and a script
-rw-r--r--move/Makefile2
-rw-r--r--move/data/keyfiles91
-rwxr-xr-xmove/etc-monitorer.pl20
-rw-r--r--move/move.pm15
-rw-r--r--move/todo3
5 files changed, 42 insertions, 89 deletions
diff --git a/move/Makefile b/move/Makefile
index b7c9af57f..916260f69 100644
--- a/move/Makefile
+++ b/move/Makefile
@@ -5,6 +5,7 @@ DEST_STAGE2 = $(DEST_LIVETREE)/usr/bin/stage2
ISO = /BIG/mdkmove.iso
DATA_FILES = devices symlinks directories-to-create etcfiles all-etcfiles keyfiles README.adding.more.files
+PROGRAM_FILES = etc-monitorer.pl
LANG_FILES = $(shell perl -ne 'print $$1 if /ALLOWED_LANGS = qw\((.*)\)/' move.pm)
STAGE1 = ../mdk-stage1
@@ -38,6 +39,7 @@ install: build
sudo mkdir -p $(DEST_STAGE2)
sudo cp -f *.pm $(DEST_STAGE2)
sudo cp -f $(addprefix $(INSTALL)/, $(INSTALL_FILES)) $(DEST_STAGE2)
+ sudo cp -f $(PROGRAM_FILES) $(DEST_LIVETREE)/usr/bin
sudo rm -rf $(DEST_LIVETREE)/usr/share/langs
sudo mkdir -p $(DEST_LIVETREE)/usr/share/langs
diff --git a/move/data/keyfiles b/move/data/keyfiles
index c5fd00525..ca3e639c4 100644
--- a/move/data/keyfiles
+++ b/move/data/keyfiles
@@ -5,90 +5,15 @@
/etc/passwd
/etc/resolv.conf
/etc/sudoers
-/etc/cups/classes.conf
-/etc/cups/client.conf
-/etc/cups/command.types
-/etc/cups/cupsd.conf
-/etc/cups/mime.convs
-/etc/cups/mime.types
-/etc/cups/printers.conf
-/etc/cups/pstoraster.convs
-/etc/devfs/conf.d/dynamic.conf
-/etc/profile.d/10lang.csh
-/etc/profile.d/10lang.sh
-/etc/profile.d/alias.csh
-/etc/profile.d/alias.sh
-/etc/profile.d/configure_keyboard.sh
-/etc/profile.d/glib20.csh
-/etc/profile.d/glib20.sh
-/etc/profile.d/inputrc.csh
-/etc/profile.d/inputrc.sh
-/etc/profile.d/kde3.sh
-/etc/profile.d/msec.csh
-/etc/profile.d/msec.sh
-/etc/profile.d/qtdir3.csh
-/etc/profile.d/qtdir3.sh
-/etc/profile.d/screen.sh
-/etc/profile.d/ssh-client.sh
-/etc/profile.d/tmpdir.csh
-/etc/profile.d/tmpdir.sh
-/etc/profile.d/xhost.csh
-/etc/profile.d/xhost.sh
-/etc/sysconfig/alsa
-/etc/sysconfig/autofsck
-/etc/sysconfig/autologin
-/etc/sysconfig/bootsplash
-/etc/sysconfig/harddisks
-/etc/sysconfig/i18n
-/etc/sysconfig/init
-/etc/sysconfig/installkernel
-/etc/sysconfig/msec
-/etc/sysconfig/rawdevices
-/etc/sysconfig/suspend
-/etc/sysconfig/syslog
-/etc/sysconfig/usb
-/etc/sysconfig/userdrake
-/etc/sysconfig/xinetd
-/etc/sysconfig/console/consolefonts/lat0-16.psf.gz
-/etc/sysconfig/console/consoletrans/iso15.acm.gz
-/etc/sysconfig/console/consoletrans/iso15.sfm.gz
+/etc/cups/*
+/etc/devfs/conf.d/*
+/etc/profile.d/*
+/etc/sysconfig/*
+/etc/sysconfig/console/consolefonts/*
+/etc/sysconfig/console/consoletrans/*
/etc/sysconfig/harddrake2/previous_hw
-/etc/sysconfig/network-scripts/ifdown-aliases
-/etc/sysconfig/network-scripts/ifdown-ipv6
-/etc/sysconfig/network-scripts/ifdown-post
-/etc/sysconfig/network-scripts/ifdown-ppp
-/etc/sysconfig/network-scripts/ifdown-sit
-/etc/sysconfig/network-scripts/ifdown-sl
-/etc/sysconfig/network-scripts/ifup-aliases
-/etc/sysconfig/network-scripts/ifup-ipv6
-/etc/sysconfig/network-scripts/ifup-ipx
-/etc/sysconfig/network-scripts/ifup-plip
-/etc/sysconfig/network-scripts/ifup-plusb
-/etc/sysconfig/network-scripts/ifup-post
-/etc/sysconfig/network-scripts/ifup-ppp
-/etc/sysconfig/network-scripts/ifup-routes
-/etc/sysconfig/network-scripts/ifup-sit
-/etc/sysconfig/network-scripts/ifup-sl
-/etc/sysconfig/network-scripts/ifup-wireless
-/etc/sysconfig/network-scripts/ifcfg-eth0
-/etc/sysconfig/network-scripts/ifcfg-eth1
-/etc/sysconfig/network-scripts/ifcfg-eth2
-/etc/sysconfig/network-scripts/ifcfg-eth3
-/etc/sysconfig/network-scripts/init.ipv6-global
-/etc/sysconfig/network-scripts/network-functions
-/etc/sysconfig/network-scripts/network-functions-ipv6
-/etc/sysconfig/suspend-scripts/suspend.control
-/etc/sysconfig/suspend-scripts/suspend.d/anacron
-/etc/sysconfig/suspend-scripts/suspend.d/beep
-/etc/sysconfig/suspend-scripts/suspend.d/clock
-/etc/sysconfig/suspend-scripts/suspend.d/hddisks
-/etc/sysconfig/suspend-scripts/suspend.d/modules
-/etc/sysconfig/suspend-scripts/suspend.d/network
-/etc/sysconfig/suspend-scripts/suspend.d/pcmcia
-/etc/sysconfig/suspend-scripts/suspend.d/services
-/etc/sysconfig/suspend-scripts/suspend.d/sound
-/etc/sysconfig/suspend-scripts/suspend.d/usb
-/etc/sysconfig/suspend-scripts/suspend.d/xfree
+/etc/sysconfig/network-scripts/*
+/etc/sysconfig/suspend-scripts/suspend.d/*
/etc/X11/XF86Config
/etc/X11/XF86Config-4
/etc/X11/XF86Config-4.old
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, $_);
+ }
+}
diff --git a/move/move.pm b/move/move.pm
index 373bf407f..d3baafbf9 100644
--- a/move/move.pm
+++ b/move/move.pm
@@ -198,9 +198,15 @@ sub key_installfiles {
eval { rm_rf $sysconf };
mkdir $sysconf;
foreach (chomp_(cat_('/image/move/keyfiles'))) {
- mkdir_p("$sysconf/" . dirname($_));
- system("cp $_ $sysconf$_");
- symlinkf("$sysconf$_", $_);
+ my $target_dir = "$sysconf/" . dirname($_);
+ mkdir_p($target_dir);
+ if (/\*$/) {
+ system("cp $_ $target_dir");
+ symlinkf("$sysconf$_", $_) foreach glob($_);
+ } else {
+ system("cp $_ $sysconf$_");
+ symlinkf("$sysconf$_", $_);
+ }
}
system("cp /image/move/README.adding.more.files /home/.sysconf");
} else {
@@ -372,6 +378,9 @@ sub install2::startMove {
output("/var/run/console/$username", 1);
run_program::run('pam_console_apply');
+ run_program::raw({ detach => 1 }, '/usr/bin/dnotify', '-MCR', '/etc', '-r', '-e', '/usr/bin/etc-monitorer.pl', '{}') or die "dnotify not found!";
+ output '/var/lib/machine_ident', machine_ident();
+
if (fork()) {
sleep 1;
log::l("DrakX waves bye-bye");
diff --git a/move/todo b/move/todo
index 224a41510..494210d70 100644
--- a/move/todo
+++ b/move/todo
@@ -45,6 +45,3 @@ have not the necessary packages and we don't want to provide)
/etc/X11/X
is a link but vfat doesn't handle links :(
-/etc/X11/XF86Config-4
- changing screen resolution doesn't get saved because file is re-created in /etc/X11, loosing link to usb-key
- -> that whole story of links just sucks, why not using a daemon or something, with the list of files to save? would probably solve most of problems.. instead of needing to modify all the programs! which is a real bad solution indeed