diff --git a/dashboard/README.md b/dashboard/README.md index b887e7051..d449a073a 100644 --- a/dashboard/README.md +++ b/dashboard/README.md @@ -1,23 +1,29 @@ -# Updating dashboard +# Sanitizer Dashboard -To build a new binary and upload it to the GCE instance: +The dashboard is automatically built and updated from `master` on the GCE instance via [`start_script.sh`](start_script.sh). -``` -go build --ldflags '-linkmode external -extldflags=-static' && \ -gcloud compute ssh --project "sanitizer-bots" --zone "us-east1-d" dashboard-v2 --command "sudo rm -f /opt/sanitizers" && \ -gcloud compute --project "sanitizer-bots" scp --zone "us-east1-d" sanitizers "dashboard-v2:/opt" && \ -gcloud compute ssh --project "sanitizer-bots" --zone "us-east1-d" dashboard-v2 --command "sudo chown root:root /opt/sanitizers" -``` - -or +## Creating the GCE instance +```bash +gcloud compute instances create dashboard-v3 \ + --project="sanitizer-bots" \ + --zone="us-east1-d" \ + --machine-type="e2-micro" \ + --network-tier="STANDARD" \ + --address="35.207.33.19" \ + --tags="http-server,https-server" \ + --no-service-account \ + --no-scopes \ + --shielded-secure-boot \ + --shielded-vtpm \ + --shielded-integrity-monitoring \ + --image-family="debian-13" \ + --image-project="debian-cloud" \ + --boot-disk-size="10GB" \ + --metadata=startup-script='#! /bin/bash +command -v curl >/dev/null || (apt-get -qq update && apt-get -qq install -y curl) +while true; do + curl -fsSL https://raw.githubusercontent.com/google/sanitizers/master/dashboard/start_script.sh | bash >/var/log/sanitizer-dashboard.log 2>&1 + sleep 600 +done' ``` -go build --ldflags '-linkmode external -extldflags=-static' && \ -gcloud compute config-ssh --remove && gcloud compute config-ssh --force-key-file-overwrite && \ -ssh dashboard-v2.us-east1-d.sanitizer-bots "sudo rm -f /opt/sanitizers" && \ -scp sanitizers "dashboard-v2.us-east1-d.sanitizer-bots:/opt" && \ -ssh dashboard-v2.us-east1-d.sanitizer-bots "sudo chown root:root /opt/sanitizers" -``` - -Note: If you get a message about "scp: /opt/sanitizers: Text file busy", wait a -few seconds and try again. diff --git a/dashboard/start_script.sh b/dashboard/start_script.sh new file mode 100755 index 000000000..6da4578f0 --- /dev/null +++ b/dashboard/start_script.sh @@ -0,0 +1,29 @@ +#!/bin/bash +set -euo pipefail + +if ! command -v go >/dev/null || ! command -v git >/dev/null || ! command -v lighttpd >/dev/null; then + export DEBIAN_FRONTEND=noninteractive + apt-get -qq update + apt-get -qq install -y golang-go git curl lighttpd + rm -f /var/www/html/index.lighttpd.html +fi + +export HOME="${HOME:-/root}" +REPO_DIR="/tmp/sanitizer-dashboard/sanitizers" + +if [[ ! -d "${REPO_DIR}/.git" ]]; then + rm -rf "${REPO_DIR}" + mkdir -p "$(dirname "${REPO_DIR}")" + git clone --depth=1 https://github.com/google/sanitizers.git "${REPO_DIR}" +else + git -C "${REPO_DIR}" fetch --depth=1 origin master + git -C "${REPO_DIR}" reset --hard FETCH_HEAD +fi + +cd "${REPO_DIR}/dashboard" +go build -o /opt/sanitizers . + +mkdir -p /var/www/html +/opt/sanitizers > /var/www/html/index.new.html +chmod 644 /var/www/html/index.new.html +mv -f /var/www/html/index.new.html /var/www/html/index.html