aboutsummaryrefslogtreecommitdiff
path: root/net-mgmt/flow-tools/files/pkg-install.in
diff options
context:
space:
mode:
Diffstat (limited to 'net-mgmt/flow-tools/files/pkg-install.in')
-rw-r--r--net-mgmt/flow-tools/files/pkg-install.in78
1 files changed, 78 insertions, 0 deletions
diff --git a/net-mgmt/flow-tools/files/pkg-install.in b/net-mgmt/flow-tools/files/pkg-install.in
new file mode 100644
index 000000000000..dc913ca32fd8
--- /dev/null
+++ b/net-mgmt/flow-tools/files/pkg-install.in
@@ -0,0 +1,78 @@
+#!/bin/sh
+#
+# $FreeBSD$
+#
+
+PATH=/bin:/usr/sbin:/usr/bin:/usr/sbin
+
+FLOW_CAPTURE_SPOOL="%%FLOW_CAPTURE_SPOOL%%"
+FLOW_CAPTURE_USER="%%FLOW_CAPTURE_USER%%"
+FLOW_CAPTURE_GROUP="%%FLOW_CAPTURE_GROUP%%"
+FLOW_CAPTURE_PIDDIR="%%FLOW_CAPTURE_PIDDIR%%"
+
+if [ -x /usr/sbin/nologin ]; then
+ NOLOGIN=/usr/sbin/nologin
+else
+ NOLOGIN=/sbin/nologin
+fi
+
+pre-install() {
+#
+# Create group
+#
+ pw groupshow ${FLOW_CAPTURE_GROUP} > /dev/null 2>&1
+ if [ $? -ne 0 ]; then
+ echo -n "Creating '${FLOW_CAPTURE_GROUP}' group... "
+ pw groupadd ${FLOW_CAPTURE_GROUP} -q
+
+ if [ $? -eq 0 ]; then
+ echo "ok"
+ else
+ echo "failed"
+ echo "Cannot create group '${FLOW_CAPTURE_GROUP}'" >&2
+ echo "Please, create it manually." >&2
+ exit 1
+ fi
+ else
+ echo "Using existing group '${FLOW_CAPTURE_GROUP}'"
+ fi
+
+#
+# Create user
+#
+ pw usershow ${FLOW_CAPTURE_USER} > /dev/null 2>&1
+ if [ $? -ne 0 ]; then
+ echo -n "Creating '${FLOW_CAPTURE_USER}' user... "
+ pw useradd -n ${FLOW_CAPTURE_USER} -g ${FLOW_CAPTURE_GROUP} \
+ -c "Flow-tools collector pseudo-user" \
+ -d "/var/empty" -s "${NOLOGIN}" -h - -q
+
+ if [ $? -eq 0 ]; then
+ echo "ok"
+ else
+ echo "failed"
+ echo "Cannot create user '${FLOW_CAPTURE_USER}'" >&2
+ echo "Please, create it manually." >&2
+ exit 1
+ fi
+ else
+ echo "Using existing group '${FLOW_CAPTURE_USER}'"
+ fi
+}
+
+post-install() {
+ /usr/bin/install -d -m 700 -o ${FLOW_CAPTURE_USER} \
+ -g ${FLOW_CAPTURE_GROUP} ${FLOW_CAPTURE_PIDDIR}
+ /usr/bin/install -d -m 1700 -o ${FLOW_CAPTURE_USER} \
+ -g ${FLOW_CAPTURE_GROUP} ${FLOW_CAPTURE_SPOOL}
+}
+
+
+case $2 in
+ PRE-INSTALL)
+ pre-install
+ ;;
+ POST-INSTALL)
+ post-install
+ ;;
+esac