[lxc-devel] [PATCH] Make lxc.functions return the default lxcpath if /etc/lxc/lxc.conf doesn't provide one
S.Çağlar Onur
caglar at 10ur.org
Mon Apr 1 03:37:09 UTC 2013
From: "S.Çağlar Onur" <caglar at 10ur.org>
Currently it returns the default path only if /etc/lxc/lxc.conf missing.
Since default lxc.conf doesn't contain lxcpath variable (this is at least the case in ubuntu) all tools fails if one doesn't give -P
caglar at qgq:~/Project/lxc/examples$ sudo /usr/bin/lxc-create -n test
lxc-create: no configuration path defined
Signed-off-by: S.Çağlar Onur <caglar at 10ur.org>
---
.gitignore | 1 +
src/lxc/lxc.functions.in | 8 ++++++--
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/.gitignore b/.gitignore
index b54ce3d..6bf0348 100644
--- a/.gitignore
+++ b/.gitignore
@@ -47,6 +47,7 @@ src/lxc/lxc-create
src/lxc/lxc-destroy
src/lxc/lxc-execute
src/lxc/lxc-freeze
+src/lxc/lxc.functions
src/lxc/lxc-info
src/lxc/lxc-init
src/lxc/lxc-kill
diff --git a/src/lxc/lxc.functions.in b/src/lxc/lxc.functions.in
index ffc841a..82ef23c 100644
--- a/src/lxc/lxc.functions.in
+++ b/src/lxc/lxc.functions.in
@@ -26,8 +26,12 @@ templatedir=@LXCTEMPLATEDIR@
lxcinitdir=@LXCINITDIR@
get_default_lxcpath() {
- (grep -v "^#" "$globalconf" 2>/dev/null || echo "lxcpath=@LXCPATH@") | \
- grep "[ \t]*lxcpath[ \t]*=" | awk -F= '{ print $2 }'
+ LXC_PATH=$(grep -v "^#" "$globalconf" 2>/dev/null | grep "[ \t]*lxcpath[ \t]*=")
+ if [ -n "$LXC_PATH" ]; then
+ echo $LXC_PATH | awk -F= '{ print $2 }'
+ else
+ echo @LXCPATH@
+ fi
}
lxc_path=`get_default_lxcpath`
--
1.7.10.4
More information about the lxc-devel
mailing list