summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authortv <tv@shackspace.de>2015-06-18 21:42:21 +0200
committertv <tv@shackspace.de>2015-06-18 21:42:21 +0200
commit99c1e067b17d9b57245ee793c7b08b0c93de54b0 (patch)
treef2141c504dd77ea03d1bd9b37903c7f5d04c440f /bin
parentde741c98a711dd3e2d7b060d5d0f0e196f1b8f2e (diff)
bin/genid: initial commit
Diffstat (limited to 'bin')
-rwxr-xr-xbin/genid11
1 files changed, 11 insertions, 0 deletions
diff --git a/bin/genid b/bin/genid
new file mode 100755
index 000000000..8e2240746
--- /dev/null
+++ b/bin/genid
@@ -0,0 +1,11 @@
+#! /bin/sh
+# usage: genid NAME
+set -euf
+name=$1
+hash=$(printf %s "$name" | sha1sum | cut -d\ -f1 | tr a-f A-F)
+echo "
+ min=2^16 # bigger than nobody and nogroup, see <nixos/modules/misc/ids.nix>
+ max=2^32 # see 2^(8*sizeof(uid_t))
+ ibase=16
+ ($hash + min) % max
+" | bc