diff --git a/runit-podman-gen.lua b/runit-podman-gen.lua index 6ba8b2c..c8cc9e2 100755 --- a/runit-podman-gen.lua +++ b/runit-podman-gen.lua @@ -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, " ")..[[ \