summaryrefslogtreecommitdiffstats
path: root/scripts/sh/generate_libvirt_xml.sh
blob: 4f9b5d36c7208e84ffd32052520b767ead1fc64b (plain)
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/bin/sh

menu() {
        echo "1) Domain XML"
        echo "2) Volume XML (not yet implemented)"
        echo "3) Network XML (not yet implemented"
        echo "x) Exit"
        echo
}

selection() {
        local selection
        echo "Enter [1|2|3|x] "
        read selection
        case $selection in
                1) domain ;;
                2) volume ;;
                3) network ;;
                x) 
                echo "Aborting on user request."
                exit 0
                ;;
                *) echo -e "${RED}Invalid input.${STD}"
        esac
}

#trap '' SIGINT SIGQUIT SIGSTP

domain() {
        local name
        local storelocation
        local store
        local storename
        echo "Name of the new domain: "
        read name
        echo "Storage location of the disk: /mnt/"
        read storelocation
        echo "Storage name of the pool: /mnt/$storelocation/"
        read store
        echo
        echo "Name: $name"
        echo "Disk: /mnt/$storelocation/$store/$name.qcow2"
        echo "Correct? [y|n|x] "
        read confirmation
        case $confirmation in
                y | yes) echo "OK" ;;
                n | no) echo "Starting over" && domain ;;
                x | menu) menu
        esac

        sed -e "s/%%NAME%%/$name/" -e "s/%%STORELOCATION%%/$storelocation/" -e "s/%%STORE%%/$store/" template.xml > $name.xml

        echo "Created $name.xml"
        exit 1
}


while true
do
        menu
        selection
done