lxc-download.in revision 6dc6f80bfd7cb169948f2ef9a95dcf6d2edee853
2ronwalf# Client script for LXC container images. 2ronwalf# Copyright © 2014 Stéphane Graber <stgraber@ubuntu.com> 2ronwalf# This library is free software; you can redistribute it and/or 2ronwalf# modify it under the terms of the GNU Lesser General Public 2ronwalf# License as published by the Free Software Foundation; either 2ronwalf# version 2.1 of the License, or (at your option) any later version. 2ronwalf# This library is distributed in the hope that it will be useful, 2ronwalf# but WITHOUT ANY WARRANTY; without even the implied warranty of 2ronwalf# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 2ronwalf# Lesser General Public License for more details. 2ronwalf# You should have received a copy of the GNU Lesser General Public 2ronwalf# License along with this library; if not, write to the Free Software 2ronwalf# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 # Deal with GPG over http proxy if [ -n
"${http_proxy:-}" ];
then # Make sure the usual locations are in PATH if [ "$3" = "noexit" ]; then echo "ERROR: Failed to download http://${DOWNLOAD_SERVER}/$1" 1>&2 echo "WARNING: Failed to download the file over HTTPs." 1>&2 echo -n " The file was instead download over HTTP. " 1>&2 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 [ -h | --help ]: Print this help message and exit. [ -l | --list ]: List all available images and exit. [ -d | --dist <distribution> ]: The name of the distribution [ -r | --release <release> ]: Release name/version [ -a | --arch <architecture> ]: Architecture of the container [ --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# Allow the setting of the LXC_CACHE_PATH with the usage of environment variables. 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# prevent mingetty from calling vhangup(2) since it fails with userns on Centos / Oracle