ubuntu-cloud-prep revision 65d8ae9c4a66f5ca85289c02dc06d63261c84619
f0b8f6dd844f8752946b865bdd44175863b15812Peter Major## If the container being cloned has one or more lxc.hook.clone specified,
f0b8f6dd844f8752946b865bdd44175863b15812Peter Major## then the specified hooks will be called for the new container. The first
f0b8f6dd844f8752946b865bdd44175863b15812Peter Major## 3 arguments passed to the clone hook will be:
f0b8f6dd844f8752946b865bdd44175863b15812Peter Major## 1. the container name
f0b8f6dd844f8752946b865bdd44175863b15812Peter Major## 2. a section ('lxc')
f0b8f6dd844f8752946b865bdd44175863b15812Peter Major## 3. hook type ('clone')
f0b8f6dd844f8752946b865bdd44175863b15812Peter Major## 4. .. additional arguments to lxc-clone
f0b8f6dd844f8752946b865bdd44175863b15812Peter Major## Environment variables:
f0b8f6dd844f8752946b865bdd44175863b15812Peter Major## LXC_ROOTFS_MOUNT: path under which the container's root fs is mounted.
f0b8f6dd844f8752946b865bdd44175863b15812Peter Major## LXC_CONFIG_FILE: The configuration file pathname
f0b8f6dd844f8752946b865bdd44175863b15812Peter Major## LXC_SRC_NAME: old container name
f0b8f6dd844f8752946b865bdd44175863b15812Peter Major## LXC_ROOTFS_PATH: path or device on which the root fs is located
c892d0dfeda5c022104813bf59275f840923551bCraig McDonnelldebug() { [ "$1" -ge "$VERBOSITY" ] || return; shift; error "$@"; }
c892d0dfeda5c022104813bf59275f840923551bCraig McDonnellfail() { [ $# -eq 0 ] || error "$@"; exit 1; }
c892d0dfeda5c022104813bf59275f840923551bCraig McDonnellUsage: ${0##*/} [options] root-dir
c892d0dfeda5c022104813bf59275f840923551bCraig McDonnell root-dir is the root directory to operate on
c892d0dfeda5c022104813bf59275f840923551bCraig McDonnell [ -C | --cloud ]: do not configure a datasource. incompatible with
c892d0dfeda5c022104813bf59275f840923551bCraig McDonnell options marked '[ds]'
c892d0dfeda5c022104813bf59275f840923551bCraig McDonnell [ -i | --instance-id]: instance-id for cloud-init, defaults to random [ds]
c892d0dfeda5c022104813bf59275f840923551bCraig McDonnell [ -L | --nolocales ]: Do not copy host's locales into container
c892d0dfeda5c022104813bf59275f840923551bCraig McDonnell [ -S | --auth-key ]: ssh public key file for datasource [ds]
c892d0dfeda5c022104813bf59275f840923551bCraig McDonnell [ -u | --userdata ]: user-data file for cloud-init [ds]
c892d0dfeda5c022104813bf59275f840923551bCraig McDonnell local long_opts="auth-key:,cloud,help,hostid:,name:,nolocales:,userdata:,verbose"
c892d0dfeda5c022104813bf59275f840923551bCraig McDonnell --options "${short_opts}" --long "${long_opts}" -- "$@" 2>/dev/null) ||
c892d0dfeda5c022104813bf59275f840923551bCraig McDonnell if [ $getopt_ret -eq 0 ]; then
c892d0dfeda5c022104813bf59275f840923551bCraig McDonnell { error "Unexpected error reading usage"; return 1; }
c892d0dfeda5c022104813bf59275f840923551bCraig McDonnell local userdata="" hostid="" authkey="" locales=1 cloud=0 name=""
c892d0dfeda5c022104813bf59275f840923551bCraig McDonnell while [ $# -ne 0 ]; do
2d8eba3efb0ced5c2ab004e5b3e949094747aeb3jenkins -h|--help) prep_usage; return 0;;
-u|--userdata)
prep_usage 1>&2;
[ $? -eq 0 ] ||
local _LXC_HOOK