~louis/ubuntu/vivid/uvtool/uvtool-lp1317266-doc-backing-img-file

« back to all changes in this revision

Viewing changes to debian/uvtool-libvirt.postinst

  • Committer: Package Import Robot
  • Author(s): Robie Basak
  • Date: 2013-09-20 17:33:54 UTC
  • Revision ID: package-import@ubuntu.com-20130920173354-1eeqk3ary5bdafst
Tags: upstream-0~bzr35
ImportĀ upstreamĀ versionĀ 0~bzr35

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh
 
2
set -e
 
3
 
 
4
define_pool() {
 
5
        if ! virsh -q pool-list --all|grep -q '^uvtool\s'; then
 
6
                # Idempotently create virsh pool
 
7
                tmpfile=`mktemp`
 
8
                echo "<pool type='dir'><name>uvtool</name><target><path>/var/lib/uvtool/libvirt/images</path><permissions><mode>0700</mode></permissions></target></pool>" > "$tmpfile"
 
9
                if ! virsh -q pool-define "$tmpfile"; then
 
10
                        rm -f "$tmpfile"
 
11
                        echo "Failed to define libvirt pool 'uvtool'" >&2
 
12
                        exit 1
 
13
                fi
 
14
                rm -f "$tmpfile"
 
15
        fi
 
16
}
 
17
 
 
18
start_pool() {
 
19
        # Idempotently start virsh pool
 
20
        if ! virsh -q pool-list|grep -q '^uvtool\s'; then
 
21
                if ! virsh -q pool-start uvtool; then
 
22
                        echo "Failed to start libvirt pool 'uvtool'" >&2
 
23
                        exit 1
 
24
                fi
 
25
        fi
 
26
}
 
27
 
 
28
if [ "$1" = configure ]; then
 
29
        mkdir -p /var/lib/uvtool/libvirt/images
 
30
        if [ ! -e /var/lib/uvtool/libvirt/metadata ]; then
 
31
                mkdir -pm775 /var/lib/uvtool/libvirt/metadata
 
32
                chown root.libvirtd /var/lib/uvtool/libvirt/metadata
 
33
        fi
 
34
        define_pool
 
35
        virsh -q pool-autostart uvtool # this is idempotent
 
36
        start_pool
 
37
fi
 
38
 
 
39
#DEBHELPER#