aboutsummaryrefslogtreecommitdiff
path: root/net/nocatauth-gateway/pkg-install
blob: ebcd712ccbbe2b4e793ada5db8640d1f2c90afd9 (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
#!/bin/sh
#
# $FreeBSD$
#

PATH=/bin:/usr/sbin

if [ -z "${WRAP_USER}" ]; then
	WRAP_USER=nocat
fi

case $2 in
    PRE-INSTALL)
	UID=181
	GID=${UID}
	if [ ! -d "${NOCAT_DIR}" ]; then
		mkdir -p ${NOCAT_DIR}
	fi
	if pw user show "${WRAP_USER}" 2>/dev/null; then
		echo "You already have a user \"${WRAP_USER}\", so I will use it."
		if pw usermod ${WRAP_USER} -d ${NOCAT_DIR}
		then
			echo "Changed home directory of \"${WRAP_USER}\" to \"${NOCAT_DIR}\""
		else
			"${NOCAT_DIR}\" failed..."
			exit 1
		fi
		else
		if pw useradd ${WRAP_USER} -u ${UID} -d ${NOCAT_DIR} \
		    -s /sbin/nologin -c "NoCat Daemon"
		then
			echo "Added user \"${WRAP_USER}\"."
		else
			echo "Adding user \"${WRAP_USER}\" failed..."
			exit 1
		fi
	fi
	;;
esac