fi
fi
-cache_base=@LOCALSTATEDIR@/cache/lxc/centos/$basearch
+# Allow the cache base to be set by environment variable
+cache_base=${LXC_CACHE_PATH:-"@LOCALSTATEDIR@/cache/lxc"}/centos/$basearch
# Let's do something better for the initial root password.
# It's not perfect but it will defeat common scanning brute force
in_userns=0
[ $(am_in_userns) = "yes" ] && in_userns=1
+# Allow the cache base to be set by environment variable
if [ $(id -u) -eq 0 ]; then
- CACHE_D="@LOCALSTATEDIR@/cache/lxc/cirros"
+ CACHE_D=${LXC_CACHE_PATH:-"@LOCALSTATEDIR@/cache/lxc/cirros"}
else
- CACHE_D="$HOME/.cache/lxc/cirros"
+ CACHE_D=${LXC_CACHE_PATH:-"$HOME/.cache/lxc/cirros"}
fi
error() { echo "$@" 1>&2; }
SECURITY_MIRROR=${SECURITY_MIRROR:-http://security.debian.org/}
LOCALSTATEDIR="@LOCALSTATEDIR@"
LXC_TEMPLATE_CONFIG="@LXCTEMPLATECONFIG@"
+# Allows the lxc-cache directory to be set by environment variable
+LXC_CACHE_PATH=${LXC_CACHE_PATH:-"$LOCALSTATEDIR/cache/lxc"}
configure_debian()
{
install_debian()
{
- cache="$LOCALSTATEDIR/cache/lxc/debian"
rootfs=$1
release=$2
arch=$3
+ cache="$4/debian"
mkdir -p $LOCALSTATEDIR/lock/subsys/
(
flock -x 9
clean()
{
- cache="$LOCALSTATEDIR/cache/lxc/debian"
+ cache=${LXC_CACHE_PATH:-"$LOCALSTATEDIR/cache/lxc/debian"}
if [ ! -e $cache ]; then
exit 0
fi
fi
-install_debian $rootfs $release $arch
+install_debian $rootfs $release $arch $LXC_CACHE_PATH
if [ $? -ne 0 ]; then
echo "failed to install debian"
exit 1
LXC_CACHE_BASE="$HOME/.cache/lxc/"
fi
-LXC_CACHE_PATH="$LXC_CACHE_BASE/download/$DOWNLOAD_DIST"
+# Allow the setting of the LXC_CACHE_PATH with the usage of environment variables.
+LXC_CACHE_PATH=${LXC_CACHE_PATH:-"$LXC_CACHE_BASE"}
+LXC_CACHE_PATH=$LXC_CACHE_PATH/download/$DOWNLOAD_DIST
LXC_CACHE_PATH="$LXC_CACHE_PATH/$DOWNLOAD_RELEASE/$DOWNLOAD_ARCH/"
LXC_CACHE_PATH="$LXC_CACHE_PATH/$DOWNLOAD_VARIANT"
fi
fi
-cache_base=@LOCALSTATEDIR@/cache/lxc/fedora/$basearch
+# Allow the cache base to be set by environment variable
+cache_base=${LXC_CACHE_PATH:-"@LOCALSTATEDIR@/cache/lxc"}/fedora/$basearch
# Let's do something better for the initial root password.
# It's not perfect but it will defeat common scanning brute force
-w|--password) forced_password=1; password=$2; shift 2;;
-s|--settings) settings=$2; shift 2;;
-m|--mirror) mirror=$2; shift 2;;
+ --container-cache) containercache=$2; shift 2;;
--tty) [[ $2 -lt 6 ]] && tty=$2; shift 2;;
--autologin) autologin=1; shift 1;;
--) shift 1; break ;;
esac
done
-cacheroot="@LOCALSTATEDIR@/cache/lxc/gentoo"
+# Allow the cache path to be set by environment variable
+cacheroot="${LXC_CACHE_PATH:-"@LOCALSTATEDIR@/cache/lxc"}/gentoo"
portage_cache="${cacheroot}/portage.tbz"
cachefs="${cacheroot}/rootfs-${arch}-${variant}"
#Configurations
#distro=cooker
hostarch=$(uname -m)
-cache_base=@LOCALSTATEDIR@/cache/lxc/openmandriva/$arch
+# Allow the cache base to be set by environment variable
+cache_base="${LXC_CACHE_PATH:-@LOCALSTATEDIR@/cache/lxc/openmandriva/$arch}"
default_path=@LXCPATH@
default_profile=default
root_password=root
install_opensuse()
{
- cache="@LOCALSTATEDIR@/cache/lxc/opensuse/$DISTRO"
+ # Allow the cache base to be set by environment variable
+ cache="${LXC_CACHE_PATH:-@LOCALSTATEDIR@/cache/lxc/opensuse/$DISTRO}"
rootfs=$1
mkdir -p @LOCALSTATEDIR@/lock/subsys/
(
clean()
{
- cache="@LOCALSTATEDIR@/cache/lxc/opensuse"
+ cache="${LXC_CACHE_PATH:-@LOCALSTATEDIR@/cache/lxc/opensuse}"
if [ ! -e $cache ]; then
exit 0
# determine the url, tarball, and directory names
# download if needed
-cache="$STATE_DIR/cache/lxc/cloud-$release"
+# Allow the cache base to be set by environment variable
+cache=${LXC_CACHE_PATH:-"$STATE_DIR/cache/lxc"}/cloud-$release
if [ $in_userns -eq 1 ]; then
- STATE_DIR="$HOME/.cache/lxc/"
- cache="$HOME/.cache/lxc/cloud-$release"
+ STATE_DIR="$HOME/.cache/lxc"
+ cache=${LXC_CACHE_PATH:-"$STATE_DIR"}/cloud-$release
fi
mkdir -p $cache
LOCALSTATEDIR="@LOCALSTATEDIR@"
LXC_TEMPLATE_CONFIG="@LXCTEMPLATECONFIG@"
+# Allows the lxc-cache directory to be set by environment variable
+LXC_CACHE_PATH=${LXC_CACHE_PATH:-"$LOCALSTATEDIR/cache/lxc"}
if [ -r /etc/default/lxc ]; then
. /etc/default/lxc
rootfs=$1
release=$2
flushcache=$3
- cache="$LOCALSTATEDIR/cache/lxc/$release"
+ cache="$4/$release"
mkdir -p $LOCALSTATEDIR/lock/subsys/
(
packages=""
user="ubuntu"
password="ubuntu"
+
while true
do
case "$1" in
fi
fi
-install_ubuntu $rootfs $release $flushcache
+install_ubuntu $rootfs $release $flushcache $LXC_CACHE_PATH
if [ $? -ne 0 ]; then
echo "failed to install ubuntu $release"
exit 1