Ubuntu Pastebin

Paste from smoser at Mon, 16 Oct 2017 19:31:16 +0000

Download as text
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
diff --git a/bin/lxc-proposed-snapshot b/bin/lxc-proposed-snapshot
index 32abad5..29f45fe 100755
--- a/bin/lxc-proposed-snapshot
+++ b/bin/lxc-proposed-snapshot
@@ -171,11 +171,19 @@ main() {
     }
     CONTAINER_NAME="$clean"
 
-    # avoid sudo prompt
-    # https://gist.github.com/smoser/e7d368481687ab39dc08#file-mic-lxd
-    sudo mount-image-callback "lxd:$cname" --system-resolvconf mchroot -- \
-        /bin/bash -s chrooted $vflag "${pt[@]}" < "$0" ||
-            return
+    local lxc_ver="" cmd=""
+    lxc_ver=$(lxc --version)
+
+    if dpkg --compare-versions $lxc_ver ge 2.17; then
+        cmd=( lxc-pstart "$cname" -- )
+    else
+        # avoid sudo prompt by following doc at:
+        # https://gist.github.com/smoser/e7d368481687ab39dc08#file-mic-lxd
+        cmd=( sudo mount-image-callback "lxd:$cname" --system-resolvconf
+              mchroot -- )
+    fi
+    "${cmd[@]}" /bin/bash -s chrooted "$vflag" "${pt[@]}" < "$0" ||
+        return
 
     if [ "$publish" = "true" ]; then
         debug 1 "publishing $cname to alias $pubname"
Download as text