diff options
author | Bill Fenner <fenner@FreeBSD.org> | 1997-11-20 05:16:53 +0000 |
---|---|---|
committer | Bill Fenner <fenner@FreeBSD.org> | 1997-11-20 05:16:53 +0000 |
commit | 40f68154c5267d567095198bef7a24a1a90d7e10 (patch) | |
tree | a11cbb0fc0012fdf8664e314eaa76ca46fb2c40f /news/ifmail | |
parent | original distribution updated (1.59->1.60) (diff) |
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-deinstall | 45 | ||||
-rw-r--r-- | news/ifmail/pkg-install | 26 |
2 files changed, 69 insertions, 2 deletions
diff --git a/news/ifmail/pkg-deinstall b/news/ifmail/pkg-deinstall new file mode 100644 index 000000000000..50d05233e469 --- /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 ebadbb12da31..ae00c1fd5e68 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." |