forked from theforeman/foreman-discovery-image
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-release
executable file
·45 lines (39 loc) · 1.65 KB
/
build-release
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
#!/bin/bash
# vim: sw=2:ts=2:et
export repoowner=${1:-theforeman}
export branch=${2:-master} # or tag
export proxy_repo=${3:-nightly}
NAME=foreman-discovery-image
cat >/tmp/firstboot.sh <<EOF
restorecon -RvvF /root/.ssh # a bug in virt-builder
sleep 20 && yum -y install livecd-tools appliance-tools-minimizer \
hardlink git wget pykickstart isomd5sum syslinux \
libguestfs-tools-c grub2-efi-x64 grub2-efi-x64-cdboot shim-x64
git clone https://github.com/$repoowner/$NAME.git -b $branch
pushd $NAME
ver=\$(git describe --abbrev=0 --tags)
./build-livecd fdi-centos7.ks $proxy_repo && sudo ./build-livecd-root \$ver /root
popd
touch /root/DONE
EOF
if [ -f $HOME/.ssh/id_rsa.pub ]; then
SSH="--ssh-inject root:file:$HOME/.ssh/id_rsa.pub"
fi
IMG=/var/lib/libvirt/images/fdi-builder.raw.img
virt-builder centos-7.6 --size 6G --format raw \
--output $IMG \
--hostname fdi-builder \
--firstboot /tmp/firstboot.sh \
--root-password "password:redhat" $SSH
virt-install --import --name fdi-builder --vcpus 2 --ram 2500 \
--disk path=$IMG,format=raw,cache=unsafe \
--os-variant rhel7.6 -w bridge=virbr0 \
--graphics spice,listen=0.0.0.0 --noautoconsole \
--serial tcp,host=:4555,mode=bind,protocol=telnet
echo "VM is now starting, the process will take about 5-15 minutes."
echo "You can watch progress in /root/virt-sysprep-firstboot.log file."
echo "To fetch the artifacts use scp or ssh root@fdi-builder or IP."
echo "You can also connect to telnet port 4555, root pass is 'redhat'."
echo "The script creates file /root/DONE when the process is finished."
echo "The VM and image cannot be reused, create a new one to rebuild."
echo "All the artifacts are created in /root. Have fun!"