[lxc-devel] [PATCH 1/1] lxc-ubuntu-cloud: get full pathname to userdata file

Serge Hallyn serge.hallyn at canonical.com
Thu Aug 30 16:04:47 UTC 2012


When passing '--userdata somefile' to the ubuntu-cloud template, a user
may pass a relative pathname.  The template uses the filename after
changing current directory, so store the full pathname for the userdata
file instead of a potential relative pathname.

Signed-off-by: Serge Hallyn <serge.hallyn at ubuntu.com>
---
 templates/lxc-ubuntu-cloud.in |   10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/templates/lxc-ubuntu-cloud.in b/templates/lxc-ubuntu-cloud.in
index 539167e..6431114 100644
--- a/templates/lxc-ubuntu-cloud.in
+++ b/templates/lxc-ubuntu-cloud.in
@@ -218,9 +218,13 @@ if [ "$stream" != "daily" -a "$stream" != "released" ]; then
     exit 1
 fi
 
-if [ -n "$userdata" -a ! -f "$userdata" ]; then
-    echo "Userdata does not exist"
-    exit 1
+if [ -n "$userdata" ]; then
+    if [ ! -f "$userdata" ]; then
+        echo "Userdata ($userdata) does not exist"
+        exit 1
+    else
+        userdata=`readlink -f $userdata`
+    fi
 fi
 
 if [ -z "$path" ]; then
-- 
1.7.10.4





More information about the lxc-devel mailing list