]> piware.de Git - bin.git/blob - postinst-setup
postinst-setup: some bug fixes
[bin.git] / postinst-setup
1 #!/bin/sh -e
2
3 # move backup to /var
4 if [ -d /home/martin/backup ] && [ ! -d /var/backups/martin ]; then
5     cp -a /home/martin/backup /var/backups/martin
6     rm -rf /home/martin/backup
7 fi
8
9 # install already shipped debs
10 UBUNTU_CD="/home/martin/download/ubuntu/`lsb_release -c`-alternate-`dpkg --print-architecture`.iso"
11 if [ -r "$UBUNTU_CD" ]; then
12     mount -o loop "$UBUNTU_CD" /cdrom
13     apt-cdrom -m add
14 fi
15 DEBIAN_FRONTEND=noninteractive apt-get -y install build-essential fakeroot devscripts postfix openssh-server bzr
16
17 # root's ssh stuff
18 if [ ! -d /root/.ssh ] && [ -d /home/martin/.ssh ]; then
19     mkdir -p /root/.ssh
20     chmod 700 /root/.ssh
21     cp /home/martin/.ssh/id_dsa* /home/martin/.ssh/known_hosts /home/martin/.ssh/config /root/.ssh/
22 fi
23
24 # restore /etc bzr branch, rescue the files we do not want to restore
25 # completely
26 cd /etc
27 if [ ! -d /etc/.bzr ]; then
28     for i in passwd group shadow fstab; do
29         [ -e $i.originst] || cp $i $i.originst
30     done
31     bzr get bzr+ssh://martin@piware.de/home/martin/backup/`hostname`-etc /backup-etc
32     cp -av /backup-etc/* /etc/
33     cp -av /backup-etc/.bzr/ /etc/
34     rm -rf /backup-etc
35     chmod 600 /etc/ssh/ssh_*_key
36 fi
37
38 # only restore dchroot part into fstab
39 grep -A 200 "^# dchroots" fstab >> fstab.originst || true
40 mv fstab.originst fstab
41
42 # only restore the human users from passwd/group
43 for i in passwd group; do
44     perl -naF: -e 'print if $F[2] > 1000 && $F[2] < 60000' $i >> $i.originst
45     mv $i.originst $i
46 done
47
48 # only restore some passwords from shadow
49 egrep 'martin|netti|joe' shadow >> shadow.originst
50 mv shadow.originst shadow
51
52 # update postfix for new configuration
53 newaliases
54 /etc/init.d/postfix restart
55
56 # copy apt cache
57 if [ -d /home/aptcache ]; then
58     find /home/aptcache/ -name "*.deb" -exec cp '{}' /var/cache/apt/archives/ \;
59     rm -rf /home/aptcache
60 fi
61
62 # other setup
63 dpkg -i /home/martin/download/libdvdcss2_*deb || true
64 locale-gen ru_RU ru_RU.UTF-8
65
66 # remove packages that we do not need
67 killall apt-get || true # cronjob goo
68 apt-get purge -y --auto-remove hplip brltty bluez-cups gnome-accessibility-themes gnome-mag gnome-orca onboard tomboy ttf-arabeyes ttf-arphic-uming ttf-baekmuk ttf-gentium ttf-kochi-gothic ttf-kochi-mincho ttf-lao ttf-malayalam-fonts ttf-mgopen ttf-thai-tlwg || true
69
70 rm /etc/rcS.d/*pcmcia* /etc/rcS.d/*ppp*
71
72 # install packages from network sources
73 killall apt-get || true
74 apt-get update -o Acquire::Http::No-Cache=true
75
76 DEBIAN_FRONTEND=noninteractive apt-get install -y --force-yes vim bzrtools bzr-svn python-paramiko patchutils offlineimap wipe diffstat gtimelog 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 weechat weechat-plugins weechat-scripts dpatch wdiff grep-dctrl ccache subversion listadmin quilt python-dev cryptsetup mutt editmoin lintian python-gtk2-doc fakechroot
77 apt-get -y build-dep postgresql-8.3 gnome-volume-manager hal cupsys apport jockey
78
79 if [ `hostname` = donald ]; then
80     DEBIAN_FRONTEND=noninteractive apt-get install -y --force-yes dchroot rsnapshot dhcp3-server apache2 ia32-libs easytag latex-beamer fakechroot
81 fi
82
83 umount /cdrom || true
84
85 # other setup
86 if [ `hostname` = "donald" ]; then
87     [ -e /mirror ] || ln -s /home/ubuntu-mirror /mirror
88     ln -s /mirror /var/www/mirror
89     ifdown eth1
90     ifup eth1
91     /etc/init.d/dhcp3-server restart
92     patch /usr/bin/gtimelog ~martin/archiv/gtimelog.wednesday.patch
93
94     # crontabs
95     crontab -u martin - <<EOF
96     # m h  dom mon dow   command
97     05 * * * * \$HOME/bin/backup >/dev/null
98 EOF
99 fi