lxc-download.in revision e145b7bb6d62fe3ba279ec0730117edea9c2d538
286N/A# Client script for LXC container images. 70N/A# Copyright © 2014 Stéphane Graber <stgraber@ubuntu.com> 70N/A# This library is free software; you can redistribute it and/or 70N/A# modify it under the terms of the GNU Lesser General Public 70N/A# License as published by the Free Software Foundation; either 70N/A# version 2.1 of the License, or (at your option) any later version. 70N/A# This library is distributed in the hope that it will be useful, 70N/A# but WITHOUT ANY WARRANTY; without even the implied warranty of 70N/A# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 70N/A# Lesser General Public License for more details. 70N/A# You should have received a copy of the GNU Lesser General Public 70N/A# License along with this library; if not, write to the Free Software 70N/A# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 286N/A# Deal with GPG over http proxy 90N/Aif [ -n
"${http_proxy:-}" ];
then 262N/A# Make sure the usual locations are in PATH 70N/A if [ "$3" = "noexit" ]; then 70N/A echo "ERROR: Failed to download http://${DOWNLOAD_SERVER}/$1" 1>&2 70N/A echo "WARNING: Failed to download the file over HTTPs." 1>&2 70N/A echo -n " The file was instead download over HTTP. " 1>&2 70N/A echo "A server replay attack may be possible!" 1>&2 if [ "$3" = "normal" ]; then echo "ERROR: Failed to download http://${DOWNLOAD_SERVER}/$1" 1>&2 echo "Setting up the GPG keyring" echo "ERROR: Unable to fetch GPG key from keyserver." echo "WARNING: Running without gpg validation!" 1>&2 echo "ERROR: Invalid signature for $1" 1>&2 [ "$fields" = "0 0 4294967295" ] && { echo no; return; } || true if [ -e "${FILE_PATH}-${DOWNLOAD_MODE}" ]; then if [ -e "$FILE_PATH.${DOWNLOAD_COMPAT_LEVEL}" ]; then FILE_PATH="${FILE_PATH}.${DOWNLOAD_COMPAT_LEVEL}" LXC container image downloader [ -d | --dist <distribution> ]: The name of the distribution [ -r | --release <release> ]: Release name/version [ -a | --arch <architecture> ]: Architecture of the container [ -h | --help ]: This help message [ -l | --list ]: List all available images [ --variant <variant> ]: Variant of the image (default: "default") [ --server <server> ]: Image server (default: "images.linuxcontainers.org") [ --keyid <keyid> ]: GPG keyid (default: 0x...) [ --keyserver <keyserver> ]: GPG keyserver to use [ --no-validate ]: Disable GPG validation (not recommended) [ --flush-cache ]: Flush the local copy (if present) [ --force-cache ]: Force the use of the local copy even if expired LXC internal arguments (do not pass manually!): [ --name <name> ]: The container name [ --path <path> ]: The path to the container [ --rootfs <rootfs> ]: The path to the container's rootfs [ --mapped-uid <map> ]: A uid map (user namespaces) [ --mapped-gid <map> ]: A gid map (user namespaces) # Check for required binaries echo "ERROR: Missing required tool: $bin" 1>&
2 echo "ERROR: Missing recommended tool: gpg" 1>&
2 echo "You can workaround this by using --no-validate." 1>&
2 # Check that we have all variables we need echo "ERROR: Not running through LXC." 1>&
2 echo "ERROR: In a user namespace without a map." 1>&
2 echo "Downloading the image index" printf "DIST\tRELEASE\tARCH\tVARIANT\tBUILD\n" [ -z
"$5" ] || [ -z
"$6" ] &&
continue echo "Flushing the cache..." echo "The cached copy has expired, re-downloading..." echo "Downloading the image index" echo "ERROR: Couldn't find a matching image." 1>&
1 echo "The cache is already up to date." echo "Using image from local cache" # Download the actual files echo "Downloading the rootfs" echo "Downloading the metadata" echo "ERROR: Invalid rootfs tarball." 2>&
1 echo "The image cache is now ready" echo "Using image from local cache" echo "Unpacking the rootfs" if [ -f
"${excludelist}" ];
then # Setup the configuration echo "ERROR: meta tarball is missing the configuration file" 1>&
2 ## Extract all the network config entries ## Extract any other config entry ## Add the container-specific config if [ -e
"${LXC_PATH}/config-auto" ];
then ## Re-add the previously removed network config if [ -e
"${LXC_PATH}/config-network" ];
then # Look for extra templates # Replace variables in all templates [ ! -f
"$file" ] &&
continue