github.com/web-platform-tests/wpt.fyi@v0.0.0-20240530210107-70cf978996f1/util/commands.sh (about)

     1  #!/bin/bash
     2  
     3  DOCKER_IMAGE=${DOCKER_IMAGE:-"webplatformtests/wpt.fyi:latest"}
     4  DOCKER_INSTANCE=${DOCKER_INSTANCE:-"wptd-dev-instance"}
     5  WPTD_HOST_WEB_PORT=${WPTD_HOST_WEB_PORT:-"8080"}
     6  WPTD_HOST_GCD_PORT=${WPTD_HOST_GCD_PORT:-"8001"}
     7  WPTD_PATH="$(git rev-parse --show-toplevel)"
     8  
     9  function wptd_chown() {
    10    docker exec -u 0:0 "${DOCKER_INSTANCE}" chown -R $(id -u $USER):$(id -g $USER) $1
    11  }
    12  function wptd_useradd() {
    13    # Allow the exit code of groupadd to be 4 (GID not unique).
    14    docker exec -u 0:0 "${DOCKER_INSTANCE}" groupadd -g $(id -g $USER) user || [ $? == 4 ]
    15    # Add user to audio & video groups to ensure Chrome can use sandbox.
    16    docker exec -u 0:0 "${DOCKER_INSTANCE}" useradd -u $(id -u $USER) -g $(id -g $USER) -G audio,video user
    17    docker exec -u 0:0 "${DOCKER_INSTANCE}" sh -c 'echo "user ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers'
    18  }
    19  function wptd_exec() {
    20    docker exec -u $(id -u $USER) "${DOCKER_INSTANCE}" sh -c "$*"
    21  }
    22  function wptd_exec_it() {
    23    docker exec -it -u $(id -u $USER) "${DOCKER_INSTANCE}" sh -c "$*"
    24  }
    25  # function wptd_run() {}
    26  function wptd_stop() {
    27    docker stop "${DOCKER_INSTANCE}"
    28  }
    29  function wptd_rm() {
    30    docker rm "${DOCKER_INSTANCE}"
    31  }