-Removed all ipkg_* functions and replaced them with a single ipkg function accepting...
[hvlinux.git] / stage3 / cis-sendmail
index ed770c2..5f8c206 100755 (executable)
@@ -1,4 +1,6 @@
 #!/bin/sh
+set -o errexit
+
 # First argument of this script is the package name
 
 # Reading system configuration informations, functions and package versions.
@@ -6,19 +8,17 @@ source ../sysinfos
 source ../functions
 source ../packages-list
 
-CUR_DIR=$(pwd)
-
 # Applying patches (if any)
-apply_patches ${1} &&
+apply_patches ${1}
 
-hv_groupadd smmsp &&
-hv_groupadd mail &&
-hv_useradd -g smmsp -G mail smmsp &&
-chmod 1777 /var/mail &&
-mkdir -p /var/spool/mqueue &&
-mkdir -p /etc/mail &&
+hv_groupadd smmsp
+hv_groupadd mail
+hv_useradd -g smmsp -G mail smmsp
+chmod 1777 /var/mail
+mkdir -p /var/spool/mqueue
+mkdir -p /etc/mail
 
-cd ${LFS_TMP}/${1} &&
+cd ${LFS_TMP}/${1}
 cat > devtools/Site/site.config.m4 << "EOF"
 define(`confMANGRP',`root')
 define(`confMANOWN',`root')
@@ -26,39 +26,35 @@ define(`confSBINGRP',`root')
 define(`confUBINGRP',`root')
 define(`confUBINOWN',`root')
 EOF
-evaluate_retval
 
 if [ "x${INST_TYPE}" = "xserver" -o "x${INST_TYPE}" = "xltsp-server" ]; then
     # Adding support for SASL2 and MILTER
-    cat >> devtools/Site/site.config.m4 << "EOF" &&
+    cat >> devtools/Site/site.config.m4 << "EOF"
 APPENDDEF(`conf_sendmail_ENVDEF', `-DSASL=2')
 APPENDDEF(`conf_sendmail_LIBS', `-lsasl2')
 APPENDDEF(`conf_sendmail_ENVDEF', `-DMILTER')
 EOF
     
     # Configuration file for SASL2
-    echo "pwcheck_method: saslauthd" /usr/lib/sasl2/Sendmail.conf || exit 1
+    echo "pwcheck_method: saslauthd" /usr/lib/sasl2/Sendmail.conf
 fi
 
-cd sendmail &&
-sh Build &&
+cd sendmail
+sh Build
 cd ../
-evaluate_retval
 
 if [ "x${INST_TYPE}" = "xserver" -o "x${INST_TYPE}" = "xltsp-server" ]; then
-    cd libmilter &&
-    sh Build install &&
+    cd libmilter
+    sh Build install
     cd ../
-    evaluate_retval
 fi
 
-cd cf/cf &&
-cp generic-linux.mc sendmail.mc &&
-sh Build sendmail.mc &&
-sh Build install-cf &&
-cd ../../ &&
+cd cf/cf
+cp generic-linux.mc sendmail.mc
+sh Build sendmail.mc
+sh Build install-cf
+cd ../../
 sh Build install
-evaluate_retval
 
 if [ "x${INST_TYPE}" = "xserver" -o "x${INST_TYPE}" = "xltsp-server" ]; then
     # Configuration Information
@@ -126,15 +122,14 @@ dnl INPUT_MAIL_FILTER(`greylist',`S=local:/var/run/milter-greylist/milter-greyli
 MAILER(smtp)
 EOF
 
-    sed -i -e "s!_HOSTNAME_!${MACHINE_NAME}\.${DOMAIN}!g" /etc/mail/sendmail.mc &&
+    sed -i -e "s!_HOSTNAME_!${MACHINE_NAME}\.${DOMAIN}!g" /etc/mail/sendmail.mc
     sed -i -e "s!_DOMAIN_!${DOMAIN}!g" /etc/mail/sendmail.mc
-    evaluate_retval
     
     if [ -n "${SENDMAIL_INCOMING_PORT}" ]; then
        # Uncommenting the alternate port line
-       sed -i -e "s!\(dnl \)\(.*_ALTERNATE_PORT_NUMBER_.*\)!\2!g" /etc/mail/sendmail.mc || exit 1
+       sed -i -e "s!\(dnl \)\(.*_ALTERNATE_PORT_NUMBER_.*\)!\2!g" /etc/mail/sendmail.mc
        # Replacing the port number
-       sed -i -e "s!_ALTERNATE_PORT_NUMBER_!${SENDMAIL_INCOMING_PORT}!g" /etc/mail/sendmail.mc || exit 1
+       sed -i -e "s!_ALTERNATE_PORT_NUMBER_!${SENDMAIL_INCOMING_PORT}!g" /etc/mail/sendmail.mc
     fi
     
     # We must put the domain name, and not the hostname in local-host-names
@@ -156,41 +151,41 @@ EOF
 Connect:192.168.0 RELAY
 EOF
     
-    cd /etc/mail &&
-    cp -R ${LFS_TMP}/${1}/cf/* . &&
+    cd /etc/mail
+    cp -R ${LFS_TMP}/${1}/cf/* .
 
     cat > /etc/mail/submit.mc << "EOF"
 dnl
 include(`./m4/cf.m4')dnl
 dnl
 EOF
-    cat ${LFS_TMP}/${1}/cf/cf/submit.mc >> /etc/mail/submit.mc &&
-    sed -i "s!\(^FEATURE.*\)127.0.0.1\(.*\)!\1${MACHINE_NAME}\.${DOMAIN}\2!" /etc/mail/submit.mc &&
-    newaliases -v &&
+    cat ${LFS_TMP}/${1}/cf/cf/submit.mc >> /etc/mail/submit.mc
+    sed -i "s!\(^FEATURE.*\)127.0.0.1\(.*\)!\1${MACHINE_NAME}\.${DOMAIN}\2!" /etc/mail/submit.mc
+    newaliases -v
    
-    cat > /etc/mail/virtusertable << "EOF" &&
+    cat > /etc/mail/virtusertable << "EOF"
 # MAKE SURE ALL ENTRIES ARE SEPARATED WITH <TAB>
 #
 EOF
 
     if [ -n "${SENDMAIL_ALT_MAILER}" ]; then
-       echo ".     ${SENDMAIL_ALT_MAILER}" > /etc/mail/mailertable || exit 1
+       echo ".     ${SENDMAIL_ALT_MAILER}" > /etc/mail/mailertable
     else
-       echo "# Define alternate mailer in this file" > /etc/mail/mailertable || exit 1
+       echo "# Define alternate mailer in this file" > /etc/mail/mailertable
     fi
 
-    cat > /etc/mail/configure << "EOF" &&
+    cat > /etc/mail/configure << "EOF"
 #!/bin/sh
 
 PID_FILE="/var/run/sendmail.pid"
 
-cd /etc/mail &&
+cd /etc/mail
 
-m4 sendmail.mc > sendmail.cf &&
-m4 submit.mc   > submit.cf &&
-newaliases &&
-makemap hash access.db < access &&
-makemap hash virtusertable < virtusertable &&
+m4 sendmail.mc > sendmail.cf
+m4 submit.mc   > submit.cf
+newaliases
+makemap hash access.db < access
+makemap hash virtusertable < virtusertable
 makemap hash mailertable.db < mailertable || exit 1
 
 # Restarting sendmail
@@ -202,15 +197,15 @@ fi
 
 exit $?
 EOF
-    chmod 740 /etc/mail/configure &&
+    chmod 740 /etc/mail/configure
 
     # Bootscript
-    install -v -m740 ${CUR_DIR}/bootscripts/sendmail /etc/rc.d/init.d &&
+    install -v -m740 ${SCRDIR}/bootscripts/sendmail /etc/rc.d/init.d
 
     # script-name start stop
-    bootscript_add_rc3 sendmail 65 25 &&
+    bootscript_add_rc3 sendmail 65 25
 
-    cat > /usr/local/bin/mail-if-fail << "EOF" &&
+    cat > /usr/local/bin/mail-if-fail << "EOF"
 #!/bin/sh
 
 # This script is used to run a command. If the command failed,
@@ -247,15 +242,14 @@ rm -f ${LOGFILE}
 exit ${ERROR_CODE}
 EOF
 
-    sed -i -e "s!_DOMAIN_!${DOMAIN}!g" /usr/local/bin/mail-if-fail &&
-    chmod 755 /usr/local/bin/mail-if-fail &&
+    sed -i -e "s!_DOMAIN_!${DOMAIN}!g" /usr/local/bin/mail-if-fail
+    chmod 755 /usr/local/bin/mail-if-fail
 
-    cp ${CUR_DIR}/resources/mail-files.sh /usr/local/bin &&
-    chmod 755 /usr/local/bin/mail-files.sh &&
+    cp ${SCRDIR}/resources/mail-files.sh /usr/local/bin
+    chmod 755 /usr/local/bin/mail-files.sh
 
     # Executing configure script.
     /etc/mail/configure
 fi
 
-# Return last error
 exit $?