From 52c8f624b5f9ef665f33a7aa80e0aa18b91daa4a Mon Sep 17 00:00:00 2001 From: Serge Hallyn Date: Mon, 19 Mar 2012 00:31:40 +0100 Subject: ubuntu templates cleanups 1. fix inconsistent use of '--auth-key' (not --auth_key) which broke their usage 2. add --debug option to lxc-ubuntu (which does set -x to show what broke) (idea from Idea from lifeless and benji) 3. fix incorrect assumption about group with -b option. User's default group may not be the same as username. Signed-off-by: Daniel Lezcano --- templates/lxc-ubuntu-cloud.in | 13 ++++++++++--- templates/lxc-ubuntu.in | 16 +++++++++++----- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/templates/lxc-ubuntu-cloud.in b/templates/lxc-ubuntu-cloud.in index 1a61c7d..267dbab 100644 --- a/templates/lxc-ubuntu-cloud.in +++ b/templates/lxc-ubuntu-cloud.in @@ -104,18 +104,19 @@ Generic Options [ -a | --arch ]: Arhcitecture of container, defaults to host arcitecture [ -C | --cloud ]: Configure container for use with meta-data service, defaults to no [ -T | --tarball ]: Location of tarball +[ -d | --debug ]: Run with 'set -x' to debug errors Options, mutually exclusive of "-C" and "--cloud": [ -i | --hostid ]: HostID for cloud-init, defaults to random string [ -u | --userdata ]: Cloud-init user-data file to configure container on start - [ -S | --auth_key ]: SSH Public key file to inject into container + [ -S | --auth-key ]: SSH Public key file to inject into container [ -L | --nolocales ]: Do not copy host's locales into container EOF return 0 } -options=$(getopt -o a:hp:r:n:Fi:CLS:T: -l arch:,help,path:,release:,name:,flush-cache,hostid:,auth-key:,cloud,no_locales,tarball: -- "$@") +options=$(getopt -o a:hp:r:n:Fi:CLS:T:d -l arch:,help,path:,release:,name:,flush-cache,hostid:,auth-key:,cloud,no_locales,tarball:,debug -- "$@") if [ $? -ne 0 ]; then usage $(basename $0) exit 1 @@ -150,6 +151,7 @@ else fi fi +debug=0 hostarch=$arch cloud=0 locales=1 @@ -166,14 +168,19 @@ do -i|--hostid) host_id=$2; shift 2;; -u|--userdata) userdata=$2; shift 2;; -C|--cloud) cloud=1; shift 1;; - -S|--auth_key) auth_key=$2; shift 2;; + -S|--auth-key) auth_key=$2; shift 2;; -L|--no_locales) locales=0; shift 2;; -T|--tarball) tarball=$2; shift 2;; + -d|--debug) debug=1; shift 1;; --) shift 1; break ;; *) break ;; esac done +if [ $debug -eq ]; then + set -x +fi + if [ "$arch" == "i686" ]; then arch=i386 fi diff --git a/templates/lxc-ubuntu.in b/templates/lxc-ubuntu.in index 391ee55..3e84e74 100644 --- a/templates/lxc-ubuntu.in +++ b/templates/lxc-ubuntu.in @@ -519,18 +519,18 @@ do_bindhome() usage() { cat <] [--trim] - [-F | --flush-cache] [-r|--release ] [ -S | --auth_key ] +$1 -h|--help [-a|--arch] [-b|--bindhome ] [--trim] [-d|--debug] + [-F | --flush-cache] [-r|--release ] [ -S | --auth-key ] release: lucid | maverick | natty | oneiric | precise trim: make a minimal (faster, but not upgrade-safe) container bindhome: bind 's home into the container arch: amd64 or i386: defaults to host arch -auth_key: SSH Public key file to inject into container +auth-key: SSH Public key file to inject into container EOF return 0 } -options=$(getopt -o a:b:hp:r:xn:FS: -l arch:,bindhome:,help,path:,release:,trim,name:,flush-cache,auth-key: -- "$@") +options=$(getopt -o a:b:hp:r:xn:FS:d -l arch:,bindhome:,help,path:,release:,trim,name:,flush-cache,auth-key:,debug -- "$@") if [ $? -ne 0 ]; then usage $(basename $0) exit 1 @@ -566,6 +566,7 @@ else fi fi +debug=0 trim_container=0 hostarch=$arch flushcache=0 @@ -580,12 +581,17 @@ do -b|--bindhome) bindhome=$2; shift 2;; -a|--arch) arch=$2; shift 2;; -x|--trim) trim_container=1; shift 1;; - -S|--auth_key) auth_key=$2; shift 2;; + -S|--auth-key) auth_key=$2; shift 2;; + -d|--debug) debug=1; shift 1;; --) shift 1; break ;; *) break ;; esac done +if [ $debug -eq 1 ]; then + set -x +fi + pwd=`getent passwd $bindhome` if [ $? -ne 0 ]; then echo "Error: no password entry found for $bindhome" -- cgit v1.2.3-65-gdbad