Le dimanche 04 décembre 2011 à 12:08 +0100, Daniel Lezcano a écrit :
> On 11/30/2011 01:07 PM, Alexey Shabalin wrote:
> > 2011/10/13 Alexey Shabalin :
> >> 2011/9/27 Greg Kurz :
> >>> On Tue, 2011-09-27 at 14:10 +0200, Frederic Crozat wrote:
> >>>> Le vendredi 26 août 2011 à 16:00 +0400, Alexey Shabalin a écrit :
> >>>>> 2011/8/26 Daniel Lezcano :
> >>>>>> On 08/23/2011 03:56 PM, Alexey Shabalin wrote:
> >>>>>>> Hello.
> >>>>>>> I think the directory /etc better suited for storing configuration
> >>>>>>> files.
> >>>>>>> This patch allows you to specify the location configs as options for
> >>>>>>> ./configure.
> >>>>>> Is this patch to store the configuraton files in /etc/lxc and the
> >>>>>> rootfs
> >>>>>> in /var/lib/lxc ?
> >>>>> yes.
> >>>>> this patch add new option --with-container-path (default /var/lib/lxc)
> >>>>> and change option --with-config-path (default /etc/lxc).
> >>>>> If you want to use configs in /var/lib/lxc, you can use
> >>>>> --with-config-path=/var/lib/lxc.
> >>>> Any status on this patch ?
> >>>>
> >>> I don't have any opinion on this patch, but it's likely to conflict
> >>> with:
> >>>
> >>> http://lxc.git.sourceforge.net/git/gitweb.cgi?p=lxc/lxc;a=commit;h=1c41ddcb4af633ac906f1d7c9ef1dc7d121d7850
> >>>
> >>> I guess it should be rebased and resent.
> >>>
> >>> Cheers.
> >> Update patch.
> > What about this patch?
> > What about move configs to /etc?
> I have to respin it on top of git HEAD.
>
> Just one question: is the default behavior kept ?
No, the default behavior was not kept.
I've took some time and modified the patch to:
- cleanly apply to git (and also modify new templates which were added since
initial submission)
- ensure the default behavior is kept
- author is still Alexey in the git commit
--
Frederic Crozat <fcro...@suse.com>
SUSE
>From fb751c5a8679e777e4d0a65c84ea31f7ded8ec87 Mon Sep 17 00:00:00 2001
From: Alexey Shabalin <sh...@altlinux.org>
Date: Thu, 19 Apr 2012 17:00:32 +0200
Subject: [PATCH] change default path for config files to /etc/lxc
Change --with-config-path in configure for define path for config files.
Add --with-container-path to configure for define path for containers
repository. Allow install config files for containers to /etc/lxc dir.
---
configure.ac | 13 ++++++++++---
src/lxc/Makefile.am | 1 +
src/lxc/lxc-clone.in | 32 +++++++++++++++++---------------
src/lxc/lxc-create.in | 8 +++++---
src/lxc/lxc-destroy.in | 6 ++++--
src/lxc/lxc_execute.c | 2 +-
src/lxc/lxc_restart.c | 2 +-
src/lxc/lxc_start.c | 2 +-
templates/lxc-altlinux.in | 3 ++-
templates/lxc-archlinux.in | 5 +++--
templates/lxc-busybox.in | 11 ++++++-----
templates/lxc-debian.in | 7 ++++---
templates/lxc-fedora.in | 5 +++--
templates/lxc-lenny.in | 7 ++++---
templates/lxc-opensuse.in | 11 ++++++-----
templates/lxc-sshd.in | 9 +++++----
templates/lxc-ubuntu-cloud.in | 15 ++++++++-------
templates/lxc-ubuntu.in | 17 +++++++++--------
18 files changed, 90 insertions(+), 66 deletions(-)
diff --git a/configure.ac b/configure.ac
index e8f0cb5..0798cae 100644
--- a/configure.ac
+++ b/configure.ac
@@ -49,8 +49,14 @@ AS_AC_EXPAND(DOCDIR, $docdir)
AC_ARG_WITH([config-path],
[AC_HELP_STRING(
[--with-config-path=dir],
- [lxc configuration repository path]
- )], [], [with_config_path=['${localstatedir}/lib/lxc']])
+ [lxc configuration files path]
+ )], [], [with_config_path="${localstatedir}/lib/lxc"])
+
+AC_ARG_WITH([container-path],
+ [AC_HELP_STRING(
+ [--with-container-path=dir],
+ [lxc containers repository path]
+ )], [], [with_container_path="${localstatedir}/lib/lxc"])
AC_ARG_WITH([rootfs-path],
[AC_HELP_STRING(
@@ -60,7 +66,8 @@ AC_ARG_WITH([rootfs-path],
AS_AC_EXPAND(LXC_GENERATE_DATE, "$(date)")
-AC_SUBST(LXCPATH, "${with_config_path}")
+AC_SUBST(LXCETCPATH, "${with_config_path}")
+AC_SUBST(LXCPATH, "${with_container_path}")
AC_SUBST(LXCROOTFSMOUNT, "${with_rootfs_path}")
AC_SUBST(LXCINITDIR, ['${libexecdir}/lxc'])
AC_SUBST(LXCTEMPLATEDIR, ['${libdir}/lxc/templates'])
diff --git a/src/lxc/Makefile.am b/src/lxc/Makefile.am
index 3a3816e..c6d05ab 100644
--- a/src/lxc/Makefile.am
+++ b/src/lxc/Makefile.am
@@ -58,6 +58,7 @@ liblxc_so_SOURCES = \
AM_CFLAGS=-I$(top_srcdir)/src \
-DLXCROOTFSMOUNT=\"$(LXCROOTFSMOUNT)\" \
-DLXCPATH=\"$(LXCPATH)\" \
+ -DLXCETCPATH=\"$(LXCETCPATH)\" \
-DLXCINITDIR=\"$(LXCINITDIR)\"
liblxc_so_CFLAGS = -fPIC -DPIC $(AM_CFLAGS)
diff --git a/src/lxc/lxc-clone.in b/src/lxc/lxc-clone.in
index 386be30..c5bc2ab 100644
--- a/src/lxc/lxc-clone.in
+++ b/src/lxc/lxc-clone.in
@@ -46,6 +46,7 @@ shortoptions='ho:n:sL:v:p:t:'
longoptions='help,orig:,name:,snapshot,fssize:,vgname:,lvprefix:,fstype:'
localstatedir=@LOCALSTATEDIR@
lxc_path=@LXCPATH@
+config_path=@LXCETCPATH@
bindir=@BINDIR@
snapshot=no
lxc_size=2G
@@ -141,12 +142,12 @@ if [ ! -r $lxc_path ]; then
exit 1
fi
-if [ ! -d "$lxc_path/$lxc_orig" ]; then
+if [ ! -d "$lxc_path/$lxc_orig" -o ! -f "$config_path/$lxc_orig/config" ]; then
echo "'$lxc_orig' does not exist"
exit 1
fi
-if [ -d "$lxc_path/$lxc_new" ]; then
+if [ -d "$lxc_path/$lxc_new" -o -f "$config_path/$lxc_new/config" ]; then
echo "'$lxc_new' already exists"
exit 1
fi
@@ -172,18 +173,19 @@ cleanup() {
trap cleanup SIGHUP SIGINT SIGTERM
mkdir -p $lxc_path/$lxc_new
+mkdir -p $config_path/$lxc_new
hostname=$lxc_new
echo "Tweaking configuration"
-cp $lxc_path/$lxc_orig/config $lxc_path/$lxc_new/config
-sed -i '/lxc.utsname/d' $lxc_path/$lxc_new/config
-echo "lxc.utsname = $hostname" >> $lxc_path/$lxc_new/config
+cp $config_path/$lxc_orig/config $config_path/$lxc_new/config
+sed -i '/lxc.utsname/d' $config_path/$lxc_new/config
+echo "lxc.utsname = $hostname" >> $config_path/$lxc_new/config
-grep "lxc.mount =" $lxc_path/$lxc_new/config >/dev/null 2>&1 && { sed -i '/lxc.mount =/d' $lxc_path/$lxc_new/config; echo "lxc.mount = $lxc_path/$lxc_new/fstab" >> $lxc_path/$lxc_new/config; }
+grep "lxc.mount =" $config_path/$lxc_new/config >/dev/null 2>&1 && { sed -i '/lxc.mount =/d' $config_path/$lxc_new/config; echo "lxc.mount = $config_path/$lxc_new/fstab" >> $config_path/$lxc_new/config; }
-if [ -e $lxc_path/$lxc_orig/fstab ];then
- cp $lxc_path/$lxc_orig/fstab $lxc_path/$lxc_new/fstab
- sed -i "s@$lxc_path/$lxc_orig@$lxc_path/$lxc_new@" $lxc_path/$lxc_new/fstab
+if [ -e $config_path/$lxc_orig/fstab ];then
+ cp $config_path/$lxc_orig/fstab $config_path/$lxc_new/fstab
+ sed -i "s@$config_path/$lxc_orig@$config_path/$lxc_new@" $config_path/$lxc_new/fstab
fi
echo "Copying rootfs..."
@@ -192,8 +194,8 @@ rootfs=$lxc_path/$lxc_new/rootfs
container_running=True
lxc-info -s -n $lxc_orig|grep RUNNING >/dev/null 2>&1 || container_running=False
-sed -i '/lxc.rootfs/d' $lxc_path/$lxc_new/config
-oldroot=`grep lxc.rootfs $lxc_path/$lxc_orig/config | awk -F= '{ print $2 '}`
+sed -i '/lxc.rootfs/d' $config_path/$lxc_new/config
+oldroot=`grep lxc.rootfs $config_path/$lxc_orig/config | awk -F= '{ print $2 '}`
if [ -b $oldroot ]; then
type vgscan || { echo "Please install lvm"; false; }
lvdisplay $oldroot > /dev/null 2>&1 || { echo "non-lvm blockdev cloning not supported"; false; }
@@ -214,7 +216,7 @@ if [ -b $oldroot ]; then
mount /dev/$lxc_vg/${lxc_lv_prefix}${lxc_new}_snapshot ${rootfs}_snapshot || { echo "failed to mount new rootfs_snapshot"; false; }
#create a new lv
lvcreate -L $lxc_size $lxc_vg -n ${lxc_lv_prefix}$lxc_new
- echo "lxc.rootfs = /dev/$lxc_vg/${lxc_lv_prefix}$lxc_new" >> $lxc_path/$lxc_new/config
+ echo "lxc.rootfs = /dev/$lxc_vg/${lxc_lv_prefix}$lxc_new" >> $config_path/$lxc_new/config
# and mount it so we can tweak it
mkdir -p $lxc_path/$lxc_new/rootfs
mkfs -t $fstype /dev/$lxc_vg/${lxc_lv_prefix}$lxc_new
@@ -226,7 +228,7 @@ if [ -b $oldroot ]; then
lvremove -f $lxc_vg/${lxc_lv_prefix}${lxc_new}_snapshot
else
lvrename $lxc_vg/${lxc_lv_prefix}${lxc_new}_snapshot $lxc_vg/${lxc_lv_prefix}$lxc_new
- echo "lxc.rootfs = /dev/$lxc_vg/${lxc_lv_prefix}$lxc_new" >> $lxc_path/$lxc_new/config
+ echo "lxc.rootfs = /dev/$lxc_vg/${lxc_lv_prefix}$lxc_new" >> $config_path/$lxc_new/config
# and mount it so we can tweak it
mkdir -p $lxc_path/$lxc_new/rootfs
mount /dev/$lxc_vg/${lxc_lv_prefix}$lxc_new $rootfs || { echo "failed to mount new rootfs"; false; }
@@ -236,7 +238,7 @@ if [ -b $oldroot ]; then
elif out=$(btrfs subvolume list "$lxc_path/$lxc_orig/rootfs" 2>&1); then
out=$(btrfs subvolume snapshot "$lxc_path/$lxc_orig/rootfs" "$rootfs" 2>&1) || { echo "failed btrfs snapshot"; false; }
- echo "lxc.rootfs = $rootfs" >> "$lxc_path/$lxc_new/config"
+ echo "lxc.rootfs = $rootfs" >> "$config_path/$lxc_new/config"
else
if [ $snapshot = "yes" ]; then
@@ -249,7 +251,7 @@ else
fi
mkdir -p $lxc_path/$lxc_new/rootfs/
rsync -ax $lxc_path/$lxc_orig/rootfs/ $lxc_path/$lxc_new/rootfs/
- echo "lxc.rootfs = $rootfs" >> $lxc_path/$lxc_new/config
+ echo "lxc.rootfs = $rootfs" >> $config_path/$lxc_new/config
if [ $container_running = "True" ]; then
lxc-unfreeze -n $lxc_orig
frozen=0
diff --git a/src/lxc/lxc-create.in b/src/lxc/lxc-create.in
index 9b12e5f..bd97878 100644
--- a/src/lxc/lxc-create.in
+++ b/src/lxc/lxc-create.in
@@ -67,6 +67,7 @@ shortoptions='hn:f:t:B:'
longoptions='help,name:,config:,template:,backingstore:,fstype:,lvname:,vgname:,fssize:'
localstatedir=@LOCALSTATEDIR@
lxc_path=@LXCPATH@
+lxc_etc_path=@LXCETCPATH@
bindir=@BINDIR@
libdir=@LIBDIR@
templatedir=@LXCTEMPLATEDIR@
@@ -173,7 +174,7 @@ case "$backingstore" in
;;
esac
-if [ -d "$lxc_path/$lxc_name" ]; then
+if [ -d "$lxc_path/$lxc_name" -o -d "$lxc_etc_path/$lxc_name" ]; then
echo "'$lxc_name' already exists"
exit 1
fi
@@ -242,16 +243,17 @@ cleanup() {
trap cleanup SIGHUP SIGINT SIGTERM
mkdir -p $lxc_path/$lxc_name
+mkdir -p $lxc_etc_path/$lxc_name
if [ -z "$lxc_config" ]; then
- touch $lxc_path/$lxc_name/config
+ touch $lxc_etc_path/$lxc_name/config
else
if [ ! -r "$lxc_config" ]; then
echo "'$lxc_config' configuration file not found"
exit 1
fi
- cp $lxc_config $lxc_path/$lxc_name/config
+ cp $lxc_config $lxc_etc_path/$lxc_name/config
fi
# Create the fs as needed
diff --git a/src/lxc/lxc-destroy.in b/src/lxc/lxc-destroy.in
index b0f2da5..4c87e4f 100644
--- a/src/lxc/lxc-destroy.in
+++ b/src/lxc/lxc-destroy.in
@@ -39,6 +39,7 @@ shortoptions='n:f'
longoptions='name:'
localstatedir=@LOCALSTATEDIR@
lxc_path=@LXCPATH@
+lxc_etc_path=@LXCETCPATH@
force=0
getopt=$(getopt -o $shortoptions --longoptions $longoptions -- "$@")
@@ -77,7 +78,7 @@ if [ -z "$lxc_name" ]; then
exit 1
fi
-if [ ! -d "$lxc_path/$lxc_name" ]; then
+if [ ! -d "$lxc_path/$lxc_name" -o ! -f "$lxc_etc_path/$lxc_name/config" ]; then
echo "'$lxc_name' does not exist"
exit 1
fi
@@ -96,7 +97,7 @@ fi
# Deduce the type of rootfs
# If LVM partition, destroy it. If anything else, ignore it. We'll support
# deletion of others later.
-rootdev=`grep lxc.rootfs $lxc_path/$lxc_name/config 2>/dev/null | sed -e 's/^[^/]*/\//'`
+rootdev=`grep lxc.rootfs $lxc_etc_path/$lxc_name/config 2>/dev/null | sed -e 's/^[^/]*/\//'`
if [ ! -z "$rootdev" ]; then
if [ -b "$rootdev" -o -h "$rootdev" ]; then
lvdisplay $rootdev > /dev/null 2>&1
@@ -108,3 +109,4 @@ if [ ! -z "$rootdev" ]; then
fi
# recursively remove the container to remove old container configuration
rm -rf --one-file-system --preserve-root $lxc_path/$lxc_name
+rm -rf --one-file-system --preserve-root $lxc_etc_path/$lxc_name
diff --git a/src/lxc/lxc_execute.c b/src/lxc/lxc_execute.c
index 1eb25a7..bba5e18 100644
--- a/src/lxc/lxc_execute.c
+++ b/src/lxc/lxc_execute.c
@@ -109,7 +109,7 @@ int main(int argc, char *argv[])
else {
int rc;
- rc = asprintf(&rcfile, LXCPATH "/%s/config", my_args.name);
+ rc = asprintf(&rcfile, LXCETCPATH "/%s/config", my_args.name);
if (rc == -1) {
SYSERROR("failed to allocate memory");
return -1;
diff --git a/src/lxc/lxc_restart.c b/src/lxc/lxc_restart.c
index 7548682..31c8143 100644
--- a/src/lxc/lxc_restart.c
+++ b/src/lxc/lxc_restart.c
@@ -132,7 +132,7 @@ int main(int argc, char *argv[])
else {
int rc;
- rc = asprintf(&rcfile, LXCPATH "/%s/config", my_args.name);
+ rc = asprintf(&rcfile, LXCETCPATH "/%s/config", my_args.name);
if (rc == -1) {
SYSERROR("failed to allocate memory");
return -1;
diff --git a/src/lxc/lxc_start.c b/src/lxc/lxc_start.c
index 7559444..c961de9 100644
--- a/src/lxc/lxc_start.c
+++ b/src/lxc/lxc_start.c
@@ -136,7 +136,7 @@ int main(int argc, char *argv[])
else {
int rc;
- rc = asprintf(&rcfile, LXCPATH "/%s/config", my_args.name);
+ rc = asprintf(&rcfile, LXCETCPATH "/%s/config", my_args.name);
if (rc == -1) {
SYSERROR("failed to allocate memory");
return err;
diff --git a/templates/lxc-altlinux.in b/templates/lxc-altlinux.in
index 3aba77b..2d8f314 100644
--- a/templates/lxc-altlinux.in
+++ b/templates/lxc-altlinux.in
@@ -28,6 +28,7 @@
arch=$(arch)
cache_base=/var/cache/lxc/altlinux/$arch
default_path=@LXCPATH@
+default_config_path=@LXCETCPATH@
default_profile=default
profile_dir=/etc/lxc/profiles
root_password=rooter
@@ -421,7 +422,7 @@ if [ "$(id -u)" != "0" ]; then
fi
rootfs_path=$path/$name/rootfs
-config_path=$default_path/$name
+config_path=$default_config_path/$name
cache=$cache_base/$release/$profile
if [ -f $config_path/config ]; then
diff --git a/templates/lxc-archlinux.in b/templates/lxc-archlinux.in
index 095880a..1300c99 100644
--- a/templates/lxc-archlinux.in
+++ b/templates/lxc-archlinux.in
@@ -29,7 +29,8 @@ arch=$(arch)
cache=/var/cache/lxc/arch/${arch}
lxc_network_type="veth"
lxc_network_link="br0"
-default_path=/var/lib/lxc
+default_path=@LXCPATH@
+default_config_path=@LXCETCPATH@
default_rc_locale="en-US.UTF-8"
default_rc_timezone="UTC"
host_mirror="http://mirrors.kernel.org/archlinux/\$repo/os/$arch"
@@ -419,7 +420,7 @@ if [ "${EUID}" != "0" ]; then
fi
rootfs_path="${path}/rootfs"
-config_path="${default_path}/${name}"
+config_path="${default_config_path}/${name}"
revert()
{
diff --git a/templates/lxc-busybox.in b/templates/lxc-busybox.in
index 720ceef..ccd5830 100644
--- a/templates/lxc-busybox.in
+++ b/templates/lxc-busybox.in
@@ -224,11 +224,11 @@ configure_busybox()
copy_configuration()
{
- path=$1
+ config_path=$1
rootfs=$2
name=$3
-cat <<EOF >> $path/config
+cat <<EOF >> $config_path/$name/config
lxc.utsname = $name
lxc.tty = 1
lxc.pts = 1
@@ -236,14 +236,14 @@ lxc.rootfs = $rootfs
EOF
if [ -d "$rootfs/lib" ]; then
-cat <<EOF >> $path/config
+cat <<EOF >> $config_path/$name/config
lxc.mount.entry=/lib $rootfs/lib none ro,bind 0 0
lxc.mount.entry=/usr/lib $rootfs/usr/lib none ro,bind 0 0
EOF
fi
if [ -d "/lib64" ] && [ -d "$rootfs/lib64" ]; then
-cat <<EOF >> $path/config
+cat <<EOF >> $config_path/$name/config
lxc.mount.entry=/lib64 $rootfs/lib64 none ro,bind 0 0
lxc.mount.entry=/usr/lib64 $rootfs/usr/lib64 none ro,bind 0 0
EOF
@@ -287,6 +287,7 @@ if [ -z "$path" ]; then
fi
rootfs=$path/rootfs
+config_path=@LXCETCPATH@
install_busybox $rootfs $name
if [ $? -ne 0 ]; then
@@ -300,7 +301,7 @@ if [ $? -ne 0 ]; then
exit 1
fi
-copy_configuration $path $rootfs $name
+copy_configuration $config_path $rootfs $name
if [ $? -ne 0 ]; then
echo "failed to write configuration file"
exit 1
diff --git a/templates/lxc-debian.in b/templates/lxc-debian.in
index b97bbac..2a1e198 100644
--- a/templates/lxc-debian.in
+++ b/templates/lxc-debian.in
@@ -185,11 +185,11 @@ install_debian()
copy_configuration()
{
- path=$1
+ config_path=$1
rootfs=$2
hostname=$3
- cat <<EOF >> $path/config
+ cat <<EOF >> $config_path/config
lxc.tty = 4
lxc.pts = 1024
lxc.rootfs = $rootfs
@@ -296,6 +296,7 @@ if [ "$(id -u)" != "0" ]; then
fi
rootfs=$path/rootfs
+config_path=@LXCETCPATH@
install_debian $rootfs
if [ $? -ne 0 ]; then
@@ -309,7 +310,7 @@ if [ $? -ne 0 ]; then
exit 1
fi
-copy_configuration $path $rootfs $name
+copy_configuration $config_path $rootfs $name
if [ $? -ne 0 ]; then
echo "failed write configuration file"
exit 1
diff --git a/templates/lxc-fedora.in b/templates/lxc-fedora.in
index 3f50895..17d7fe9 100644
--- a/templates/lxc-fedora.in
+++ b/templates/lxc-fedora.in
@@ -28,7 +28,8 @@
#Configurations
arch=$(arch)
cache_base=/var/cache/lxc/fedora/$arch
-default_path=/var/lib/lxc
+default_path=@LXCPATH@
+default_config_path=@LXCETCPATH@
root_password=rooter
lxc_network_type=veth
lxc_network_link=virbr0
@@ -367,7 +368,7 @@ fi
rootfs_path=$path/rootfs
-config_path=$default_path/$name
+config_path=$default_config_path/$name
cache=$cache_base/$release
revert()
diff --git a/templates/lxc-lenny.in b/templates/lxc-lenny.in
index 3720dce..b9bc4a2 100644
--- a/templates/lxc-lenny.in
+++ b/templates/lxc-lenny.in
@@ -174,11 +174,11 @@ install_debian()
copy_configuration()
{
- path=$1
+ config_path=$1
rootfs=$2
name=$3
- cat <<EOF >> $path/config
+ cat <<EOF >> $config_path/$name/config
lxc.tty = 4
lxc.pts = 1024
lxc.rootfs = $rootfs
@@ -284,6 +284,7 @@ if [ "$(id -u)" != "0" ]; then
fi
rootfs=$path/rootfs
+config_path=@LXCETCPATH@
install_debian $rootfs
if [ $? -ne 0 ]; then
@@ -297,7 +298,7 @@ if [ $? -ne 0 ]; then
exit 1
fi
-copy_configuration $path $rootfs
+copy_configuration $config_path $rootfs $name
if [ $? -ne 0 ]; then
echo "failed write configuration file"
exit 1
diff --git a/templates/lxc-opensuse.in b/templates/lxc-opensuse.in
index 120b2c7..142174d 100644
--- a/templates/lxc-opensuse.in
+++ b/templates/lxc-opensuse.in
@@ -250,17 +250,17 @@ install_opensuse()
copy_configuration()
{
- path=$1
+ config_path=$1
rootfs=$2
name=$3
- cat <<EOF >> $path/config
+ cat <<EOF >> $config_path/$name/config
lxc.utsname = $name
lxc.tty = 4
lxc.pts = 1024
lxc.rootfs = $rootfs
-lxc.mount = $path/fstab
+lxc.mount = $config_path/$name/fstab
lxc.cgroup.devices.deny = a
# /dev/null and zero
@@ -280,7 +280,7 @@ lxc.cgroup.devices.allow = c 5:2 rwm
lxc.cgroup.devices.allow = c 254:0 rwm
EOF
- cat <<EOF > $path/fstab
+ cat <<EOF > $config_path/$name/fstab
proc $rootfs/proc proc nodev,noexec,nosuid 0 0
sysfs $rootfs/sys sysfs defaults 0 0
EOF
@@ -365,6 +365,7 @@ if [ "$(id -u)" != "0" ]; then
fi
rootfs=$path/rootfs
+config_path=@LXCETCPATH@
install_opensuse $rootfs
if [ $? -ne 0 ]; then
@@ -378,7 +379,7 @@ if [ $? -ne 0 ]; then
exit 1
fi
-copy_configuration $path $rootfs $name
+copy_configuration $config_path $rootfs $name
if [ $? -ne 0 ]; then
echo "failed write configuration file"
exit 1
diff --git a/templates/lxc-sshd.in b/templates/lxc-sshd.in
index bd5d293..8f99cae 100644
--- a/templates/lxc-sshd.in
+++ b/templates/lxc-sshd.in
@@ -93,11 +93,11 @@ EOF
copy_configuration()
{
- path=$1
+ config_path=$1
rootfs=$2
name=$3
-cat <<EOF >> $path/config
+cat <<EOF >> $config_path/$name/config
lxc.utsname = $name
lxc.pts = 1024
lxc.rootfs = $rootfs
@@ -111,7 +111,7 @@ lxc.mount.entry=@LXCTEMPLATEDIR@/lxc-sshd $rootfs/sbin/init none bind 0 0
EOF
if [ "$(uname -m)" = "x86_64" ]; then
- cat <<EOF >> $path/config
+ cat <<EOF >> $config_path/$name/config
lxc.mount.entry=/lib64 $rootfs/lib64 none ro,bind 0 0
EOF
fi
@@ -172,6 +172,7 @@ if [ -z "$path" ]; then
fi
rootfs=$path/rootfs
+config_path=@LXCETCPATH@
install_sshd $rootfs
if [ $? -ne 0 ]; then
@@ -185,7 +186,7 @@ if [ $? -ne 0 ]; then
exit 1
fi
-copy_configuration $path $rootfs $name
+copy_configuration $config_path $rootfs $name
if [ $? -ne 0 ]; then
echo "failed to write configuration file"
exit 1
diff --git a/templates/lxc-ubuntu-cloud.in b/templates/lxc-ubuntu-cloud.in
index 267dbab..b36eb36 100644
--- a/templates/lxc-ubuntu-cloud.in
+++ b/templates/lxc-ubuntu-cloud.in
@@ -27,7 +27,7 @@ fi
copy_configuration()
{
- path=$1
+ config_path=$1
rootfs=$2
name=$3
arch=$4
@@ -38,20 +38,20 @@ copy_configuration()
# if there is exactly one veth network entry, make sure it has an
# associated hwaddr.
- nics=`grep -e '^lxc\.network\.type[ \t]*=[ \t]*veth' $path/config | wc -l`
+ nics=`grep -e '^lxc\.network\.type[ \t]*=[ \t]*veth' $config_path/config | wc -l`
if [ $nics -eq 1 ]; then
- grep -q "^lxc.network.hwaddr" $path/config || cat <<EOF >> $path/config
+ grep -q "^lxc.network.hwaddr" $config_path/config || cat <<EOF >> $config_path/config
lxc.network.hwaddr= 00:16:3e:$(openssl rand -hex 3| sed 's/\(..\)/\1:/g; s/.$//')
EOF
fi
- cat <<EOF >> $path/config
+ cat <<EOF >> $config_path/config
lxc.utsname = $name
lxc.tty = 4
lxc.pts = 1024
lxc.rootfs = $rootfs
-lxc.mount = $path/fstab
+lxc.mount = $config_path/fstab
lxc.arch = $arch
lxc.cap.drop = sys_module mac_admin
@@ -86,7 +86,7 @@ lxc.cgroup.devices.allow = c 10:228 rwm
lxc.cgroup.devices.allow = c 10:232 rwm
EOF
- cat <<EOF > $path/fstab
+ cat <<EOF > $config_path/fstab
proc $rootfs/proc proc nodev,noexec,nosuid 0 0
sysfs $rootfs/sys sysfs defaults 0 0
EOF
@@ -206,6 +206,7 @@ if [ "$(id -u)" != "0" ]; then
fi
rootfs=$path/rootfs
+config_path=@LXCETCPATH@
type ubuntu-cloudimg-query
type wget
@@ -305,7 +306,7 @@ EOF
) 200>/var/lock/subsys/lxc-ubucloud
-copy_configuration $path $rootfs $name $arch
+copy_configuration $config_path $rootfs $name $arch
echo "Container $name created."
exit 0
diff --git a/templates/lxc-ubuntu.in b/templates/lxc-ubuntu.in
index 3e84e74..531a3ca 100644
--- a/templates/lxc-ubuntu.in
+++ b/templates/lxc-ubuntu.in
@@ -278,7 +278,7 @@ install_ubuntu()
copy_configuration()
{
- path=$1
+ config_path=$1
rootfs=$2
name=$3
arch=$4
@@ -295,21 +295,21 @@ copy_configuration()
# if there is exactly one veth network entry, make sure it has an
# associated hwaddr.
- nics=`grep -e '^lxc\.network\.type[ \t]*=[ \t]*veth' $path/config | wc -l`
+ nics=`grep -e '^lxc\.network\.type[ \t]*=[ \t]*veth' $config_path/config | wc -l`
if [ $nics -eq 1 ]; then
- grep -q "^lxc.network.hwaddr" $path/config || cat <<EOF >> $path/config
+ grep -q "^lxc.network.hwaddr" $config_path/config || cat <<EOF >> $path/config
lxc.network.hwaddr= 00:16:3e:$(openssl rand -hex 3| sed 's/\(..\)/\1:/g; s/.$//')
EOF
fi
- cat <<EOF >> $path/config
+ cat <<EOF >> $config_path/config
lxc.utsname = $name
lxc.devttydir = $ttydir
lxc.tty = 4
lxc.pts = 1024
lxc.rootfs = $rootfs
-lxc.mount = $path/fstab
+lxc.mount = $config_path/fstab
lxc.arch = $arch
lxc.cap.drop = sys_module mac_admin mac_override
@@ -344,7 +344,7 @@ lxc.cgroup.devices.allow = c 10:228 rwm
lxc.cgroup.devices.allow = c 10:232 rwm
EOF
- cat <<EOF > $path/fstab
+ cat <<EOF > $config_path/fstab
proc $rootfs/proc proc nodev,noexec,nosuid 0 0
sysfs $rootfs/sys sysfs defaults 0 0
EOF
@@ -513,7 +513,7 @@ do_bindhome()
# bind-mount the user's path into the container's /home
h=`getent passwd $user | cut -d: -f 6`
mkdir -p $rootfs/$h
- echo "$h $rootfs/$h none bind 0 0" >> $path/fstab
+ echo "$h $rootfs/$h none bind 0 0" >> $config_path/fstab
}
usage()
@@ -625,6 +625,7 @@ if [ "$(id -u)" != "0" ]; then
fi
rootfs=$path/rootfs
+config_path=@LXCETCPATH@
install_ubuntu $rootfs $release $flushcache
if [ $? -ne 0 ]; then
@@ -638,7 +639,7 @@ if [ $? -ne 0 ]; then
exit 1
fi
-copy_configuration $path $rootfs $name $arch $release
+copy_configuration $config_path $rootfs $name $arch $release
if [ $? -ne 0 ]; then
echo "failed write configuration file"
exit 1
--
1.7.7
------------------------------------------------------------------------------
For Developers, A Lot Can Happen In A Second.
Boundary is the first to Know...and Tell You.
Monitor Your Applications in Ultra-Fine Resolution. Try it FREE!
http://p.sf.net/sfu/Boundary-d2dvs2
_______________________________________________
Lxc-devel mailing list
Lxc-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/lxc-devel