~benji/ubuntu/precise/lxc/bug-951150

« back to all changes in this revision

Viewing changes to templates/lxc-ubuntu.in

  • Committer: Package Import Robot
  • Author(s): Serge Hallyn, Ben Howard, Serge Hallyn
  • Date: 2012-02-15 23:33:12 UTC
  • Revision ID: package-import@ubuntu.com-20120215233312-pc46uy6py2f240g1
Tags: 0.7.5-3ubuntu26
[ Ben Howard ]
* 0043-tweak-templates.patch:
  - Add a macaddr to configs created by ubuntu-cloud template
  - Add ssh key injection, locales, and tarball specification support to
    ubuntu-cloud template.

[ Serge Hallyn ]
* (also in 0043-tweak-templates.patch) Add a macaddr to configs created by
  ubuntu template (LP: #931229) and allow an ssh key to be injected.
* debian/control: add openssl as Recommends as it's now used by the
    templates.
* 0044-lxc-destroy-rm-autos: remove autostart symlinks when deleting a
  container.  (LP: #930525)

Show diffs side-by-side

added added

removed removed

Lines of Context:
70
70
    chroot $rootfs groupadd --system $group >/dev/null 2>&1 || true
71
71
    chroot $rootfs useradd --create-home -s /bin/bash -G $group ubuntu
72
72
    echo "ubuntu:ubuntu" | chroot $rootfs chpasswd
 
73
    if [ -n "$auth_key" -a -f "$auth_key" ]; then
 
74
        u_path="/home/ubuntu/.ssh"
 
75
        root_u_path="$rootfs/$u_path"
 
76
        mkdir -p $root_u_path
 
77
        cp $auth_key "$root_u_path/authorized_keys"
 
78
        chroot $rootfs chown -R ubuntu: "$u_path"
 
79
 
 
80
        echo "Inserted SSH public key from $auth_key into /home/ubuntu/.ssh/authorized_keys"
 
81
    fi
73
82
    return 0
74
83
}
75
84
 
258
267
        ttydir=" lxc"
259
268
    fi
260
269
 
 
270
    # if there is exactly one veth network entry, make sure it has an
 
271
    # associated hwaddr.
 
272
    nics=`grep -e '^lxc\.network\.type[ \t]*=[ \t]*veth' $path/config | wc -l`
 
273
    if [ $nics -eq 1 ]; then
 
274
        grep -q "^lxc.network.hwaddr" $path/config || cat <<EOF >> $path/config
 
275
lxc.network.hwaddr= 00:16:3e:$(openssl rand -hex 3| sed 's/\(..\)/\1:/g; s/.$//')
 
276
EOF
 
277
    fi
 
278
 
261
279
    cat <<EOF >> $path/config
262
280
lxc.utsname = $name
263
281
 
480
498
{
481
499
    cat <<EOF
482
500
$1 -h|--help [-a|--arch] [-b|--bindhome <user>] [--trim]
483
 
   [-F | --flush-cache] [-r|--release <release>]
 
501
   [-F | --flush-cache] [-r|--release <release>] [ -S | --auth_key <keyfile>]
484
502
release: lucid | maverick | natty | oneiric | precise
485
503
trim: make a minimal (faster, but not upgrade-safe) container
486
504
bindhome: bind <user>'s home into the container
487
505
arch: amd64 or i386: defaults to host arch
 
506
auth_key: SSH Public key file to inject into container
488
507
EOF
489
508
    return 0
490
509
}
491
510
 
492
 
options=$(getopt -o a:b:hp:r:xn:F -l arch:,bindhome:,help,path:,release:,trim,name:,flush-cache -- "$@")
 
511
options=$(getopt -o a:b:hp:r:xn:FS: -l arch:,bindhome:,help,path:,release:,trim,name:,flush-cache,auth-key: -- "$@")
493
512
if [ $? -ne 0 ]; then
494
513
    usage $(basename $0)
495
514
    exit 1
539
558
    -b|--bindhome)  bindhome=$2; shift 2;;
540
559
    -a|--arch)      arch=$2; shift 2;;
541
560
    -x|--trim)      trim_container=1; shift 1;;
 
561
    -S|--auth_key)  auth_key=$2; shift 2;;
542
562
    --)             shift 1; break ;;
543
563
        *)              break ;;
544
564
    esac