Ubuntu Pastebin

Paste from ubuntu at Fri, 17 Mar 2017 14:40:12 +0000

Download as text
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/sh

burl="http://cloud-images.ubuntu.com/daily/server"
rel="xenial"
img_url="$burl/$rel/current/$rel-server-cloudimg-amd64-disk1.img"
img_file="${img_url##*/}"
img_raw="${img_file%.img}.raw"
img_out="$rel-disk.img"
img_work="$img_out.work"

error() { echo "$@" 1>&2; }
fail() { [ $# -eq 0 ] || error "$@"; exit 1; }

if ! command -v mount-image-callback >/dev/null 2>&1; then
    fail "need mount-image-callback: apt-get install -qy cloud-image-utils"
fi
  
if [ ! -f "$img_file" ]; then
    wget "$img_url" -O "$img_file.tmp" && mv "$img_file.tmp" "$img_file" ||
        fail "failed download of $img_url"
fi

qemu-img create -f qcow2 -b "${img_file}" "${img_work}" ||
    fail "failed create $img_work from $img_file"

mount-image-callback --system-mounts --system-resolvconf "$img_work" -- \
    chroot _MOUNTPOINT_ sh -ec '
       apt-get -q update
       grubcfg="/etc/default/grub.d/noprobe.cfg"
       echo GRUB_DISABLE_OS_PROBER=true > "$grubcfg"
       DEBIAN_FRONTEND=noninteractive eatmydata apt-get -qy install linux-generic' \
       </dev/null ||
       fail "failed to install linux-generic"

qemu-img convert -O qcow2 -c "$img_work" "$img_out.tmp" &&
    mv "$img_out.tmp" "$img_out" ||
    fail "failed to convert $img_work to $img_out"

error "wrote $img_out for $rel"
Download as text