This commit is contained in:
Cat /dev/Nulo 2022-09-16 16:06:33 -03:00
parent 540ef75dbf
commit 58330f77e8

View file

@ -9,6 +9,14 @@ function utils.join_table(table, separator)
return string
end
local env_string = ""
local netns_string = ""
local USE_NETNS = os.getenv "USE_NETNS"
if USE_NETNS ~= nil then
env_string = env_string .. "USE_NETNS='"..USE_NETNS.."' "
netns_string = "ip netns exec "..USE_NETNS.." "
end
local user = arg[1]
local container_name = arg[2]
local image_name = arg[3]
@ -20,7 +28,7 @@ end
local prefix = [[
#!/bin/sh
# Generated with ]]..utils.join_table({arg[0], user, container_name, image_name, unpack(arguments)}, " ")..[[
# Generated with ]]..utils.join_table({env_string..arg[0], user, container_name, image_name, unpack(arguments)}, " ")..[[
IMAGE=']]..image_name..[['
@ -37,7 +45,7 @@ local run_script = prefix..[[
chpst -u "$USER:$USER" podman pull "$IMAGE" 2>/dev/stdout || exit $?
chpst -u "$USER:$USER" podman image prune -f 2>/dev/stdout || exit $?
exec chpst -u "$USER:$USER" podman run --tty --rm \
exec ]]..netns_string..[[chpst -u "$USER:$USER" podman run --tty --rm \
--name="$CONTAINER_NAME" \
--replace \
]]..utils.join_table(arguments, " ")..[[ \