#!/bin/bash CMD=$(basename $0) TAG="v16.2.14" if [[ "$CMD" == *"-14" ]]; then CMD=${CMD%"-14"} TAG="v14.2.22" elif [[ "$CMD" == *"-16" ]]; then CMD=${CMD%"-16"} TAG="v16.2.14" elif [[ "$CMD" == *"-18" ]]; then CMD=${CMD%"-18"} TAG="v18.2.7" fi TTY="" BIMG={{ insecure_registry | default('registry.cn-beijing.aliyuncs.com') }}/{{ registry | default('yunion') }}/ceph:$TAG {% 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/ceph") if [ -z "$IMG" ]; then IMG=$(k3s ctr images list -q | grep -m 1 -w "yunionio/ceph") 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 \ $IMG \ ceph-common \ /usr/bin/$CMD $@ {% else %} if [ -t 0 ]; then TTY="-it" fi IMG=$(docker image ls --filter 'reference=*/yunion/ceph' | grep -m 1 -w "yunion/ceph" | awk '{print $1 ":" $2}') if [ -z "$IMG" ]; then IMG=$(docker image ls --filter 'reference=*/yunionio/ceph' | grep -m 1 -w "yunionio/ceph" | awk '{print $1 ":" $2}') if [ -z "$IMG" ]; then IMG=$BIMG fi fi docker run --rm --network host $TTY \ -v /tmp:/tmp \ $IMG \ /usr/bin/$CMD $@ {% endif %}