1
0
mirror of https://github.com/rancher/os.git synced 2025-05-05 06:36:20 +00:00
os/scripts/run

52 lines
1.3 KiB
Plaintext
Raw Normal View History

2015-02-09 04:38:37 +00:00
#!/bin/bash
set -e
set -x
cd $(dirname $0)/..
source scripts/build-common
BASE=$(pwd)
KERNEL=${BASE}/dist/artifacts/vmlinuz
INITRD=${BASE}/dist/artifacts/initrd
2015-02-19 18:26:59 +00:00
NO_COMPRESS_INITRD=${INITRD}.none
2015-02-09 04:38:37 +00:00
HD=${BASE}/build/empty-hd.img
HD_GZ=${ARTIFACTS}/empty-hd.img.gz
INITRD_TMP=${BUILD}/$(sha1sum ${INITRD} | awk '{print $1}')
INITRD_TEST=${BUILD}/initrd.test
if [[ ! -e ${KERNEL} || ! -e ${INITRD} ]]; then
echo "Failed to find ${KERNEL} or ${INITRD}" 1>&2
exit 1
fi
if [ ! -d ${INITRD_TMP} ]; then
mkdir -p ${INITRD_TMP}
pushd ${INITRD_TMP}
2015-02-19 18:26:59 +00:00
if [ -e ${NO_COMPRESS_INITRD} ]; then
cat ${NO_COMPRESS_INITRD} | sudo cpio -idmv
else
xz -dc ${INITRD} | sudo cpio -idmv
fi
2015-02-09 04:38:37 +00:00
rm -f init
popd
fi
cp bin/rancheros ${INITRD_TMP}/init
cd ${INITRD_TMP}
if [ "$1" == "--docker" ]; then
docker build -t rancheros-run .
2015-02-14 16:35:46 +00:00
docker run --rm --privileged -it rancheros-run
2015-02-09 04:38:37 +00:00
else
find | cpio -H newc -o > ${INITRD_TEST}
if [ ! -e ${HD} ]; then
zcat ${HD_GZ} > ${HD}
fi
2015-02-19 18:26:59 +00:00
qemu-system-x86_64 -serial stdio -kernel ${KERNEL} -initrd ${INITRD_TEST} -m 1024 -net nic,vlan=0,model=virtio -net user,vlan=0,hostfwd=tcp::2222-:22,hostname=rancher -drive if=virtio,file=${HD} -machine accel=kvm -cpu host -smp 4 -append "x $@" ${QEMU_ARGS}
2015-02-17 03:49:13 +00:00
2015-02-09 04:38:37 +00:00
fi