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)