From 40f68154c5267d567095198bef7a24a1a90d7e10 Mon Sep 17 00:00:00 2001 From: Bill Fenner Date: Thu, 20 Nov 1997 05:16:53 +0000 Subject: 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. --- news/ifmail/pkg-deinstall | 45 +++++++++++++++++++++++++++++++++++++++++++++ news/ifmail/pkg-install | 26 ++++++++++++++++++++++++-- 2 files changed, 69 insertions(+), 2 deletions(-) create mode 100644 news/ifmail/pkg-deinstall (limited to 'news/ifmail') 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." -- cgit v1.2.3