#!/bin/bash appdir=$(cd `dirname $0` && pwd) apptmp='/tmp' vmsize='8G' vmmem='2G' vcpu=`cat /proc/cpuinfo|grep proc|tail -1|awk '{print $NF}'` k8sdsk="${apptmp}/k8s-demo.raw" httpboot='http://ftp.debian.org/debian/dists/stretch/main/installer-amd64/current/images/netboot/debian-installer/amd64' seed='https://git.ix.gs/public/coins-demo/raw/branch/master/contrib/k8s-seed.txt' qemu="${appdir}/contrib/qemu-system-x86_64 -L ${appdir}/contrib/share/qemu -net nic -net user -m ${vmmem} -smp ${vcpu} -localtime -enable-kvm -cpu host,+nx -M pc -vga std -usbdevice tablet -k en-us -hda ${k8sdsk} -boot once=d -nographic" ### installvm() { fallocate -l ${vmsize} ${k8sdsk} echo "Preparing K8S VM..." wget -cO ${apptmp}/kernel ${httpboot}/linux wget -cO ${apptmp}/initrd ${httpboot}/initrd.gz ${qemu} -kernel ${apptmp}/kernel -initrd ${apptmp}/initrd -append "console=ttyS0,115200n8 apt-setup/proposed=true nomodeset fb=false priority=critical locale=en_US url=${seed}" rm -f ${apptmp}/kernel ${apptmp}/initrd } runvm() { echo "Look like we already has VM, let's go" ${qemu} } ### if [ ! -f "${k8sdsk}" ]; then installvm && runvm; else runvm; fi