summaryrefslogblamecommitdiff
path: root/mail/courier/files/pkg-install.in
blob: c6e6ebd6002db8217ca578ca7e8d56a3fbaf0fc1 (plain) (tree)
1
2
3
4
5
6
7
8
9

         
           



                                    

                                       
 







                                                   
                               



















                                                

                   
 










                                 
                                    











                                                                                        
  
#!/bin/sh
#
# $FreeBSD$
#

PKG_PREFIX=${PKG_PREFIX:=/usr/local}

USER=%%MAILOWN%%;	UID=%%MAILUID%%
GROUP=%%MAILGRP%%;	GID=%%MAILGID%%

ask() {
    local question default answer

    question=$1
    default=$2
    if [ -z "${PACKAGE_BUILDING}" ]; then
        read -p "${question} [${default}]? " answer
    fi
    if [ -z "${answer}" ]; then
        answer=${default}
    fi
    echo ${answer}
}

yesno() {
    local question default answer

    question=$1
    default=$2
    while :; do
        answer=$(ask "${question}" "${default}")
        case "${answer}" in
        [Yy]*)	return 0;;
        [Nn]*)	return 1;;
        esac
        echo "Please answer yes or no."
    done
}

replace() {
    local orig repl

    orig=$1
    repl=$2
    if [ -e ${orig} ]; then
        mv -f ${orig} ${orig}.OFF
        chmod 0 ${orig}.OFF
    fi
    if [ -e ${repl} ]; then
        ln -s ${repl} ${orig}
    fi
}

if [ ":$2" = ":POST-INSTALL" ]; then
        if yesno "Would you like to activate Courier in /etc/mail/mailer.conf" n; then
            mv -f /etc/mail/mailer.conf /etc/mail/mailer.conf.old
            echo "#"						>  /etc/mail/mailer.conf
            echo -n "# Execute the Courier sendmail program"	>> /etc/mail/mailer.conf
            echo ", named ${PKG_PREFIX}/bin/sendmail"		>> /etc/mail/mailer.conf
            echo "#"						>> /etc/mail/mailer.conf
            echo "sendmail	${PKG_PREFIX}/bin/sendmail"	>> /etc/mail/mailer.conf
            echo "send-mail	${PKG_PREFIX}/bin/sendmail"	>> /etc/mail/mailer.conf
            echo "mailq		${PKG_PREFIX}/bin/mailq"	>> /etc/mail/mailer.conf
            echo "newaliases	${PKG_PREFIX}/sbin/makealiases"	>> /etc/mail/mailer.conf
            echo "Done."
        fi
fi