]> piware.de Git - bin.git/blob - postinst-setup
1be35aa0542ee6133a5c5eb286dc9c1462f69950
[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 # need bzr and postfix for the setup below
10 DEBIAN_FRONTEND=noninteractive apt-get -y install --no-install-recommends postfix openssh-server bzr python-paramiko 
11
12 # root's ssh stuff
13 if [ ! -d /root/.ssh ] && [ -d /home/martin/.ssh ]; then
14     mkdir -p /root/.ssh
15     chmod 700 /root/.ssh
16     cp /home/martin/.ssh/id_rsa* /home/martin/.ssh/known_hosts /home/martin/.ssh/config /root/.ssh/
17 fi
18
19 # restore /etc bzr branch, rescue the files we do not want to restore
20 # completely
21 cd /etc
22 if [ ! -d /etc/.bzr ]; then
23     for i in passwd group shadow fstab; do
24         [ -e $i.originst ] || cp $i $i.originst
25     done
26     [ -e /backup-etc ] || bzr get bzr+ssh://martin@piware.de/home/martin/backup/`hostname`-etc /backup-etc
27     cp -av /backup-etc/* /etc/
28     cp -av /backup-etc/.bzr/ /etc/
29     rm -rf /backup-etc
30     chmod 600 /etc/ssh/ssh_*_key
31     chmod 640 /etc/shadow
32     chown root:shadow /etc/shadow
33     chmod 700 /etc/ssl/private
34     chmod 640 /etc/ssl/private/ssl-cert-*
35     chown root:ssl-cert /etc/ssl/private/ssl-cert*
36
37     # only restore dchroot part into fstab
38     grep -A 200 "^#.*chroot" fstab >> fstab.originst || true
39     mv fstab.originst fstab
40
41     # only restore the human users from passwd/group
42     for i in passwd group; do
43         perl -naF: -e 'print if $F[2] > 1000 && $F[2] < 60000' $i >> $i.originst
44         mv $i.originst $i
45     done
46
47     # only restore some passwords from shadow
48     egrep 'martin|netti|joe' shadow >> shadow.originst
49     mv shadow.originst shadow
50     chown root:shadow shadow
51     chmod 640 shadow
52 fi
53
54 # update postfix for new configuration
55 newaliases
56 /etc/init.d/postfix restart
57
58 # other setup
59 dpkg -i /home/martin/download/libdvdcss2_*deb || true
60 locale-gen ru_RU ru_RU.UTF-8
61
62 # remove packages that we do not need
63 killall apt-get || true # cronjob goo
64 apt-get purge -y --auto-remove hplip hplip-data hpijs brltty bluez-cups gnome-accessibility-themes gnome-mag gnome-orca onboard tomboy ttf-lao ttf-thai-tlwg || true
65
66 rm -f /etc/rcS.d/*pcmcia* /etc/rcS.d/*ppp*
67
68 # install packages from network sources
69 killall apt-get || true
70 apt-get update
71
72 DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y --force-yes vim bzrtools patchutils offlineimap wipe diffstat gtimelog jigdo-file libtool devhelp python-doc manpages-dev gstreamer0.10-fluendo-mp3 gstreamer0.10-ffmpeg weechat weechat-plugins weechat-scripts dpatch wdiff ccache listadmin quilt cryptsetup mutt editmoin lintian python-gtk2-doc fakechroot ubuntu-dev-tools dput dchroot fakechroot easytag rsnapshot texlive-lang-german texlive-latex-extra powertop vim-scripts libtemplate-perl kvm bzr-buildpackage git-core greasemonkey build-essential fakeroot devscripts libglib2.0-doc libgtk2.0-doc git-buildpackage d-feet germinate debootstrap seahorse-plugins wmctrl mumble
73 apt-get -y build-dep postgresql-8.4 cups apport calibre gvfs udisks upower gnome-disk-utility
74
75 # basic 32 bit libraries (for adb)
76 if [ `uname -m` = x86_64 ]; then
77     apt-get install -y lib32stdc++6 lib32ncurses5 libc6-i386
78 fi
79
80 # crontabs
81 crontab -u martin - <<EOF
82 # m h  dom mon dow   command
83 05 * * * * \$HOME/bin/backup >/dev/null
84 EOF
85
86 if [ -x /usr/bin/gtimelog ]; then
87     patch --no-backup-if-mismatch /usr/bin/gtimelog ~martin/archiv/gtimelog.tuesday.patch
88 fi