summaryrefslogtreecommitdiff
path: root/net-mgmt/flowd/pkg-install
blob: 6fa963d1463412b0b53e3b0ab76e6a47d215ea8c (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
36
37
38
39
40
41
42
#!/bin/sh
#
#	$FreeBSD$
#
# Based on cyrus-sasl2 port
#
# create 'flowd' user 
#

create_user() {
	USER=${FLOWD_USER}
	GROUP=nobody
	PW=/usr/sbin/pw

	if [ -x /usr/sbin/nologin ]; then
		shell=/usr/sbin/nologin
	elif [ -x /sbin/nologin ]; then
		shell=/sbin/nologin
	else
		shell=/nonexistent
	fi
	uhome="/var/empty"

	if ! ${PW} show user ${USER} -q >/dev/null; then
		if ! ${PW} add user ${USER} -g ${GROUP} -d "${uhome}" \
				-c "flowd privilege separation user" -s "${shell}" -p "*" \
				; then
			e=$?
			echo "*** Failed to add user \`${USER}'. Please add it manually."
			exit ${e}
		fi
		echo "*** Added user \`${USER}' (id ${uid})"
	else
		echo "*** You already have user \`${USER}'."
	fi
}

case $2 in
	POST-INSTALL)
		create_user
		;;
esac