From 74c09beca8aa508ea798a6933fe4d485cdea9f74 Mon Sep 17 00:00:00 2001 From: Martin Pitt Date: Sun, 5 Aug 2007 20:07:26 +0200 Subject: [PATCH] postinst-setup: switch from pibackup to /etc/ in bzr --- postinst-setup | 74 +++++++++++++++++++++----------------------------- 1 file changed, 31 insertions(+), 43 deletions(-) diff --git a/postinst-setup b/postinst-setup index 2f9c757..33d2741 100755 --- a/postinst-setup +++ b/postinst-setup @@ -4,55 +4,43 @@ [ -e /mirror ] || ln -s /home/ubuntu-mirror /mirror mount -o loop /home/martin/download/ubuntu/gutsy-alternate-amd64.iso /cdrom apt-cdrom -m add -DEBIAN_FRONTEND=noninteractive apt-get -y install build-essential fakeroot devscripts postfix openssh-server +DEBIAN_FRONTEND=noninteractive apt-get -y install build-essential fakeroot devscripts postfix openssh-server bzr -dpkg -i ~martin/download/afio*.deb || exit 1 - -# configuration files -mkdir -p /var/backups/pibackup/ -[ -e /home/full*.cpio ] && mv /home/full*.cpio /var/backups/pibackup/ || true +# root's ssh stuff +if [ ! -d /root/ssh ]; then + mkdir -p /root/.ssh + chmod 700 /root/.ssh + cp /home/martin/.ssh/id_dsa* /home/martin/.ssh/known_hosts /home/martin/.ssh/config /root/.ssh/ +fi -CURBACKUP=`ls -t /var/backups/pibackup/full* | head -n 1` -[ -e "$CURBACKUP" ] || { - echo no current full backup in /var/backups/pibackup - exit 1 -} -cd / -afio -iZ -y '/etc/*' -Y /etc/passwd -Y /etc/group -Y /etc/shadow -Y /etc/fstab $CURBACKUP +# restore /etc bzr branch, rescue the files we do not want to restore +# completely +cd /etc +if [ ! -d /etc/.bzr ]; then + rsync -r martin@piware.de:backup/desktop-etc/.bzr . + for i in passwd group shadow fstab; do + cp $i $i.originst + done + bzr revert --no-backup +fi # only restore dchroot part into fstab -cd /tmp -afio -iZ -y /etc/fstab $CURBACKUP -grep -A 200 "^# dchroots" /tmp/etc/fstab >> /etc/fstab -rm -rf /tmp/etc +grep -A 200 "^# dchroots" fstab >> fstab.originst +mv fstab.originst fstab -newaliases -/etc/init.d/postfix restart - -# install users -cat <> /etc/passwd -joe:x:1001:1001:Joe User,,,:/home/joe:/bin/bash -netti:x:1002:1002:Annett Kittel,,,:/home/netti:/bin/bash -EOF -cat <> /etc/shadow -joe:$1$7t1pZTyL$lI7.B/9DtPa6y2BD8wTNZ/:13060:0:99999:7::: -netti:$1$5uq6X7u0$92yOfMH2Nh89Ui.hbaEDp/:12930:0:99999:7::: -EOF -cat <> /etc/group -joe:x:1001: -netti:x:1002: -EOF - -for g in cdrom audio video plugdev scanner; do - for u in joe netti; do - adduser $u $g - done +# only restore the human users from passwd/group +for i in passwd group; do + perl -naF: -e 'print if $F[2] >= 1000 && $F[2] < 60000' $i >> $i.originst + mv $i.originst $i done -# root's ssh stuff -mkdir -p /root/.ssh -chmod 700 /root/.ssh -cp /home/martin/.ssh/id_dsa* /home/martin/.ssh/known_hosts /home/martin/.ssh/config /root/.ssh/ +# only restore some passwords from shadow +egrep 'martin|netti|test|joe' shadow >> shadow.originst +mv shadow.originst shadow + +# update postfix for new configuration +newaliases +/etc/init.d/postfix restart # copy apt cache if [ -d /home/aptcache ]; then @@ -81,7 +69,7 @@ killall apt-get || true # install packages from network sources apt-get update -o Acquire::Http::No-Cache=true -DEBIAN_FRONTEND=noninteractive apt-get install -y --force-yes vim bzr bzrtools python-paramiko patchutils offlineimap wipe gnome-gpg diffstat dchroot gtimelog pibackup jigdo-file libtool devhelp python-doc manpages-dev gstreamer0.10-plugins-ugly gstreamer0.10-plugins-bad gstreamer0.10-plugins-bad-multiverse gstreamer0.10-plugins-ugly-multiverse gstreamer0.10-ffmpeg xchat debmirror dpatch wdiff dhcp3-server grep-dctrl ccache subversion listadmin quilt apache2 python-dev cryptsetup mutt editmoin lintian +DEBIAN_FRONTEND=noninteractive apt-get install -y --force-yes vim bzrtools python-paramiko patchutils offlineimap wipe gnome-gpg diffstat dchroot gtimelog pibackup jigdo-file libtool devhelp python-doc manpages-dev gstreamer0.10-plugins-ugly gstreamer0.10-plugins-bad gstreamer0.10-plugins-bad-multiverse gstreamer0.10-plugins-ugly-multiverse gstreamer0.10-ffmpeg xchat debmirror dpatch wdiff dhcp3-server grep-dctrl ccache subversion listadmin quilt apache2 python-dev cryptsetup mutt editmoin lintian apt-get -y build-dep postgresql-8.2 gnome-volume-manager hal cupsys apport # other setup -- 2.39.2