diff options
author | Gregor Kleen <gkleen@yggdrasil.li> | 2017-05-30 13:34:29 +0200 |
---|---|---|
committer | Gregor Kleen <gkleen@yggdrasil.li> | 2017-05-30 13:34:29 +0200 |
commit | 41db4be212184f3444ca8cb988a8006cd869de6a (patch) | |
tree | cf0613b62de7d92dfd0c4ad0292266663626b221 /hel | |
parent | e129d87f91052f8772bb6171164cf631083ce3d4 (diff) | |
download | nixos-41db4be212184f3444ca8cb988a8006cd869de6a.tar nixos-41db4be212184f3444ca8cb988a8006cd869de6a.tar.gz nixos-41db4be212184f3444ca8cb988a8006cd869de6a.tar.bz2 nixos-41db4be212184f3444ca8cb988a8006cd869de6a.tar.xz nixos-41db4be212184f3444ca8cb988a8006cd869de6a.zip |
Determine group dynamically
Diffstat (limited to 'hel')
-rw-r--r-- | hel/recv-media.nix | 7 |
1 files changed, 4 insertions, 3 deletions
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" '' | |||
27 | [[ -z "$1" || -z "$2" ]] && exit 2 | 27 | [[ -z "$1" || -z "$2" ]] && exit 2 |
28 | 28 | ||
29 | dir=/var/media | 29 | dir=/var/media |
30 | group=$(stat -c '%G' $dir) | ||
30 | tmpFile="''${dir}"/.tmp/$(basename "$1") | 31 | tmpFile="''${dir}"/.tmp/$(basename "$1") |
31 | target="''${dir}"/$(basename "$1") | 32 | target="''${dir}"/$(basename "$1") |
32 | 33 | ||
@@ -37,9 +38,9 @@ writeScriptBin "recv-media" '' | |||
37 | $(echo ''${2}) | 38 | $(echo ''${2}) |
38 | EOF | 39 | EOF |
39 | 40 | ||
40 | if [[ $(id -gn) != "media" ]]; then | 41 | if [[ $(id -gn) != $group ]]; then |
41 | printf "Primary group is %s, trying to switch to media..." $(id -gn) | 42 | printf "Primary group is %s, trying to switch to %s..." $(id -gn) $group |
42 | exec -- sg media "$0 $*" | 43 | exec -- sg $group "$0 $*" |
43 | fi | 44 | fi |
44 | 45 | ||
45 | ( | 46 | ( |