~ubuntu-virt/vmbuilder/trunk

« back to all changes in this revision

Viewing changes to sanity-checks

  • Committer: Soren Hansen
  • Date: 2008-06-27 12:47:26 UTC
  • Revision ID: soren.hansen@canonical.com-20080627124726-kj690sepircudc3h
Import python rewrite.. It's not quite at a useful point yet (only cli+kvm+hardy is in a usable state), but it's getting there..

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
validate_arch() {
2
 
        if [ "$1" != amd64 -a "$1" != i386 -a "$1" != lpia ]
3
 
        then
4
 
                echo "Invalid architecture: \"$1\". Valid choices are: amd64 i386 lpia"
5
 
                exit 1
6
 
        fi
7
 
}
8
 
 
9
 
check_dest_dir() {
10
 
        if ! [ -d "`dirname "$1"`" ]
11
 
        then
12
 
                echo "`dirname "$1"` does not exist or is not a directory, so $1 cannot be created"
13
 
                exit 1
14
 
        fi
15
 
        if ! [ -w "`dirname "$1"`" ]
16
 
        then
17
 
                echo "`dirname "$1"` is not writable, so $1 cannot be created"
18
 
                exit 1
19
 
        fi
20
 
}
21
 
 
22
 
check_tmp_dir() {
23
 
        if [ ! -d "$1" ]
24
 
        then
25
 
                echo "\"$1\" is not a directory"
26
 
                exit 1
27
 
        fi
28
 
        if [ ! -w "$1" ]
29
 
        then
30
 
                echo "\"$1\" is not writable"
31
 
                exit 1
32
 
        fi
33
 
}
34
 
 
35
 
#
36
 
# Will verify that $1 is a valid Ubuntu suite,
37
 
# and if not, give the user the list of supported ones
38
 
# and bail out.
39
 
#
40
 
check_suite() {
41
 
        if ! [ -f /usr/share/ubuntu-vm-builder/suites/"$1" ]
42
 
        then
43
 
                usage
44
 
                echo
45
 
                echo "Error: \"$1\" is not a supported suite"
46
 
                echo "Supported suites are:"
47
 
                ls /usr/share/ubuntu-vm-builder/suites/ | cat
48
 
                exit 1
49
 
        fi
50
 
}
51
 
 
52
 
#
53
 
# Will verify that $1 is a valid virtualisatin solution,
54
 
# and if not, give the user the list of supported ones
55
 
# and bail out.
56
 
#
57
 
check_vm() {
58
 
        if ! [ -f /usr/share/ubuntu-vm-builder/vms/"$1" ]
59
 
        then
60
 
                usage
61
 
                echo
62
 
                echo "Error: \"$1\" is not a supported vm"
63
 
                echo "Supported vms are:"
64
 
                ls /usr/share/ubuntu-vm-builder/vms/ | cat
65
 
                exit 1
66
 
        fi
67
 
}