## If the container being cloned has one or more lxc.hook.clone
## specified, then the specified hooks will be called for the new
## container. The arguments passed to the clone hook are:
## 1. the container name
## 2. a section ('lxc')
## 3. hook type ('clone')
## 4. .. additional arguments to lxc-clone
## Environment variables:
## LXC_ROOTFS_MOUNT: path to the root filesystem
## LXC_CONFIG_FILE: path to config file
## LXC_SRC_NAME: old container name
## LXC_ROOTFS_PATH: path or device on which the root fs is located
set -f
VERBOSITY="0"
cat <<EOF
Usage: ${0##*/} [options] root-dir
root-dir is the root directory to operate on
[ -C | --cloud ]: do not configure a datasource. incompatible with
options marked '[ds]'
[ -i | --instance-id]: instance-id for cloud-init, defaults to random [ds]
[ -L | --nolocales ]: Do not copy host's locales into container
[ -S | --auth-key ]: ssh public key file for datasource [ds]
[ -u | --userdata ]: user-data file for cloud-init [ds]
[ -V | --vendordata ]: vendor-data file for cloud-init [ds]
EOF
}
local short_opts="Chi:L:S:u:v"
local long_opts="auth-key:,cloud,help,hostid:,name:,nolocales:,create-etc-init,userdata:,vendordata:,verbose"
local getopt_out getopt_ret
:
getopt_ret=$?
if [ $getopt_ret -eq 0 ]; then
eval set -- "${getopt_out}" ||
fi
local create_etc_init=0 name="ubuntucloud-lxc"
while [ $# -ne 0 ]; do
-h|--help) prep_usage; return 0;;
--create-etc-init) create_etc_init=1;;
-V|--vendordata)
-u|--userdata)
--) shift; break;;
esac
shift;
done
[ $# -eq 1 ] || {
prep_usage 1>&2;
return 1;
}
# getopt above failed, but we were called from lxc clone. there might
# be multiple clone hooks and the args provided here not for us. This
# seems like not the greatest interface, so all we'll do is mention it.
error "${0##*}: usage failed, continuing with defaults"
fi
echo "#upstart needs help for overlayfs (LP: #1213925)." > \
local seed_d=""
else
fi
{
echo "public-keys:" &&
[ $? -eq 0 ] ||
fi
local larch="usr/lib/locale/locale-archive"
return 1;
}
fi
fi
else
{
echo "#cloud-config"
echo "output: {all: '| tee -a /var/log/cloud-init-output.log'}"
echo "apt_mirror: $MIRROR"
echo "manage_etc_hosts: localhost"
echo "password: ubuntu"
echo "chpasswd: { expire: false; }"
fi
[ $? -eq 0 ] || {
return 1;
}
return 1;
}
fi
fi
}
# main just joins 2 modes of being called. from user one from lxc clone
local _LXC_HOOK
_LXC_HOOK="clone"
shift 3
# if mountpoint is overlayfs then add '--create-etc-init'
[ "${LXC_ROOTFS_PATH#overlayfs}" != "${LXC_ROOTFS_PATH}" ] &&
create_etc_init="--create-etc-init"
else
_LXC_HOOK=""
prep "$@"
fi
return $?
}
main "$@"
# vi: ts=4 expandtab