forked from coreos/coreos-xhyve
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcoreos-xhyve-run
executable file
·57 lines (50 loc) · 1.68 KB
/
coreos-xhyve-run
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
#!/bin/bash
OPTIND=1
while getopts ":f:" opt; do
case ${opt} in
f)
[[ -r "${OPTARG}" ]] && source "${OPTARG}" || \
echo "Warning: couldn't read \"${OPTARG}\". Ignoring." >&2
;;
\?)
echo "Warning: unsupported option '-${OPTARG}'. Ignoring." >&2
;;
:)
echo "Warning: no cloud-config provided. Ignoring." >&2
esac
done
XHYVE=${XHYVE:-xhyve}
CHANNEL=${CHANNEL:-alpha}
LATEST=$(ls -r imgs/${CHANNEL}.*.vmlinuz | head -n 1 | sed -e "s,.*${CHANNEL}.,," -e "s,.coreos_.*,,")
if [[ -z ${LATEST} ]]; then
echo "Error: couldn't find anything to load locally (${CHANNEL} channel)."
echo " please run 'coreos-xhyve-fetch' first."
exit 1
fi
VERSION=${VERSION:-${LATEST}}
CLOUD_CONFIG=${CLOUD_CONFIG:-https://raw.githubusercontent.com/coreos/coreos-xhyve/master/cloud-init/docker-only.txt}
UUID=${UUID:-$(uuidgen)} && UUID="-U ${UUID}"
[[ -n "${SSHKEY}" ]] && SSHKEY="sshkey=\"${SSHKEY}\""
PAYLOAD=${CHANNEL}.${VERSION}.coreos_production_pxe
VMLINUZ=${PAYLOAD}.vmlinuz
INITRD=${PAYLOAD}_image.cpio.gz
CMDLINE="earlyprintk=serial console=ttyS0 ${SSHKEY} coreos.autologin"
CMDLINE="${CMDLINE} cloud-config-url=${CLOUD_CONFIG}"
MEMORY=${MEMORY:-1024}
MEM="-m ${MEMORY}M"
CPUS=${CPUS:-1}
SMP="-c ${CPUS} -A"
NET="-s 2:0,virtio-net"
PCI_DEV="-s 0:0,hostbridge -s 31,lpc"
LPC_DEV="-l com1,stdio"
if [ -n "$ROOT_HDD" ]; then
ROOT="-s 4,virtio-blk,$ROOT_HDD"
if [ -n "$ROOT_LABEL" ]; then
LOC="LABEL=$ROOT_LABEL"
else
LOC="/dev/vda"
fi
CMDLINE="${CMDLINE} root=$LOC rootfstype=ext4"
fi
EXTRA_ARGS=${EXTRA_ARGS}
${XHYVE} $MEM $SMP $PCI_DEV $LPC_DEV $NET $ROOT $UUID $EXTRA_ARGS -f kexec,imgs/$VMLINUZ,imgs/$INITRD,"$CMDLINE"