-
Notifications
You must be signed in to change notification settings - Fork 1
/
anaconda_install
70 lines (55 loc) · 2.05 KB
/
anaconda_install
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
#!/usr/bin/bash
set -ex
# Kill child processes on exit
trap 'kill $(jobs -pr) || :' SIGINT SIGTERM EXIT
usage() {
echo "Usage: $0 <distro> <releasever> <kickstart> [<dstimage> [<disksize-in-mb>]]"
}
DISTRO=$1
RELEASEVER=$2
KICKSTART=$3
DISK_NAME=$4
DISK_SIZE=$5
VM_RAM=${6:-2048}
VM_SMP=${7:-4}
[[ -f $KICKSTART ]]
[[ ! -f $DISK_NAME ]]
[[ -z "$DISK_SIZE" ]] && egrep "^part.*--grow" $KICKSTART && exit 4
[[ -z "$DISK_SIZE" ]] && DISK_SIZE=$(( 128 + $(sed -n "/^part / s/.*size[ =]\([0-9]\+\).*/\1/ p" $KICKSTART) )) # Assumption: One partition
[[ -n "$DISK_SIZE" ]]
# Fetch the relevant anaconda bits
bash $(dirname $0)/bootstrap_anaconda $DISTRO $RELEASEVER
[[ $KICKSTART != $(basename $KICKSTART) ]] && ln -fvs $KICKSTART $(basename $KICKSTART)
PYPORT=$(( 50000 + $RANDOM % 15000 ))
VNCPORT=$(( $RANDOM % 1000 ))
APPEND="console=ttyS0 quiet"
APPEND+=" cmdline inst.cmdline inst.ks=http://10.0.2.2:$PYPORT/$(basename $KICKSTART) inst.stage2=http://10.0.2.2:$PYPORT/ inst.zram=on"
APPEND+=" $QEMU_APPEND"
sed -i "s#@HOST_HTTP@#http://10.0.2.2:$PYPORT#" $KICKSTART
if [[ -n "$http_proxy" ]];
then
# sed -i "/--proxy/! s#^\(url\|repo\) #\1 --proxy=$http_proxy #" "$KICKSTART"
sed -i "/^export http_proxy/d ; s#%post#%post\\nexport http_proxy=$http_proxy#" "$KICKSTART"
else
sed -i "s/\(.*\) --proxy=\S\+\(.*\)/\1\2/" "$KICKSTART"
sed -i "/^export http_proxy/d" "$KICKSTART"
fi
python -m SimpleHTTPServer $PYPORT &
qemu-img create -f qcow2 $DISK_NAME ${DISK_SIZE}M
QEMU_DRIVE="-drive if=virtio,cache=unsafe,file=$DISK_NAME"
if [[ "$(qemu-system-x86_64 -version)" =~ "version 2.3" ]]; then
QEMU_DRIVE="-drive discard=unmap,cache=unsafe,if=none,id=hd0,file=$DISK_NAME -device virtio-scsi-pci -device scsi-disk,drive=hd0"
fi
qemu-system-x86_64 \
-enable-kvm \
-vnc 0.0.0.0:$VNCPORT \
-serial stdio \
-smp $VM_SMP \
-m $VM_RAM \
-net user -net nic \
-kernel vmlinuz \
-initrd initrd.img \
-device virtio-serial \
-chardev file,id=logfile,path=anaconda.log -device virtserialport,name=org.fedoraproject.anaconda.log.0,chardev=logfile \
$QEMU_DRIVE \
-append "$APPEND"