~indicator-multiload/indicator-multiload/trunk

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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#!/bin/bash -e

cd ~/Downloads
for image in *ubuntu*.iso; do
    basename=${image%%.iso}
    uuid=$(uuidgen)
    cat > /tmp/kvm-config.xml << EOF
<domain type='kvm'>
<name>$basename</name>
<uuid>$uuid</uuid>
<memory>7864325</memory>
<currentMemory>7864325</currentMemory>
<vcpu>1</vcpu>
<os>
    <type arch='i686' machine='pc-1.0'>hvm</type>
    <boot dev='cdrom'/>
</os>
<features>
    <acpi/>
    <apic/>
    <pae/>
</features>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>restart</on_crash>
<devices>
    <emulator>/usr/bin/kvm</emulator>
    <disk type='file' device='cdrom'>
    <driver name='qemu' type='raw'/>
    <source file='/home-data/mh21/Downloads/$image'/>
    <target dev='hdc' bus='ide'/>
    <readonly/>
    <alias name='ide0-1-0'/>
    <address type='drive' controller='0' bus='1' unit='0'/>
    </disk>
    <controller type='ide' index='0'>
    <alias name='ide0'/>
    <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
    </controller>
    <interface type='network'>
    <mac address='52:54:00:d6:1a:b7'/>
    <source network='default'/>
    <target dev='vnet0'/>
    <model type='virtio'/>
    <alias name='net0'/>
    <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
    </interface>
    <serial type='pty'>
    <source path='/dev/pts/1'/>
    <target port='0'/>
    <alias name='serial0'/>
    </serial>
    <console type='pty' tty='/dev/pts/1'>
    <source path='/dev/pts/1'/>
    <target type='serial' port='0'/>
    <alias name='serial0'/>
    </console>
    <input type='mouse' bus='ps2'/>
    <graphics type='vnc' port='5900' autoport='yes'/>
    <sound model='ich6'>
    <alias name='sound0'/>
    <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
    </sound>
    <video>
    <model type='vmvga' vram='9216' heads='1'/>
    <alias name='video0'/>
    <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
    </video>
    <memballoon model='virtio'>
    <alias name='balloon0'/>
    <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
    </memballoon>
</devices>
</domain>
EOF

sendkeys() {
    a=
    while (( "$#" )); do
        a="$a KEY_$1"
        shift
    done
    virsh send-key $basename $a > /dev/null
    sleep 1
}

    echo Creating and starting machine $basename...
    virsh create /tmp/kvm-config.xml
    sleep 2
    sendkeys SPACE
    sendkeys F2 ENTER ENTER

    sleep 30

    if [[ $basename == kubuntu* ]]; then
        echo Skipping welcome message...
        sendkeys TAB
        sendkeys TAB
        sendkeys SPACE > /dev/null

        sleep 20

        echo Loading terminal...
        sendkeys LEFTALT F1
        sendkeys T E R M I N A L
        sleep 2
        sendkeys BACKSPACE
        sleep 2
        sendkeys ENTER
    elif [[ $basename == ubuntu* ]]; then
        echo Loading terminal...
        sendkeys LEFTMETA
        sendkeys T E R M
        sleep 1
        sendkeys ENTER
    else
        echo Loading terminal...
        sendkeys LEFTALT F2
        sendkeys X MINUS T E R M I N A L
        sendkeys MINUS E M U L A T O R
        sleep 1
        sendkeys ENTER
    fi

    sleep 2

    echo Installing...
    sendkeys W G E T SPACE
    sendkeys M H 2 1 DOT D E
    sendkeys SLASH I M SPACE
    sendkeys MINUS LEFTSHIFT O SPACE
    sendkeys MINUS LEFTSHIFT BACKSLASH
    sendkeys S H SPACE MINUS ENTER

    echo Hit enter when finished...
    read

    virsh screenshot $basename
    virsh suspend $basename
done