run-common 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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}/dist/artifacts/vmlinuz
  32. INITRD_SRC=${BASE}/build/initrd
  33. INITRD=${BASE}/build/initrd.tmp
  34. QEMU=1
  35. FORMAT=1
  36. RM_USR=1
  37. REBUILD=1
  38. QEMUARCH=${qemuarch["${ARCH}"]}
  39. TTYCONS=${ttycons["${ARCH}"]}
  40. DEFAULT_KERNEL_ARGS="quiet rancher.password=rancher console=${TTYCONS} rancher.autologin=${TTYCONS}"