diff options
author | 2012-03-19 00:31:40 +0100 | |
---|---|---|
committer | 2012-03-19 00:31:40 +0100 | |
commit | 52c8f624b5f9ef665f33a7aa80e0aa18b91daa4a (patch) | |
tree | d5635fa9da7aa6790f5b420119802030e8457313 | |
parent | do check for utmp checking at the right time (diff) | |
download | lxc-52c8f624b5f9ef665f33a7aa80e0aa18b91daa4a.tar.gz lxc-52c8f624b5f9ef665f33a7aa80e0aa18b91daa4a.tar.bz2 lxc-52c8f624b5f9ef665f33a7aa80e0aa18b91daa4a.zip |
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 <dlezcano@fr.ibm.com>
-rw-r--r-- | templates/lxc-ubuntu-cloud.in | 13 | ||||
-rw-r--r-- | 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 <<EOF -$1 -h|--help [-a|--arch] [-b|--bindhome <user>] [--trim] - [-F | --flush-cache] [-r|--release <release>] [ -S | --auth_key <keyfile>] +$1 -h|--help [-a|--arch] [-b|--bindhome <user>] [--trim] [-d|--debug] + [-F | --flush-cache] [-r|--release <release>] [ -S | --auth-key <keyfile>] release: lucid | maverick | natty | oneiric | precise trim: make a minimal (faster, but not upgrade-safe) container bindhome: bind <user>'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" |