summaryrefslogtreecommitdiff
path: root/misc/dnetc/files/pkg-install.in
blob: f93546ef53b8ffbbc08831aa198a9314a996ebeb (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/bin/sh
#
# $FreeBSD$

if [ "$2" != "PRE-INSTALL" ]; then
    exit 0
fi

CLIENTUSER=%%CLIENTUSER%%
CLIENTGROUP=%%CLIENTGROUP%%
UID=%%CLIENTUID%%
GID=$UID

if ! /usr/sbin/pw groupshow "$CLIENTGROUP" 2>/dev/null 1>&2; then
	if /usr/sbin/pw groupadd $CLIENTGROUP -g $GID; then
		echo "=> Added group \"$CLIENTGROUP\"."
	else
		echo "=> Adding group \"$CLIENTGROUP\" failed."
		exit 1
	fi
fi

if ! /usr/sbin/pw usershow "$CLIENTUSER" 2>/dev/null 1>&2; then
	if /usr/sbin/pw useradd $CLIENTUSER -u $UID -g $CLIENTGROUP -h - \
		-s "/sbin/nologin" -d "/nonexistent" \
		-c "distributed.net client and proxy pseudo-user"; \
	then
		echo "=> Added user \"$CLIENTUSER\"."
	else
		echo "=> Adding user \"$CLIENTUSER\" failed."
		exit 1
	fi
fi

exit 0