From 70a4d99fe95ed8d992be0e6cc667a2ed1d5d0a70 Mon Sep 17 00:00:00 2001 From: Nulo Date: Fri, 16 Sep 2022 16:22:39 -0300 Subject: [PATCH] group --- runit-podman-gen.lua | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/runit-podman-gen.lua b/runit-podman-gen.lua index dd6f99d..6018798 100755 --- a/runit-podman-gen.lua +++ b/runit-podman-gen.lua @@ -29,6 +29,13 @@ local user = arg[1] local container_name = arg[2] local image_name = arg[3] +local group = user +local GROUP = os.getenv "GROUP" +if GROUP ~= nil then + env_string = env_string .. "GROUP="..GROUP.." " + group = GROUP +end + local arguments = {unpack(arg, 4)} for i=1,#arguments do arguments[i] = "'"..arguments[i].."'" @@ -46,16 +53,18 @@ CONTAINER_NAME=']]..container_name..[[' export USER=']]..user..[[' +export GROUP=']]..group..[[' + export HOME="/home/$USER" cd "$HOME" ]] 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 $? +chpst -u "$USER:$GROUP" podman pull "$IMAGE" 2>/dev/stdout || exit $? +chpst -u "$USER:$GROUP" podman image prune -f 2>/dev/stdout || exit $? -exec ]]..netns_string..[[chpst -u "$USER:$USER" podman run --tty --rm \ +exec ]]..netns_string..[[chpst -u "$USER:$GROUP" podman run --tty --rm \ --name="$CONTAINER_NAME" \ --replace \ ]]..utils.join_table(arguments, " ")..[[ \ @@ -63,8 +72,8 @@ exec ]]..netns_string..[[chpst -u "$USER:$USER" podman run --tty --rm \ ]] local down_script = prefix..[[ -chpst -u "$USER:$USER" podman stop --ignore "$CONTAINER_NAME" 2>/dev/stdout || exit $? -chpst -u "$USER:$USER" podman rm --force --ignore "$CONTAINER_NAME" 2>/dev/stdout || exit $? +chpst -u "$USER:$GROUP" podman stop --ignore "$CONTAINER_NAME" 2>/dev/stdout || exit $? +chpst -u "$USER:$GROUP" podman rm --force --ignore "$CONTAINER_NAME" 2>/dev/stdout || exit $? ]] local function write_script(file_name, content)