From 41db4be212184f3444ca8cb988a8006cd869de6a Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Tue, 30 May 2017 13:34:29 +0200 Subject: Determine group dynamically --- hel/recv-media.nix | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'hel') diff --git a/hel/recv-media.nix b/hel/recv-media.nix index 5d2d2ea2..d30da5eb 100644 --- a/hel/recv-media.nix +++ b/hel/recv-media.nix @@ -27,6 +27,7 @@ writeScriptBin "recv-media" '' [[ -z "$1" || -z "$2" ]] && exit 2 dir=/var/media + group=$(stat -c '%G' $dir) tmpFile="''${dir}"/.tmp/$(basename "$1") target="''${dir}"/$(basename "$1") @@ -37,9 +38,9 @@ writeScriptBin "recv-media" '' $(echo ''${2}) EOF - if [[ $(id -gn) != "media" ]]; then - printf "Primary group is %s, trying to switch to media..." $(id -gn) - exec -- sg media "$0 $*" + if [[ $(id -gn) != $group ]]; then + printf "Primary group is %s, trying to switch to %s..." $(id -gn) $group + exec -- sg $group "$0 $*" fi ( -- cgit v1.2.3