#
# Copyright (c) Ensim Corporation 2000, 2001   All Rights Reserved.
#
# This software is furnished under a license and may be used and copied
# only  in  accordance  with  the  terms  of such  license and with the
# inclusion of the above copyright notice. This software or any other
# copies thereof may not be provided or otherwise made available to any
# other person. No title to and ownership of the software is hereby
# transferred.
#
# The information in this software is subject to change without notice
# and  should  not be  construed  as  a commitment by Ensim Corporation.
# Ensim assumes no responsibility for the use or  reliability  of its
# software on equipment which is not supplied by Ensim.
#
# 
install_srv(){
    set_context "Checking permissions of / and /etc" 
    if [ $(is_group_writable /) ] ; then
        exit_on_failure 1 "sendmail does not accept that / is group writable."
    fi
    if [ $(is_group_writable /etc) ] ; then
        exit_on_failure 1 "sendmail does not accept that /etc is group writable."
    fi
    if [ $(is_group_writable /etc/virtualhosting) ] ; then
        exit_on_failure 1 "sendmail does not accept that /etc/virtualhosting is group writable."
    fi
    set_context "Changing the ownership of /var/spool/mail"
    exe "chown mail.mail /var/spool/mail"

    set_context "Add setuid permission to virthostmail"
    exe "/bin/chmod 4755 /usr/bin/virthostmail"
 
    set_context "Creating /etc/virtualhosting/mappings/sendmail.domainmap"
    exe "touch /etc/virtualhosting/mappings/sendmail.domainmap"
    exe "chown root.root /etc/virtualhosting/mappings/sendmail.domainmap"
    exe "chmod 0644 /etc/virtualhosting/mappings/sendmail.domainmap"

}

upgrade_srv() {
    :
}
. /etc/appliance/scriptsLib-3.0/common.lib

G_WP_SRV_NAME=sendmail

if [ "$1" = "1" ]; then
    install_srv
elif [ "$1" ]; then
    upgrade_srv
fi

script_exit_success "pre"
