summaryrefslogtreecommitdiff
path: root/irc/bitlbee/files/pkg-install.in
diff options
context:
space:
mode:
Diffstat (limited to 'irc/bitlbee/files/pkg-install.in')
-rw-r--r--irc/bitlbee/files/pkg-install.in74
1 files changed, 74 insertions, 0 deletions
diff --git a/irc/bitlbee/files/pkg-install.in b/irc/bitlbee/files/pkg-install.in
new file mode 100644
index 000000000000..06a9fa3d7beb
--- /dev/null
+++ b/irc/bitlbee/files/pkg-install.in
@@ -0,0 +1,74 @@
+#!/bin/sh -
+#
+# $FreeBSD$
+#
+
+BITLBEEDIR=%%BITLBEEDIR%%
+BITLBEEUSER=%%BITLBEEUSER%%
+BITLBEEGROUP=%%BITLBEEGROUP%%
+BITLBEEUID=%%BITLBEEUID%%
+BITLBEEGID=%%BITLBEEGID%%
+
+ask() {
+ local question default answer
+
+ question=$1
+ default=$2
+ if [ -z "${PACKAGE_BUILDING}" ]; then
+ read -p "${question} [${default}]? " answer
+ fi
+ if [ "x${answer}" = "x" ]; then
+ answer=${default}
+ fi
+ echo ${answer}
+}
+
+yesno() {
+ local default question answer
+
+ question=$1
+ default=$2
+ while :; do
+ answer=$(ask "${question}" "${default}")
+ case "${answer}" in
+ [Yy][Ee][Ss]|[Yy])
+ return 0
+ ;;
+ [Nn][Oo]|[Nn])
+ return 1
+ ;;
+ esac
+ echo "Please answer yes or no."
+ done
+}
+
+if [ "$2" = "PRE-INSTALL" ]; then
+ if /usr/sbin/pw group show "${BITLBEEGROUP}" 2>&1 >/dev/null; then
+ echo "You already have a \"${BITLBEEGROUP}\" group, so I will use it."
+ else
+ echo "You need a \"${BITLBEEGROUP}\" group."
+ if yesno "Would you like me to create it" "YES"; then
+ /usr/sbin/pw groupadd "${BITLBEEGROUP}" -g "${BITLBEEGID}" -h - || \
+ /usr/sbin/pw groupadd "${BITLBEEGROUP}" -h - || exit
+ echo "Done."
+ else
+ echo "Please create the \"${BITLBEEGROUP}\" group manually and try again."
+ exit 1
+ fi
+ fi
+
+ if /usr/sbin/pw user show "${BITLBEEUSER}" 2>&1 >/dev/null; then
+ echo "You already have a \"${BITLBEEUSER}\" user, so I will use it."
+ else
+ echo "You need a \"${BITLBEEUSER}\" user."
+ if yesno "Would you like me to create it" "YES"; then
+ /usr/sbin/pw useradd "${BITLBEEUSER}" -u "${BITLBEEUID}" -g "${BITLBEEGROUP}" -h - -d "${BITLBEEDIR}" \
+ -s /sbin/nologin -c "Bitlbee pseudo-user" || \
+ /usr/sbin/pw useradd "${BITLBEEUSER}" -g "${BITLBEEGROUP}" -h - -d "${BITLBEEDIR}" \
+ -s /sbin/nologin -c "Bitlbee pseudo-user" || exit
+ else
+ echo "Please create the \"${BITLBEEUSER}\" user manually and try again."
+ exit 1
+ fi
+ fi
+fi