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

46 lines
1.0 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
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}
lzma -dc ${INITRD} | sudo cpio -idmv
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-14 16:35:46 +00:00
kvm -m 1024 -kernel ${KERNEL} -initrd ${INITRD_TEST} -append "$@" -hda ${HD} -serial stdio -netdev user,id=hostnet0 -device virtio-net-pci,romfile=,netdev=hostnet0
2015-02-09 04:38:37 +00:00
fi