run-common 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #!/bin/bash
  2. set -e
  3. HOST_ARCH=${HOST_ARCH:-amd64}
  4. ARCH=${ARCH:-amd64}
  5. declare -A qemuarch=( ["amd64"]="x86_64" ["arm"]="arm" ["arm64"]="aarch64" )
  6. declare -A ttycons=( ["amd64"]="ttyS0" ["arm"]="ttyAMA0" ["arm64"]="ttyAMA0" )
  7. declare -A machine=( ["amd64"]="" ["arm"]="-M virt" ["arm64"]="-M virt" )
  8. declare -A cpu=( ["amd64"]="" ["arm"]="-cpu cortex-a8" ["arm64"]="-cpu cortex-a57" )
  9. declare -A network=(
  10. ["amd64"]="-net nic,vlan=0,model=virtio -net user,vlan=0,hostfwd=tcp::2222-:22,hostname=rancher-dev"
  11. ["arm"]="-netdev user,id=unet,hostfwd=tcp::2222-:22,hostname=rancher-dev -device virtio-net-device,netdev=unet"
  12. )
  13. network["arm64"]=${network["arm"]}
  14. hd_amd64() {
  15. echo "-drive if=virtio,file=$1"
  16. }
  17. hd_arm() {
  18. echo "-drive if=none,id=hd0,file=$1 -device virtio-blk-device,drive=hd0"
  19. }
  20. declare -A hd=( ["amd64"]="hd_amd64" ["arm"]="hd_arm" ["arm64"]="hd_arm" )
  21. cd_amd64() {
  22. echo "-hdc $1"
  23. }
  24. cd_arm() {
  25. echo "-drive if=none,id=cd0,file=$1 -device virtio-blk-device,drive=cd0"
  26. }
  27. declare -A cd=( ["amd64"]="cd_amd64" ["arm"]="cd_arm" ["arm64"]="cd_arm" )
  28. BUILD=build
  29. BASE=$(pwd)
  30. UNAME=$(uname)
  31. KERNEL=${BASE}/build/kernel/vmlinuz
  32. INITRD_SRC=${BASE}/build/initrd
  33. INITRD=${BASE}/build/initrd.tmp
  34. #LINUXMOD=${BASE}/build/kernel/linuxmods
  35. QEMU=1
  36. FORMAT=1
  37. RM_USR=1
  38. REBUILD=1
  39. QEMUARCH=${qemuarch["${ARCH}"]}
  40. TTYCONS=${ttycons["${ARCH}"]}
  41. if [ "$ENGINE_REGISTRY_MIRROR" != "" ]; then
  42. REGISTRY_MIRROR="rancher.bootstrap_docker.registry_mirror=${ENGINE_REGISTRY_MIRROR} rancher.system_docker.registry_mirror=${ENGINE_REGISTRY_MIRROR} rancher.docker.registry_mirror=${ENGINE_REGISTRY_MIRROR}"
  43. fi
  44. DEFAULT_KERNEL_ARGS="printk.devkmsg=on rancher.password=rancher console=tty1 rancher.autologin=tty1 console=${TTYCONS} rancher.autologin=${TTYCONS} ${REGISTRY_MIRROR} "