summaryrefslogtreecommitdiff
path: root/sysutils/nix/files/add-nixbld-users
blob: 2b4ac4e88d9844d44e2f564ba6c7d9ea8162e1c3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#! /bin/sh -
# $FreeBSD$

set -eu

if [ -z "$1" ] || ! expr -- "$1" : "[0-9][0-9]*" >/dev/null; then
	echo "Usage: $0 NUMBER" 2>/dev/null
	exit 1
fi

if [ "$1" -lt 1 ]; then
	echo "ERROR: NUMBER should be at least 1" 2>/dev/null
	exit 1
fi

for n in $(seq 1 "$1"); do
	user="nixbld${n}"
	if pw usershow "$user" >/dev/null 2>&1; then
		continue
	fi
	pw useradd "$user" -c "Nix build user $n" -d /var/empty -G nixbld \
		-g nixbld -s /usr/sbin/nologin
done