github.com/google/syzkaller@v0.0.0-20240517125934-c0f1611a36d6/dashboard/config/openbsd/recreate.sh (about) 1 #!/usr/bin/env bash 2 3 # Copyright 2021 syzkaller project authors. All rights reserved. 4 # Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. 5 6 # Rebuilds ci-openbsd in syzkaller project. Helpfully munges the 7 # .ssh/known_hosts file since the new image has a fresh key. 8 # 9 # DROPS files in the current directory, so best used from a subdir of /tmp. 10 # 11 # The user is expected to have the private key matching 12 # the public keys baked into create-openbsd* scripts and a 13 # section in their .ssh/config similar to this: 14 # Host ci-openbsd 15 # Hostname ci-openbsd # if running on a project VM or the external IP 16 # User syzkaller 17 # IdentityFile ~/.ssh/id_syzkaller 18 19 # Before running first time do: 20 # sudo apt-get install genisoimage growisofs qemu qemu-kvm qemu-system-x86-64 expect 21 22 # The script does not require any arguments/env vars, run just as: 23 # $GOPATH/src/github.com/google/syzkaller/dashboard/config/openbsd/recreate.sh 24 25 set -eux 26 27 TODAY=$(date -u +%Y-%m-%d) 28 29 SYZ_DIR="$(cd "$(dirname "${0}")"/../../..; pwd -P)" 30 [[ -d "${SYZ_DIR}/tools" ]] || { echo "Requires syzkaller dir $SYZ_DIR" ; exit 1; } 31 32 ZONE=us-central1-b 33 INSTANCE=ci-openbsd 34 IP=$(gcloud compute instances describe "${INSTANCE}" --zone="${ZONE}" --project=syzkaller '--format=text(networkInterfaces[].accessConfigs[].natIP)' | cut -f2 -d' ') 35 SERVICE_ACCOUNT=$(gcloud compute instances describe "${INSTANCE}" --zone="${ZONE}" --project=syzkaller '--format=text(serviceAccounts[].email)' | cut -d' ' -f2) 36 IMAGE="${INSTANCE}"-"${TODAY}"-root 37 38 "${SYZ_DIR}"/tools/create-openbsd-gce-ci.sh 39 40 gsutil -u syzkaller cp -a public-read openbsd-amd64-snapshot-gce.tar.gz gs://syzkaller/openbsd-amd64-"${TODAY}"-gce.tar.gz 41 42 ssh root@"${INSTANCE}" halt -p || true 43 44 yes | gcloud compute --project=syzkaller images delete "${IMAGE}" || true 45 gcloud compute --project=syzkaller images create "${IMAGE}" --source-uri gs://syzkaller/"openbsd-amd64-${TODAY}-gce.tar.gz" 46 47 yes | gcloud compute --project=syzkaller instances delete "${INSTANCE}" \ 48 --zone="${ZONE}" 49 gcloud compute --project=syzkaller \ 50 instances create "${INSTANCE}" \ 51 --address="${IP}" \ 52 --private-network-ip "${INSTANCE}"-internal \ 53 --boot-disk-device-name="${INSTANCE}" \ 54 --boot-disk-size=10GB \ 55 --boot-disk-type=pd-ssd \ 56 --disk=name="${INSTANCE}"-syzkaller,device-name="${INSTANCE}"-syzkaller,mode=rw,boot=no \ 57 --image-project=syzkaller \ 58 --image="${IMAGE}" \ 59 --machine-type=custom-12-65536 \ 60 --maintenance-policy=MIGRATE \ 61 --metadata=serial-port-enable=1 \ 62 --network-tier=PREMIUM \ 63 --scopes=https://www.googleapis.com/auth/cloud-platform \ 64 --service-account="${SERVICE_ACCOUNT}" \ 65 --subnet=default \ 66 --zone="${ZONE}" 67 68 (grep -v "^$IP" ~/.ssh/known_hosts && echo "${IP}" "$(grep ssh-ed25519 install_log)") > ~/.ssh/known_hosts.new 69 mv ~/.ssh/known_hosts{.new,} 70 71 "${SYZ_DIR}"/tools/create-openbsd-vmm-worker.sh 72 73 ssh syzkaller@"${INSTANCE}" mkdir -p /syzkaller/userspace 74 ssh syzkaller@"${INSTANCE}" ln -sf /syzkaller/{gopath/src/github.com/google/syzkaller/dashboard/,}config 75 scp worker_key syzkaller@"${INSTANCE}":/syzkaller/userspace/key 76 scp -C worker_disk.raw syzkaller@"${INSTANCE}":/syzkaller/userspace/image 77 ssh syzkaller@"${INSTANCE}" 'D=/syzkaller/userspace-multicore && mkdir -p $D && ln -sf ../userspace/{image,key} $D && ln -sf ../config/openbsd/overlays/ci-openbsd-multicore $D/overlay' 78 ssh root@"${INSTANCE}" reboot