]> piware.de Git - bin.git/commitdiff
add backup/restore scripts
authormartin@piware.de <>
Thu, 19 Oct 2006 11:25:00 +0000 (13:25 +0200)
committermartin@piware.de <>
Thu, 19 Oct 2006 11:25:00 +0000 (13:25 +0200)
postinst-setup [new file with mode: 0755]
preinst-backup [new file with mode: 0755]

diff --git a/postinst-setup b/postinst-setup
new file mode 100755 (executable)
index 0000000..b2dcf2e
--- /dev/null
@@ -0,0 +1,75 @@
+#!/bin/sh -e
+
+# install already shipped debs
+[ -e /mirror ] || ln -s /home/ubuntu-mirror /mirror
+mount -o loop /home/martin/download/ubuntu/edgy-alternate-amd64.iso /cdrom
+apt-cdrom -m add
+DEBIAN_FRONTEND=noninteractive apt-get -y install build-essential fakeroot devscripts mutt postfix openssh-server
+
+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
+
+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
+
+# 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
+
+newaliases
+/etc/init.d/postfix restart
+
+# install users
+cat <<EOF >> /etc/passwd
+joe:x:1001:1001:Joe User,,,:/home/joe:/bin/bash
+netti:x:1002:1002:Annett Kittel,,,:/home/netti:/bin/bash
+EOF
+cat <<EOF >> /etc/shadow
+joe:$1$7t1pZTyL$lI7.B/9DtPa6y2BD8wTNZ/:13060:0:99999:7:::
+netti:$1$5uq6X7u0$92yOfMH2Nh89Ui.hbaEDp/:12930:0:99999:7:::
+EOF
+cat <<EOF >> /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
+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/
+
+# copy apt cache
+if [ -d /home/aptcache ]; then
+    find /home/aptcache/ -name "*.deb" -exec cp '{}' /var/cache/apt/archives/ \;
+fi
+
+# other setup
+dpkg -i /home/martin/download/libdvdcss2_*deb || true
+locale-gen ru_RU ru_RU.UTF-8
+
+# install packages from network sources
+apt-get update
+apt-get install -y --force-yes vim bzr bzrtools python-paramiko patchutils offlineimap gnumeric wipe gnome-gpg diffstat dchroot tetex-extra latex-ucs workrave gtimelog pibackup jigdo-file libtool devhelp python-doc perl-doc manpages-dev transfig gstreamer0.10-plugins-ugly gstreamer0.10-plugins-bad gstreamer0.10-plugins-bad-multiverse gstreamer0.10-plugins-ugly-multiverse gstreamer0.10-ffmpeg xchat nvidia-glx debmirror dpatch wdiff dhcp3-server grep-dctrl ccache subversion listadmin
+apt-get -y build-dep postgresql-8.1 gnome-volume-manager hal pmount cupsys
+
+# other setup
+nvidia-glx-config enable
+ifdown eth1
+ifup eth1
+/etc/init.d/dhcp3-server restart
diff --git a/preinst-backup b/preinst-backup
new file mode 100755 (executable)
index 0000000..23d2b88
--- /dev/null
@@ -0,0 +1,14 @@
+#!/bin/sh -ex
+
+CURBACKUP=`ls -t /var/backups/pibackup/full* | head -n 1`
+[ -e "$CURBACKUP" ] || {
+    echo no current full backup in /var/backups/pibackup
+    exit 1
+}
+cp $CURBACKUP /home/
+
+apt-get autoclean
+mkdir -p /home/aptcache
+rm -rf /home/aptcache/*
+cp /var/cache/apt/archives/*.deb /home/aptcache/
+