lxc-download.in revision 71d3a6590fe665421d7a0026d699b0654ddfc7f6
8900b9eb2514c07047541833286428572493a9fdStéphane Graber#!/bin/sh
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi# Client script for LXC container images.
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi#
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi# Copyright © 2014 Stéphane Graber <stgraber@ubuntu.com>
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi#
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi# This library is free software; you can redistribute it and/or
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi# modify it under the terms of the GNU Lesser General Public
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi# License as published by the Free Software Foundation; either
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi# version 2.1 of the License, or (at your option) any later version.
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi# This library is distributed in the hope that it will be useful,
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi# but WITHOUT ANY WARRANTY; without even the implied warranty of
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi# Lesser General Public License for more details.
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi# You should have received a copy of the GNU Lesser General Public
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi# License along with this library; if not, write to the Free Software
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi# USA
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi
a5ba96715d4ef264c43d4f187251de491ba198c0KATOH Yasufumiset -eu
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi
8900b9eb2514c07047541833286428572493a9fdStéphane GraberLXC_TEMPLATE_CONFIG="@LXCTEMPLATECONFIG@"
57da8c32f85c0255efa61ee32e260068afdaa565KATOH YasufumiLXC_HOOK_DIR="@LXCHOOKDIR@"
57da8c32f85c0255efa61ee32e260068afdaa565KATOH YasufumiLOCALSTATEDIR="@LOCALSTATEDIR@"
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi# Defaults
faefa7f8584a7d1567df2e6f1f9240a28a6466abStéphane GraberDOWNLOAD_DIST=
57da8c32f85c0255efa61ee32e260068afdaa565KATOH YasufumiDOWNLOAD_RELEASE=
57da8c32f85c0255efa61ee32e260068afdaa565KATOH YasufumiDOWNLOAD_ARCH=
57da8c32f85c0255efa61ee32e260068afdaa565KATOH YasufumiDOWNLOAD_VARIANT="default"
57da8c32f85c0255efa61ee32e260068afdaa565KATOH YasufumiDOWNLOAD_SERVER="images.linuxcontainers.org"
57da8c32f85c0255efa61ee32e260068afdaa565KATOH YasufumiDOWNLOAD_KEYID="0xBAEFF88C22F6E216"
57da8c32f85c0255efa61ee32e260068afdaa565KATOH YasufumiDOWNLOAD_KEYSERVER="pool.sks-keyservers.net"
57da8c32f85c0255efa61ee32e260068afdaa565KATOH YasufumiDOWNLOAD_VALIDATE="true"
57da8c32f85c0255efa61ee32e260068afdaa565KATOH YasufumiDOWNLOAD_FLUSH_CACHE="false"
57da8c32f85c0255efa61ee32e260068afdaa565KATOH YasufumiDOWNLOAD_MODE="system"
57da8c32f85c0255efa61ee32e260068afdaa565KATOH YasufumiDOWNLOAD_USE_CACHE="false"
57da8c32f85c0255efa61ee32e260068afdaa565KATOH YasufumiDOWNLOAD_URL=
57da8c32f85c0255efa61ee32e260068afdaa565KATOH YasufumiDOWNLOAD_SHOW_HTTP_WARNING="true"
57da8c32f85c0255efa61ee32e260068afdaa565KATOH YasufumiDOWNLOAD_SHOW_GPG_WARNING="true"
57da8c32f85c0255efa61ee32e260068afdaa565KATOH YasufumiDOWNLOAD_COMPAT_LEVEL=1
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi
57da8c32f85c0255efa61ee32e260068afdaa565KATOH YasufumiLXC_NAME=
57da8c32f85c0255efa61ee32e260068afdaa565KATOH YasufumiLXC_PATH=
57da8c32f85c0255efa61ee32e260068afdaa565KATOH YasufumiLXC_ROOTFS=
57da8c32f85c0255efa61ee32e260068afdaa565KATOH YasufumiLXC_MAPPED_UID=
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi# Some useful functions
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumicleanup() {
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi if [ -d "$DOWNLOAD_TEMP" ]; then
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi rm -Rf $DOWNLOAD_TEMP
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi fi
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi}
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumidownload_file() {
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi if ! wget -q https://${DOWNLOAD_SERVER}/$1 -O $2 >/dev/null 2>&1; then
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi if ! wget -q http://${DOWNLOAD_SERVER}/$1 -O $2 >/dev/null 2>&1; then
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi if [ "$3" = "noexit" ]; then
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi return 1
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi else
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi echo "ERROR: Failed to download $1" 1>&2
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi exit 1
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi fi
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi elif [ "$DOWNLOAD_SHOW_HTTP_WARNING" = "true" ]; then
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi DOWNLOAD_SHOW_HTTP_WARNING="false"
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi echo "WARNING: Failed to download the file over HTTPs." 1>&2
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi echo -n " The file was instead download over HTTP. " 1>&2
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi echo "A server replay attack may be possible!" 1>&2
dc421f3aac1f0e516c763dd156629a8ed2a7b4caKATOH Yasufumi fi
dc421f3aac1f0e516c763dd156629a8ed2a7b4caKATOH Yasufumi fi
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi}
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumigpg_setup() {
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi if [ "$DOWNLOAD_VALIDATE" = "false" ]; then
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi return
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi fi
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi echo "Setting up the GPG keyring"
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi mkdir -p "$DOWNLOAD_TEMP/gpg"
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi chmod 700 "$DOWNLOAD_TEMP/gpg"
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi export GNUPGHOME="$DOWNLOAD_TEMP/gpg"
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi if ! gpg --keyserver $DOWNLOAD_KEYSERVER \
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi --recv-keys ${DOWNLOAD_KEYID} >/dev/null 2>&1; then
dc421f3aac1f0e516c763dd156629a8ed2a7b4caKATOH Yasufumi echo "ERROR: Unable to fetch GPG key from keyserver."
dc421f3aac1f0e516c763dd156629a8ed2a7b4caKATOH Yasufumi exit 1
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi fi
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi}
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumigpg_validate() {
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi if [ "$DOWNLOAD_VALIDATE" = "false" ]; then
70bb1a9ca75543597766cfd644b53db5cc772d3fLars Wikberg if [ "$DOWNLOAD_SHOW_GPG_WARNING" = "true" ]; then
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi echo "WARNING: Running without gpg validation!" 1>&2
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi fi
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi DOWNLOAD_SHOW_GPG_WARNING="false"
dc421f3aac1f0e516c763dd156629a8ed2a7b4caKATOH Yasufumi return 0
dc421f3aac1f0e516c763dd156629a8ed2a7b4caKATOH Yasufumi fi
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi if ! gpg --verify $1 >/dev/zero 2>&1; then
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi echo "ERROR: Invalid signature for $1" 1>&2
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi exit 1
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi fi
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi}
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumiin_userns() {
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi [ -e /proc/self/uid_map ] || { echo no; return; }
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi [ "$(wc -l /proc/self/uid_map | awk '{ print $1 }')" -eq 1 ] || \
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi { echo yes; return; }
dc421f3aac1f0e516c763dd156629a8ed2a7b4caKATOH Yasufumi line=$(awk '{ print $1 " " $2 " " $3 }' /proc/self/uid_map)
dc421f3aac1f0e516c763dd156629a8ed2a7b4caKATOH Yasufumi [ "$line" = "0 0 4294967295" ] && { echo no; return; }
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi echo yes
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi}
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumirelevant_file() {
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi FILE_PATH="${LXC_CACHE_PATH}/$1"
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi if [ -e "${FILE_PATH}-${DOWNLOAD_MODE}" ]; then
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi FILE_PATH="${FILE_PATH}-${DOWNLOAD_MODE}"
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi fi
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi if [ -e "$FILE_PATH.${DOWNLOAD_COMPAT_LEVEL}" ]; then
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi FILE_PATH="${FILE_PATH}.${DOWNLOAD_COMPAT_LEVEL}"
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi fi
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi echo $FILE_PATH
dc421f3aac1f0e516c763dd156629a8ed2a7b4caKATOH Yasufumi}
dc421f3aac1f0e516c763dd156629a8ed2a7b4caKATOH Yasufumi
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumiusage() {
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi cat <<EOF
57da8c32f85c0255efa61ee32e260068afdaa565KATOH YasufumiLXC container image downloader
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi
57da8c32f85c0255efa61ee32e260068afdaa565KATOH YasufumiRequired arguments:
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi[ -d | --dist <distribution> ]: The name of the distribution
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi[ -r | --release <release> ]: Release name/version
dc421f3aac1f0e516c763dd156629a8ed2a7b4caKATOH Yasufumi[ -a | --arch <architecture> ]: Architecture of the container
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi[ -h | --help ]: This help message
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi
57da8c32f85c0255efa61ee32e260068afdaa565KATOH YasufumiOptional arguments:
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi[ --variant <variant> ]: Variant of the image (default: "default")
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi[ --server <server> ]: Image server (default: "images.linuxcontainers.org")
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi[ --keyid <keyid> ]: GPG keyid (default: 0x...)
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi[ --keyserver <keyserver> ]: GPG keyserver to use
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi[ --no-validate ]: Disable GPG validation (not recommended)
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi[ --flush-cache ]: Flush the local copy (if present)
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi
57da8c32f85c0255efa61ee32e260068afdaa565KATOH YasufumiLXC internal arguments (do not pass manually!):
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi[ --name <name> ]: The container name
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi[ --path <path> ]: The path to the container
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi[ --rootfs <rootfs> ]: The path to the container's rootfs
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi[ --mapped-uid <map> ]: A uid/gid map (user namespaces)
57da8c32f85c0255efa61ee32e260068afdaa565KATOH YasufumiEOF
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi return 0
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi}
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumioptions=$(getopt -o d:r:a:h -l dist:,release:,arch:,help,variant:,server:,\
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumikeyid:,no-validate,flush-cache,name:,path:,rootfs:,mapped-uid: -- "$@")
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumiif [ $? -ne 0 ]; then
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi usage
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi exit 1
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumifi
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumieval set -- "$options"
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumiwhile :; do
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi case "$1" in
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi -h|--help) usage $0 && exit 0;;
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi -d|--dist) DOWNLOAD_DIST=$2; shift 2;;
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi -r|--release) DOWNLOAD_RELEASE=$2; shift 2;;
3726cda21aade3dce418315e7f3dd2e15b69f735KATOH Yasufumi -a|--arch) DOWNLOAD_ARCH=$2; shift 2;;
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi --variant) DOWNLOAD_VARIANT=$2; shift 2;;
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi --server) DOWNLOAD_SERVER=$2; shift 2;;
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi --keyid) DOWNLOAD_KEYID=$2; shift 2;;
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi --no-validate) DOWNLOAD_VALIDATE="false"; shift 1;;
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi --flush-cache) DOWNLOAD_FLUSH_CACHE="true"; shift 1;;
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi --name) LXC_NAME=$2; shift 2;;
3726cda21aade3dce418315e7f3dd2e15b69f735KATOH Yasufumi --path) LXC_PATH=$2; shift 2;;
dc421f3aac1f0e516c763dd156629a8ed2a7b4caKATOH Yasufumi --rootfs) LXC_ROOTFS=$2; shift 2;;
dc421f3aac1f0e516c763dd156629a8ed2a7b4caKATOH Yasufumi --mapped-uid) LXC_MAPPED_UID=$2; shift 2;;
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi *) break;;
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi esac
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumidone
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi# Check for required binaries
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumifor bin in tar xz wget; do
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi if ! type $bin >/dev/null 2>&1; then
3726cda21aade3dce418315e7f3dd2e15b69f735KATOH Yasufumi echo "ERROR: Missing required tool: $bin" 1>&2
3726cda21aade3dce418315e7f3dd2e15b69f735KATOH Yasufumi exit 1
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi fi
dc421f3aac1f0e516c763dd156629a8ed2a7b4caKATOH Yasufumidone
dc421f3aac1f0e516c763dd156629a8ed2a7b4caKATOH Yasufumi
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi# Check for GPG
3726cda21aade3dce418315e7f3dd2e15b69f735KATOH Yasufumiif [ "$DOWNLOAD_VALIDATE" = "true" ]; then
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi if ! type gpg >/dev/null 2>&1; then
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi echo "ERROR: Missing recommended tool: gpg" 1>&2
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi echo "You can workaround this by using --no-validate." 1>&2
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi exit 1
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi fi
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumifi
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi# Check that we have all variables we need
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumiif [ -z "$LXC_NAME" ] || [ -z "$LXC_PATH" ] || [ -z "$LXC_ROOTFS" ]; then
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi echo "ERROR: Not running through LXC." 1>&2
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi exit 1
dc421f3aac1f0e516c763dd156629a8ed2a7b4caKATOH Yasufumifi
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumiif [ "$(in_userns)" = "yes" ]; then
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi if [ -z "$LXC_MAPPED_UID" ] || [ "$LXC_MAPPED_UID" = "-1" ]; then
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi echo "ERROR: In a user namespace without a map." 1>&2
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi exit 1
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi fi
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi DOWNLOAD_MODE="user"
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumifi
dc421f3aac1f0e516c763dd156629a8ed2a7b4caKATOH Yasufumi
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumiif [ -z "$DOWNLOAD_DIST" ] || [ -z "$DOWNLOAD_RELEASE" ] || \
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi [ -z "$DOWNLOAD_ARCH" ]; then
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi echo "ERROR: Missing required argument" 1>&2
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi usage
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi exit 1
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumifi
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi# Trap all exit signals
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumitrap cleanup EXIT HUP INT TERM
57da8c32f85c0255efa61ee32e260068afdaa565KATOH YasufumiDOWNLOAD_TEMP=$(mktemp -d)
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi# Setup the cache
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumiif [ "$DOWNLOAD_MODE" = "system" ]; then
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi LXC_CACHE_BASE="$LOCALSTATEDIR/cache/"
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi LXC_CACHE_PATH="$LOCALSTATEDIR/cache/lxc/download/$DOWNLOAD_DIST"
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi LXC_CACHE_PATH="$LXC_CACHE_PATH/$DOWNLOAD_RELEASE/$DOWNLOAD_ARCH"
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumielse
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi LXC_CACHE_BASE="$HOME/.cache/lxc/"
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi LXC_CACHE_PATH="$HOME/.cache/lxc/download/$DOWNLOAD_DIST"
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi LXC_CACHE_PATH="$LXC_CACHE_PATH/$DOWNLOAD_RELEASE/$DOWNLOAD_ARCH"
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumifi
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumiif [ -d "$LXC_CACHE_PATH" ]; then
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi if [ "$DOWNLOAD_FLUSH_CACHE" = "true" ]; then
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi echo "Flushing the cache..."
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi rm -Rf $LXC_CACHE_PATH
dc421f3aac1f0e516c763dd156629a8ed2a7b4caKATOH Yasufumi else
dc421f3aac1f0e516c763dd156629a8ed2a7b4caKATOH Yasufumi DOWNLOAD_USE_CACHE="true"
dc421f3aac1f0e516c763dd156629a8ed2a7b4caKATOH Yasufumi if [ -e "$(relevant_file expiry)" ]; then
dc421f3aac1f0e516c763dd156629a8ed2a7b4caKATOH Yasufumi if [ "$(cat $(relevant_file expiry))" -lt $(date +%s) ]; then
dc421f3aac1f0e516c763dd156629a8ed2a7b4caKATOH Yasufumi echo "The cached copy has expired, re-downloading..."
dc421f3aac1f0e516c763dd156629a8ed2a7b4caKATOH Yasufumi DOWNLOAD_USE_CACHE="false"
dc421f3aac1f0e516c763dd156629a8ed2a7b4caKATOH Yasufumi rm -Rf $LXC_CACHE_PATH
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi fi
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi fi
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi fi
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumifi
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi# Download what's needed
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumiif [ "$DOWNLOAD_USE_CACHE" = "false" ]; then
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi # Initialize GPG
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi gpg_setup
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi # Grab the index
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi DOWNLOAD_INDEX_PATH=/meta/1.0/index-${DOWNLOAD_MODE}
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi echo "Downloading the image index"
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi if ! download_file ${DOWNLOAD_INDEX_PATH}.${DOWNLOAD_COMPAT_LEVEL} \
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi ${DOWNLOAD_TEMP}/index noexit ||
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi ! download_file ${DOWNLOAD_INDEX_PATH}.${DOWNLOAD_COMPAT_LEVEL}.asc \
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi ${DOWNLOAD_TEMP}/index.asc noexit; then
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi download_file ${DOWNLOAD_INDEX_PATH} ${DOWNLOAD_TEMP}/index normal
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi download_file ${DOWNLOAD_INDEX_PATH}.asc \
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi ${DOWNLOAD_TEMP}/index.asc normal
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi fi
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi gpg_validate ${DOWNLOAD_TEMP}/index.asc
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi # Parse it
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi while read line; do
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi # Basic CSV parser
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi OLD_IFS=$IFS
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi IFS=";"
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi set -- $line
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi IFS=$OLD_IFS
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi if [ "$1" != "$DOWNLOAD_DIST" ] || \
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi [ "$2" != "$DOWNLOAD_RELEASE" ] || \
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi [ "$3" != "$DOWNLOAD_ARCH" ] || \
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi [ "$4" != "$DOWNLOAD_VARIANT" ] || \
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi [ -z "$6" ]; then
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi continue
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi fi
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi DOWNLOAD_URL=$6
dc421f3aac1f0e516c763dd156629a8ed2a7b4caKATOH Yasufumi break
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi done < ${DOWNLOAD_TEMP}/index
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi if [ -z "$DOWNLOAD_URL" ]; then
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi echo "ERROR: Couldn't find a matching image." 1>&1
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi exit 1
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi fi
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi # Download the actual files
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi echo "Downloading the rootfs"
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi download_file $DOWNLOAD_URL/rootfs.tar.xz \
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi ${DOWNLOAD_TEMP}/rootfs.tar.xz normal
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi download_file $DOWNLOAD_URL/rootfs.tar.xz.asc \
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi ${DOWNLOAD_TEMP}/rootfs.tar.xz.asc normal
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi gpg_validate ${DOWNLOAD_TEMP}/rootfs.tar.xz.asc
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi echo "Downloading the metadata"
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi download_file $DOWNLOAD_URL/meta.tar.xz \
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi ${DOWNLOAD_TEMP}/meta.tar.xz normal
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi download_file $DOWNLOAD_URL/meta.tar.xz.asc \
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi ${DOWNLOAD_TEMP}/meta.tar.xz.asc normal
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi gpg_validate ${DOWNLOAD_TEMP}/meta.tar.xz.asc
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi mkdir -p $LXC_CACHE_PATH
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi mv ${DOWNLOAD_TEMP}/rootfs.tar.xz $LXC_CACHE_PATH
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi if ! tar Jxf ${DOWNLOAD_TEMP}/meta.tar.xz -C $LXC_CACHE_PATH; then
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi echo "ERROR: Invalid rootfs tarball." 2>&1
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi exit 1
dc421f3aac1f0e516c763dd156629a8ed2a7b4caKATOH Yasufumi fi
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi if [ -n "$LXC_MAPPED_UID" ] && [ "$LXC_MAPPED_UID" != "-1" ]; then
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi chown $LXC_MAPPED_UID -Rf $LXC_CACHE_BASE >/dev/null 2>&1 || true
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi fi
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi echo "The image cache is now ready"
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumielse
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi echo "Using image from local cache"
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumifi
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi# Unpack the rootfs
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumiecho "Unpacking the rootfs"
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumiif [ "$DOWNLOAD_MODE" = "system" ]; then
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi tar --numeric-owner -xpJf ${LXC_CACHE_PATH}/rootfs.tar.xz -C ${LXC_ROOTFS}
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumielse
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi tar --anchored --exclude="./dev/*" --numeric-owner -xpJf \
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi ${LXC_CACHE_PATH}/rootfs.tar.xz -C ${LXC_ROOTFS}
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi mkdir -p ${LXC_ROOTFS}/dev/pts/
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumifi
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi# Setup the configuration
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumiconfigfile=$(relevant_file config)
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumifstab=$(relevant_file fstab)
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumiif [ ! -e $configfile ]; then
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi echo "ERROR: meta tarball is missing the configuration file" 1>&2
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi exit 1
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumifi
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi## Extract all the network config entries
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumised -i -e "/lxc.network/{w ${LXC_PATH}/config-network" -e "d}" \
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi ${LXC_PATH}/config
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi## Extract any other config entry
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumised -i -e "/lxc./{w ${LXC_PATH}/config-auto" -e "d}" ${LXC_PATH}/config
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi## Append the defaults
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumiecho "" >> ${LXC_PATH}/config
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumiecho "# Distribution configuration" >> ${LXC_PATH}/config
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumicat $configfile >> ${LXC_PATH}/config
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi## Add the container-specific config
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumiecho "" >> ${LXC_PATH}/config
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumiecho "# Container specific configuration" >> ${LXC_PATH}/config
dc421f3aac1f0e516c763dd156629a8ed2a7b4caKATOH Yasufumiif [ -e "${LXC_PATH}/config-auto" ]; then
dc421f3aac1f0e516c763dd156629a8ed2a7b4caKATOH Yasufumi cat ${LXC_PATH}/config-auto >> ${LXC_PATH}/config
dc421f3aac1f0e516c763dd156629a8ed2a7b4caKATOH Yasufumi rm ${LXC_PATH}/config-auto
dc421f3aac1f0e516c763dd156629a8ed2a7b4caKATOH Yasufumifi
dc421f3aac1f0e516c763dd156629a8ed2a7b4caKATOH Yasufumiif [ -e "$fstab" ]; then
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi echo "lxc.mount = ${LXC_PATH}/fstab" >> ${LXC_PATH}/config
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumifi
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumiecho "lxc.utsname = ${LXC_NAME}" >> ${LXC_PATH}/config
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi## Re-add the previously removed network config
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumiif [ -e "${LXC_PATH}/config-network" ]; then
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi echo "" >> ${LXC_PATH}/config
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi echo "# Network configuration" >> ${LXC_PATH}/config
dc421f3aac1f0e516c763dd156629a8ed2a7b4caKATOH Yasufumi cat ${LXC_PATH}/config-network >> ${LXC_PATH}/config
dc421f3aac1f0e516c763dd156629a8ed2a7b4caKATOH Yasufumi rm ${LXC_PATH}/config-network
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumifi
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi
57da8c32f85c0255efa61ee32e260068afdaa565KATOH YasufumiTEMPLATE_FILES="${LXC_PATH}/config"
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi# Setup the fstab
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumiif [ -e $fstab ]; then
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi cp ${fstab} ${LXC_PATH}/fstab
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi TEMPLATE_FILES="$TEMPLATE_FILES ${LXC_PATH}/fstab"
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumifi
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi# Look for extra templates
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumiif [ -e "$(relevant_file templates)" ]; then
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi while read line; do
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi fullpath=${LXC_ROOTFS}/$line
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi [ ! -e "$fullpath" ] && continue
dc421f3aac1f0e516c763dd156629a8ed2a7b4caKATOH Yasufumi TEMPLATE_FILES="$TEMPLATE_FILES $fullpath"
dc421f3aac1f0e516c763dd156629a8ed2a7b4caKATOH Yasufumi done < $(relevant_file templates)
dc421f3aac1f0e516c763dd156629a8ed2a7b4caKATOH Yasufumifi
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi# Replace variables in all templates
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumifor file in $TEMPLATE_FILES; do
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi [ ! -e "$file" ] && continue
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi sed -i "s#LXC_NAME#$LXC_NAME#g" $file
dc421f3aac1f0e516c763dd156629a8ed2a7b4caKATOH Yasufumi sed -i "s#LXC_PATH#$LXC_PATH#g" $file
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi sed -i "s#LXC_ROOTFS#$LXC_ROOTFS#g" $file
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi sed -i "s#LXC_TEMPLATE_CONFIG#$LXC_TEMPLATE_CONFIG#g" $file
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi sed -i "s#LXC_HOOK_DIR#$LXC_HOOK_DIR#g" $file
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumidone
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumiif [ -n "$LXC_MAPPED_UID" ] && [ "$LXC_MAPPED_UID" != "-1" ]; then
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi chown $LXC_MAPPED_UID -f $LXC_PATH/config $LXC_PATH/fstab || true
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumifi
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumiif [ -e "$(relevant_file create-message)" ]; then
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi echo ""
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi echo "---"
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi cat "$(relevant_file create-message)"
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumifi
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumiexit 0
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi