chiark / gitweb /
wip productisation
[autopkgtest.git] / xen / fixups
1 #!/bin/sh
2 set -ex
3 . ${ADT_XENLVM_SHARE:=/usr/share/autopkgtest/xenlvm}/readconfig
4
5 dest=$adt_play/base
6
7 echo '---fixups:'
8
9 cp ${ADT_XENLVM_SHARE}/fixups-inside $dest/root/
10
11 mkdir -p $dest/lib/modules
12 cp -a "${adt_modules}" $dest/lib/modules/.
13
14 if ! test -f "${adt_ssh_pubkey}"; then
15         if [ "x${adt_ssh_pubkey}" != "x${adt_ssh_privkey}.priv" ]; then
16                 fail "cannot generate keypair automatically because adt_ssh_privkey \`$adt_ssh_privkey' and adt_ssh_pubkey \`$adt_ssh_pubkey' do not match up in the way required by ssh-keygen (<pubkey> must be <privkey>.pub>"
17         fi
18         if test -f "${adt_ssh_privkey}"; then
19                 fail "will not overwrite existing private key \`$adt_ssh_privkey' - but where is public key \`$adt_ssh_pubkey' ?"
20         fi
21
22         mkdir -p /root/.ssh
23         ssh-keygen -N '' ${adt_ssh_keygen_args} -f "${adt_ssh_privkey}"
24 fi
25
26 mkdir -m 02700 -p $dest/root/.ssh
27 cp -- "${adt_ssh_pubkey}" $dest/root/.ssh/authorized_keys
28
29 cat <<END >$dest/etc/init.d/xenethtoolk
30 #!/bin/sh
31 # work around checksum offload bug in Xen network bridge driver
32 case "$1" in
33 start)
34         ethtool -K eth0 tx off
35         ethtool -K eth0 rx off
36         ;;
37 esac
38 END
39 chmod +x $dest/etc/init.d/xenethtoolk
40 ln -s ../init.d/xenethtoolk $dest/etc/rc2.d/S21xenethtoolk
41
42 chroot $dest root/fixups-inside \
43         "$adt_host_hostname" "$adt_guest_hostname" \
44         "$adt_host_ipaddr" "$adt_guest_ipaddr" \
45         "$adt_fs_type"
46
47 kh=/etc/ssh/ssh_known_hosts
48 test ! -f $kh || cp $kh $kh.new
49 exec 3>$kh.new
50 pfx="$adt_guest_hostname,$adt_guest_ipaddr"
51 test ! -f $kh || perl -pe '$_="" if m/^(\S+)\s/ && $1 eq "'$pfx'";' $kh >&3
52 for f in $dest/etc/ssh/ssh_host_*_key.pub; do
53     perl -pe '$_= "'$pfx' ".$_;' $f >&3
54 done
55 exec 3>&-
56 mv $kh.new $kh
57
58 echo '
59 === adt xen fixups done.
60 '