forked from kashyapc/virt-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jeos-guest-create.bash
executable file
·253 lines (238 loc) · 4.33 KB
/
jeos-guest-create.bash
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
#!/bin/bash
# Kickstart borrowed(& slightly tweaked) from --
# https://raw.github.com/autotest/virt-test/master/shared/unattended/JeOS-17.ks
# Contact: [email protected]
#
#Check if bridging is configured
show_bridge=`brctl show | awk 'NR==2 {print $1}'`
if [ $? -ne 0 ] ; then
echo "Bridged Networking is not configured, please do so to get an IP similar to your host."
exit 255
fi
#check if no. of arguments are 3
if [ "$#" != 3 ]; then
echo " Please provide the args according to usage"
echo ""
echo " usage: "$0 name distro arch" "
echo ""
echo " where 'name' = f18vm1 "
echo " where 'distro' = f18 "
echo " where 'arch' = x86_64 [OR] i386 "
echo ""
exit 255
fi
name=$1
distro=$2
arch=$3
location1=http://dl.fedoraproject.org/pub/fedora/linux/releases/18/Fedora/$arch/os/
echo "Creating domain $name..."
echo "Disk image will be created as /var/lib/libvirt/images/$name.qcow2"
echo "Location of the OS sources $location2..."
#Disk Image location
diskimage=/var/lib/libvirt/images/$name.qcow2
#Create the qcow2 disk image with preallocation and 'facllocate'(which pre-allocates all the blocks to a file) it for max. performance
echo "Creating qcow2 disk image.."
qemu-img create -f qcow2 -o preallocation=metadata $diskimage 2G
#NOTE : Uncomment the below comment, *if* you want to allocate all the blocks (and marks them unintialized). But this will remove the sparseness
#fallocate -l `ls -al $diskimage | awk '{print $5}'` $diskimage
echo `ls -lash $diskimage`
#!/bin/bash
cat << EOF > fed.ks
install
text
reboot
lang en_US.UTF-8
keyboard us
network --bootproto dhcp
rootpw 123456
firewall --disabled
selinux --disabled
timezone --utc America/New_York
firstboot --disable
bootloader --location=mbr --timeout=0 --append="console=tty0 console=ttyS0,115200 rd_NO_PLYMOUTH"
zerombr
poweroff
clearpart --all --initlabel
part / --fstype=ext4 --grow --asprimary --size=1
%packages
gpgme
hardlink
dmidecode
ethtool
tcpdump
tar
bzip2
-yum-utils
-cryptsetup
-vconfig
-dump
-acpid
-mlocate
-stunnel
-rng-tools
-ntfs-3g
-sos
-jwhois
-fedora-release-notes
-pam_pkcs11
-wireless-tools
-rdist
-mdadm
-dmraid
-ftp
-rsync
-system-config-network-tui
-pam_krb5
-nano
-nc
-PackageKit-yum-plugin
-btrfs-progs
-ypbind
-yum-presto
-microcode_ctl
-finger
-krb5-workstation
-ntfsprogs
-iptstate
-fprintd-pam
-irqbalance
-dosfstools
-mcelog
-smartmontools
-lftp
-unzip
-rsh
-telnet
-setuptool
-bash-completion
-pinfo
-rdate
-system-config-firewall-tui
-nfs-utils
-words
-cifs-utils
-prelink
-wget
-dos2unix
-passwdqc
-coolkey
-symlinks
-pm-utils
-bridge-utils
-zip
-eject
-numactl
-mtr
-sssd
-pcmciautils
-tree
-usbutils
-hunspell
-irda-utils
-time
-man-pages
-yum-langpacks
-talk
-wpa_supplicant
-kbd-misc
-kbd
-slang
-authconfig
-newt
-newt-python
-ntsysv
-libnl3
-tcp_wrappers
-quota
-libpipeline
-man-db
-groff
-less
-plymouth-core-libs
-plymouth
-plymouth-scripts
-libgudev1
-ModemManager
-NetworkManager-glib
-selinux-policy
-selinux-policy-targeted
-crontabs
-cronie
-cronie-anacron
-cyrus-sasl
-sendmail
-netxen-firmware
-linux-firmware
-libdaemon
-avahi-autoipd
-libpcap
-ppp
-libsss_sudo
-sudo
-at
-psacct
-parted
-passwd
-bind-utils
-tmpwatch
-bc
-acl
-attr
-traceroute
-mailcap
-quota-nls
-mobile-broadband-provider-info
-audit
-e2fsprogs-libs
-e2fsprogs
-pciutils-libs
-biosdevname
-pciutils
-dbus-glib
-libdrm
-setserial
-lsof
-ed
-cyrus-sasl-plain
-dnsmasq
-system-config-firewall-base
-hesiod
-libpciaccess
-diffutils
-policycoreutils
-m4
-checkpolicy
-procmail
-libuser
-polkit
%end
%post --interpreter /usr/bin/python
import os
os.system('grubby --remove-args="rhgb quiet" --update-kernel=$(grubby --default-kernel)')
os.system('dhclient')
os.system('chkconfig sshd on')
os.system('iptables -F')
os.system('echo 0 > /selinux/enforce')
os.system('echo Post set up finished > /dev/ttyS0')
os.system('echo Post set up finished > /dev/hvc0')
%end
EOF
#Create the guest
if [ "$distro" = f18 ]; then
virt-install --connect=qemu:///system \
--network=bridge:br0 \
--initrd-inject=./fed.ks \
--extra-args="ks=file:/fed.ks console=tty0 console=ttyS0,115200 serial rd_NO_PLYMOUTH" \
--name=$name \
--disk path=$diskimage,format=qcow2,cache=none \
--ram 2048 \
--vcpus=2 \
--check-cpu \
--accelerate \
--os-type linux \
--os-variant fedora17 \
--cpuset auto \
--hvm \
--location=$location1 \
--nographics
fi