#!/bin/bash set -e IMAGE_NAME="zyxel-openwrt-builder" CONTAINER_NAME="openwrt-builder-container" FIRMWARE_PATH="/home/builder/openwrt/bin/brcm963xx/zyxel/ras.bin" echo "Building Docker image ${IMAGE_NAME}..." docker build -t ${IMAGE_NAME} . echo "Starting container..." docker run --cpus="1" -it --name "${CONTAINER_NAME}" \ -e TERM=vt100 \ "${IMAGE_NAME}" \ /bin/bash -c "cd /home/builder/openwrt && \ ./scripts/feeds update -a && \ ./scripts/feeds install -a && \ make -j1 V=sc" docker cp ${CONTAINER_NAME}:.config ./.config-build docker cp ${CONTAINER_NAME}:defconfig.log ./defconfig-build.log docker cp ${CONTAINER_NAME}:${FIRMWARE_PATH} ./build/ras.bin 2>/dev/null || { echo "ERROR: Firmware not found at ${FIRMWARE_PATH}" echo "The build may have failed or the output path is not ${FIRMWARE_PATH}" echo "You can inspect the container manually: docker start -ai ${CONTAINER_NAME}" exit 1 } echo "Firmware copied to ./build/ras.bin"