#!/bin/bash TTY="" BIMG={{ insecure_registry | default('registry.cn-beijing.aliyuncs.com') }}/{{ registry | default('yunion') }}/openvswitch:2.12.4-20260212 {% if k8s_or_k3s | default('k3s') == 'k3s' %} if [ -t 0 ]; then TTY="-t" fi IMG=$(k3s ctr images list -q | grep -m 1 -w "yunion/openvswitch") if [ -z "$IMG" ]; then IMG=$(k3s ctr images list -q | grep -m 1 -w "yunionio/openvswitch") if [ -z "$IMG" ]; then IMG=$BIMG k3s ctr images list name==$IMG -q | grep $IMG > /dev/null if [ $? -ne 0 ]; then k3s ctr images pull $IMG fi fi fi k3s ctr run --rm --net-host $TTY \ --mount type=bind,src=/tmp,dst=/tmp,options=rbind \ --mount type=bind,src=/etc/openvswitch,dst=/etc/openvswitch,options=rbind \ --mount type=bind,src=/var/run/openvswitch,dst=/var/run/openvswitch,options=rbind \ $IMG \ openvswitch \ /usr/bin/$(basename $0) $@ {% else %} if [ -t 0 ]; then TTY="-it" fi IMG=$(docker image ls --filter 'reference=*/yunion/openvswitch' | grep -m 1 -w "yunion/openvswitch" | awk '{print $1 ":" $2}') if [ -z "$IMG" ]; then IMG=$(docker image ls --filter 'reference=*/yunionio/openvswitch' | grep -m 1 -w "yunionio/openvswitch" | awk '{print $1 ":" $2}') if [ -z "$IMG" ]; then IMG=$BIMG fi fi docker run --rm --network host $TTY \ -v /tmp:/tmp \ -v /etc/openvswitch:/etc/openvswitch \ -v /var/run/openvswitch:/var/run/openvswitch \ $IMG \ /usr/bin/$(basename $0) $@ {% endif %}