From 2496e349cb94498df19ae5b7c39cff044f336983 Mon Sep 17 00:00:00 2001 From: Nulo Date: Fri, 16 Sep 2022 16:17:37 -0300 Subject: [PATCH] dependencies --- runit-podman-gen.lua | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/runit-podman-gen.lua b/runit-podman-gen.lua index c8cc9e2..dd6f99d 100755 --- a/runit-podman-gen.lua +++ b/runit-podman-gen.lua @@ -13,9 +13,17 @@ 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.."' " + env_string = env_string .. "USE_NETNS="..USE_NETNS.." " netns_string = "ip netns exec "..USE_NETNS.." " end +local dependencies_string = "" +local DEPENDENCIES = os.getenv "DEPENDENCIES" +if DEPENDENCIES ~= nil then + env_string = env_string .. "DEPENDENCIES='"..DEPENDENCIES.."' " + for dep in string.gmatch(DEPENDENCIES, "[%w-]+") do + dependencies_string = dependencies_string .. "sv status "..dep.." || exit 1\n" + end +end local user = arg[1] local container_name = arg[2] @@ -30,6 +38,8 @@ local prefix = [[ #!/bin/sh # Generated with ]]..utils.join_table({env_string..arg[0], user, container_name, image_name, unpack(arguments)}, " ")..[[ +]]..dependencies_string..[[ + IMAGE=']]..image_name..[[' CONTAINER_NAME=']]..container_name..[['