split createhdds.sh into functions, bump Fedora release

This commit is contained in:
Jan Sedlák 2015-08-17 17:19:57 +02:00
parent 269dbbe004
commit 5579572db5

View File

@ -1,4 +1,5 @@
#!/bin/bash
function disk_full {
echo "Creating disk_full.img..."
guestfish <<_EOF_
sparse disk_full.img 10G
@ -15,7 +16,9 @@ mount /dev/sda2 /
write /testfile "Oh, hi Mark"
umount /
_EOF_
}
function disk_freespace {
echo "Creating disk_freespace.img..."
guestfish <<_EOF_
sparse disk_freespace.img 10G
@ -26,14 +29,16 @@ mkfs ext4 /dev/sda1
mount /dev/sda1 /
write /testfile "Hello, world!"
_EOF_
}
echo "Creating disk_f21_minimal.img..."
virt-builder fedora-21 -o disk_f21_minimal.img --update --selinux-relabel --root-password password:weakpassword > /dev/null
function disk_f22_minimal {
echo "Creating disk_f22_minimal.img..."
virt-builder fedora-22 -o disk_f22_minimal.img --update --selinux-relabel --root-password password:weakpassword > /dev/null
expect <<_EOF_
log_user 0
set timeout -1
spawn qemu-kvm -m 2G -nographic disk_f21_minimal.img
spawn qemu-kvm -m 2G -nographic disk_f22_minimal.img
expect "localhost login:"
send "root\r"
@ -43,20 +48,22 @@ expect "~]#"
send "poweroff\r"
expect "reboot: Power down"
_EOF_
}
echo "Creating disk_f21_desktop.img..."
function disk_f22_desktop {
echo "Creating disk_f22_desktop.img..."
# these steps are required
# 1. remove firewalld - firewalld configuration in minimal and desktop are conflicting
# 2. update fedora
# 3. install @Fedora Workstation group
# 4. add new user on first boot
# 5. use expect to do selinux relabelling and to set password for user
virt-builder fedora-21 -o disk_f21_desktop.img --size 10G --run-command "yum -y remove firewalld*" --update --selinux-relabel --install "@^workstation-product-environment" --root-password password:weakpassword --firstboot-command 'useradd -m -p "" ejohn' > /dev/null
virt-builder fedora-22 -o disk_f22_desktop.img --size 10G --run-command "yum -y remove firewalld*" --update --selinux-relabel --install "@^workstation-product-environment" --root-password password:weakpassword --firstboot-command 'useradd -m -p "" ejohn' > /dev/null
expect <<_EOF_
log_user 0
set timeout -1
spawn qemu-kvm -m 2G -nographic disk_f21_desktop.img
spawn qemu-kvm -m 2G -nographic disk_f22_desktop.img
expect "localhost login:"
send "root\r"
@ -68,7 +75,9 @@ send "echo 'ejohn:weakpassword' | chpasswd\r"
send "poweroff\r"
expect "reboot: Power down"
_EOF_
}
function disk_ks {
echo "Creating disk_ks.img..."
curl --silent -o "/tmp/root-user-crypted-net.ks" "https://jskladan.fedorapeople.org/kickstarts/root-user-crypted-net.ks" > /dev/null
guestfish <<_EOF_
@ -80,3 +89,33 @@ mkfs ext4 /dev/sda1
mount /dev/sda1 /
upload /tmp/root-user-crypted-net.ks /root-user-crypted-net.ks
_EOF_
}
if [ "$#" -eq 0 ]; then
disk_full
disk_freespace
disk_f22_minimal
disk_f22_desktop
disk_ks
else
case $1 in
full)
disk_full
;;
freespace)
disk_freespace
;;
minimal)
disk_f22_minimal
;;
desktop)
disk_f22_desktop
;;
ks)
disk_ks
;;
*)
echo "$0 [full|freespace|minimal|desktop|ks]"
;;
esac
fi