summaryrefslogtreecommitdiffstats
path: root/news/ifmail
diff options
context:
space:
mode:
authorfenner <fenner@FreeBSD.org>1997-11-20 05:16:53 +0000
committerfenner <fenner@FreeBSD.org>1997-11-20 05:16:53 +0000
commit3e999fcb50e8c2b285dea891e7fa0a96eeaf5365 (patch)
tree51e01e056c5f3335a4d46805a95b0723e790198f /news/ifmail
parent72b39a4043c00293db82d05aa1b7b10edd7972bc (diff)
downloadFreeBSD-ports-3e999fcb50e8c2b285dea891e7fa0a96eeaf5365.zip
FreeBSD-ports-3e999fcb50e8c2b285dea891e7fa0a96eeaf5365.tar.gz
Try to use uid 70 for the ifmail user when installing; pick an
available uid < 100 if 70 isn't available. Delete the user when deinstalling.
Diffstat (limited to 'news/ifmail')
-rw-r--r--news/ifmail/pkg-deinstall45
-rw-r--r--news/ifmail/pkg-install26
2 files changed, 69 insertions, 2 deletions
diff --git a/news/ifmail/pkg-deinstall b/news/ifmail/pkg-deinstall
new file mode 100644
index 0000000..50d0523
--- /dev/null
+++ b/news/ifmail/pkg-deinstall
@@ -0,0 +1,45 @@
+#!/bin/sh
+
+user=ifmail
+
+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 dflt question answer
+
+ question=$1
+ dflt=$2
+ while :; do
+ answer=$(ask "${question}" "${dflt}")
+ case "${answer}" in
+ [Yy]*) return 0;;
+ [Nn]*) return 1;;
+ esac
+ echo "Please answer yes or no."
+ done
+}
+
+if [ x$2 != xDEINSTALL ]; then
+ exit
+fi
+
+if yesno "Do you want me to remove user \"${user}\"" y; then
+ if [ `id -u` -ne 0 ]; then
+ echo "You must be root to delete the user."
+ exit 1
+ fi
+ pw userdel -n ${user}
+ echo "Done."
+fi
diff --git a/news/ifmail/pkg-install b/news/ifmail/pkg-install
index ebadbb1..ae00c1f 100644
--- a/news/ifmail/pkg-install
+++ b/news/ifmail/pkg-install
@@ -2,6 +2,7 @@
user=ifmail
group=uucp
+uid=70
ask() {
local question default answer
@@ -56,8 +57,29 @@ EOF
else
echo "You need a user \"${user}\"."
if which -s pw && yesno "Would you like me to create it" y; then
- pw useradd ${user} -g ${group} -h - -d /nonexistent \
- -s /nonexistent -c "Ifmail user" || exit
+ if [ `id -u` -ne 0 ]; then
+ echo "You must be root to add the user."
+ exit 1
+ fi
+ if pw user show ${uid} >/dev/null 2>&1; then
+ echo "The ifmail user is normally UID ${uid}. However, you currently have"
+ echo "a UID ${uid}."
+ if yesno "Should I just pick a new UID" y; then
+ while pw user show ${uid} >/dev/null 2>&1; do
+ uid=`expr ${uid} + 1`
+ done
+ if [ $uid -gt 99 ]; then
+ echo "I can't find a low UID to use. Please create an 'ifmail' user"
+ echo "and try the installation again."
+ exit 1
+ fi
+ else
+ exit 1
+ fi
+ echo "Ok, I'll use UID ${uid}."
+ fi
+ pw useradd ${user} -g ${group} -u ${uid} -h - -d /nonexistent \
+ -s /nonexistent -c "Ifmail user" || exit 1
echo "Done."
else
echo "Please create it, and try again."
OpenPOWER on IntegriCloud