ubuntu-cloud-prep revision d24d56d7ee3420bb79238ff84cad07c20cf4757d
## 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]
EOF
}
##
# no args or not root
job=""
# find first argument that doesn't start with '-' as 'job'
done
# if job isn't there, no reason to check further
# on Unknown, 'status' exits 1, and prints 'Unknown job' to stderr.
initctl reload-configuration >/dev/null 2>&1
real "$@"
chmod 755 "$1"
}
local root_d="$1"
# already patched
}
local short_opts="Chi:L:S:u:v"
local long_opts="auth-key:,cloud,help,hostid:,name:,nolocales:,patch-start,userdata:,verbose"
local getopt_out getopt_ret
:
getopt_ret=$?
if [ $getopt_ret -eq 0 ]; then
eval set -- "${getopt_out}" ||
fi
local patch_start=0
while [ $# -ne 0 ]; do
-h|--help) prep_usage; return 0;;
--patch-start) patch_start=1;;
-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
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;
}
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 '--patch-start'
[ "${LXC_ROOTFS_PATH#overlayfs}" != "${LXC_ROOTFS_PATH}" ] &&
pstart="--patch-start"
else
_LXC_HOOK=""
prep "$@"
fi
return $?
}
main "$@"
# vi: ts=4 expandtab