~ubuntu-branches/ubuntu/quantal/ceph/quantal

« back to all changes in this revision

Viewing changes to src/script/build_debian_image.sh

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2012-07-16 09:56:24 UTC
  • mfrom: (0.3.11)
  • mto: This revision was merged to the branch mainline in revision 17.
  • Revision ID: package-import@ubuntu.com-20120716095624-azr2w4hbhei1rxmx
Tags: upstream-0.48
ImportĀ upstreamĀ versionĀ 0.48

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh -x
 
2
 
 
3
set -e
 
4
 
 
5
image="$1"
 
6
root=/tmp/$$
 
7
dist=squeeze
 
8
 
 
9
srcdir=`dirname $0`
 
10
 
 
11
# image
 
12
[ -e $image ] && echo $image exists && exit 1
 
13
dd if=/dev/zero of=$image bs=1M seek=1023 count=1
 
14
yes | mke2fs -j $image
 
15
 
 
16
mkdir $root
 
17
mount -o loop $image $root
 
18
 
 
19
cleanup() {
 
20
        umount $root/proc || true
 
21
        umount $root/sys || true
 
22
        umount $root/dev/pts || true
 
23
        umount $root
 
24
}
 
25
trap cleanup INT TERM EXIT
 
26
 
 
27
debootstrap $dist $root http://http.us.debian.org/debian/
 
28
 
 
29
cat <<EOF >> $root/etc/fstab
 
30
none /dev/pts devpts gid=5,mode=620 0 0
 
31
proc /proc proc defaults 0 0
 
32
sysfs /sys sysfs defaults 0 0
 
33
none /sys/kernel/debug debugfs defaults 0 0
 
34
tmpfs /tmp tmpfs defaults,size=768M 0 0
 
35
none /host hostfs defaults 0 0
 
36
EOF
 
37
 
 
38
echo "uml" > $root/etc/hostname
 
39
mkdir $root/host
 
40
 
 
41
# set up chroot
 
42
mount -t proc proc $root/proc
 
43
mount -t sysfs sysfs $root/sys
 
44
mount -t devpts devptr $root/dev/pts -o gid=5,mode=620
 
45
 
 
46
# set up network
 
47
cp $srcdir/network-from-cmdline $root/etc/init.d/network-from-cmdline
 
48
chroot $root update-rc.d network-from-cmdline defaults 20
 
49
 
 
50
# kcon_ helpers
 
51
cp $srcdir/kcon_most.sh $root/root/most.sh
 
52
cp $srcdir/kcon_all.sh $root/root/all.sh
 
53
 
 
54
# fix up consoles
 
55
cat <<EOF >> $root/etc/securetty 
 
56
 
 
57
# uml
 
58
tty0
 
59
vc/0
 
60
EOF
 
61
 
 
62
cat <<EOF >> $root/etc/inittab
 
63
 
 
64
# uml just one console
 
65
c0:1235:respawn:/sbin/getty 38400 tty0 linux
 
66
EOF
 
67
grep -v tty[23456] $root/etc/inittab > $root/etc/inittab.new
 
68
mv $root/etc/inittab.new $root/etc/inittab
 
69
 
 
70
# no root password
 
71
chroot $root passwd -d root
 
72
 
 
73
# copy creating user's authorized_keys
 
74
mkdir $root/root/.ssh
 
75
chmod 700 $root/root/.ssh
 
76
cp ~/.ssh/authorized_keys $root/root/.ssh/authorized_keys
 
77
chmod 600 $root/root/.ssh/authorized_keys
 
78
 
 
79
# packages
 
80
chroot $root apt-get -y --force-yes install ssh libcrypto\+\+ bind9-host
 
81
 
 
82
exit 0