답변1
-p는 하나의 명령으로 여러 번 추가하는 것을 지원하므로 루프를 사용하여 포트를 하나씩 추가했습니다.
이게 내 코드야
set port_range $_flag_port
if echo $port_range | grep -qs -
set -e port_mapping_tcp
set -e port_mapping_udp
set -e port_mapping
set port_counter 0
for port_arrary in (seq (echo $port_range | awk -F "-" '{print $1}') (echo $port_range | awk -F "-" '{print $2}'))
set port_counter (math $port_counter+1)
set port_mapping_tcp[$port_counter] "-ptcp:$port_arrary"
set port_mapping_udp[$port_counter] "-pudp:$port_arrary"
end
else
if echo $port_range | grep -qs ,
set -e port_mapping_tcp
set -e port_mapping_udp
set -e port_mapping
set port_counter 0
for port_arrary in (echo $port_range | string split ,)
set port_counter (math $port_counter+1)
set port_mapping_tcp[$port_counter] "-ptcp:$port_arrary"
set port_mapping_udp[$port_counter] "-pudp:$port_arrary"
end
else
set port_mapping_tcp "-ptcp:$_flag_port"
set port_mapping_udp "-pudp:$_flag_port"
end
end
sudo systemd-nspawn --resolv-conf=off $port_mapping_tcp $port_mapping_udp -bnq -D $container