diff --git a/run-builder.sh b/run-builder.sh index f4790eb..352a6a8 100755 --- a/run-builder.sh +++ b/run-builder.sh @@ -19,13 +19,32 @@ else exit 2 fi -GATEWAY_IP=$(podman network inspect org.osbuild.koji --format '{{ (index (index (index .plugins 0).ipam.ranges 0) 0).gateway }}') -echo "Gateway IP is $GATEWAY_IP" +builder_start() { + GATEWAY_IP=$(podman network inspect org.osbuild.koji --format '{{ (index (index (index .plugins 0).ipam.ranges 0) 0).gateway }}') + echo "Gateway IP is $GATEWAY_IP" -${CONTAINER_RUNTIME} run --rm -i -t --name org.osbuild.koji.builder --network org.osbuild.koji \ - -v "${SHARE_DIR}:/share:z" \ - -v "${DATA_DIR}:/mnt:z" \ - -v "${PWD}/container/builder/osbuild-koji.conf:/etc/koji-osbuild/builder.conf:z" \ - --hostname org.osbuild.koji.kojid \ - --add-host=composer:${GATEWAY_IP} \ - koji.builder + ${CONTAINER_RUNTIME} run --rm ${CONTAINER_FLAGS} \ + --name org.osbuild.koji.builder --network org.osbuild.koji \ + -v "${SHARE_DIR}:/share:z" \ + -v "${DATA_DIR}:/mnt:z" \ + -v "${PWD}/container/builder/osbuild-koji.conf:/etc/koji-osbuild/builder.conf:z" \ + --hostname org.osbuild.koji.kojid \ + --add-host=composer:${GATEWAY_IP} \ + koji.builder +} + +builder_stop() { + ${CONTAINER_RUNTIME} stop org.osbuild.koji.builder || true +} + +# default to running in the background +CONTAINER_FLAGS=-d + +if [ $1 == "start" ]; then + builder_start +elif [ $1 == "fg" ]; then + CONTAINER_FLAGS=-it + builder_start +elif [ $1 == "stop" ]; then + builder_stop +fi