#!/bin/sh
+set -o errexit
+
# First argument of this script is the package name
# Reading system configuration informations, functions and package versions.
# This server is configured to use SSL only, no plain-text passwords.
# Applying patches (if any)
-apply_patches ${1} &&
+apply_patches ${1}
-cd ${LFS_TMP}/${1} &&
+cd ${LFS_TMP}/${1}
# Setting default mailbox format for imapd
-sed -i -e "s!^\(CREATEPROTO=\)unixproto!\1${MAILBOX_FORMAT}proto!" src/osdep/unix/Makefile &&
+sed -i -e "s!^\(CREATEPROTO=\)unixproto!\1${MAILBOX_FORMAT}proto!" src/osdep/unix/Makefile
-make lnp &&
+make lnp
# Installing imapd
-install -m 755 imapd/imapd /usr/bin &&
-install -m 644 src/imapd/imapd.8 /usr/man/man8/imapd.8 &&
+install -m 755 imapd/imapd /usr/bin
+install -m 644 src/imapd/imapd.8 /usr/man/man8/imapd.8
# Installing mailutil
-install -m 755 mailutil/mailutil /usr/bin &&
-install -m 644 src/mailutil/mailutil.1 /usr/man/man1/mailutil.1 &&
+install -m 755 mailutil/mailutil /usr/bin
+install -m 644 src/mailutil/mailutil.1 /usr/man/man1/mailutil.1
# Installing dmail
-install -m 755 dmail/dmail /usr/bin &&
-install -m 644 src/dmail/dmail.1 /usr/man/man1/dmail.1 &&
+install -m 755 dmail/dmail /usr/bin
+install -m 644 src/dmail/dmail.1 /usr/man/man1/dmail.1
# Installing C-library
-mkdir -p /usr/lib/uw-imap/{include,lib} &&
-install -m 644 c-client/c-client.a /usr/lib/uw-imap/lib &&
-ln -sf /usr/lib/uw-imap/lib/c-client.a /usr/lib/uw-imap/lib/libc-client.a &&
-install -m 644 c-client/*.h /usr/lib/uw-imap/include &&
-install -m 644 src/osdep/tops-20/shortsym.h /usr/lib/uw-imap/include &&
+mkdir -p /usr/lib/uw-imap/{include,lib}
+install -m 644 c-client/c-client.a /usr/lib/uw-imap/lib
+ln -sf /usr/lib/uw-imap/lib/c-client.a /usr/lib/uw-imap/lib/libc-client.a
+install -m 644 c-client/*.h /usr/lib/uw-imap/include
+install -m 644 src/osdep/tops-20/shortsym.h /usr/lib/uw-imap/include
# Addition to /etc/inetd.conf
-string_add "imaps stream tcp nowait.400 root /usr/bin/imapd imapd" /etc/inetd.conf &&
+string_add "imaps stream tcp nowait.400 root /usr/bin/imapd imapd" /etc/inetd.conf
# Addition to /etc/services
-string_add "imaps 993/tcp " /etc/services &&
+string_add "imaps 993/tcp " /etc/services
# Addition to /etc/pam.conf
-string_add "# IMAP server" /etc/pam.conf &&
-string_add "imap auth required pam_unix.so nullok" /etc/pam.conf &&
-string_add "imap account required pam_unix.so try_first_pass" /etc/pam.conf &&
-string_add "imap session required pam_deny.so" /etc/pam.conf &&
+string_add "# IMAP server" /etc/pam.conf
+string_add "imap auth required pam_unix.so nullok" /etc/pam.conf
+string_add "imap account required pam_unix.so try_first_pass" /etc/pam.conf
+string_add "imap session required pam_deny.so" /etc/pam.conf
# SSL Certificates generation script
-cat > /etc/mail/imap-ssl-certs << "EOF" &&
+cat > /etc/mail/imap-ssl-certs << "EOF"
#!/bin/sh
-echo "-------------------------------------------------" &&
-echo "Generation of a Certificate Signing Request (CSR)" &&
-echo "" &&
-echo "Example fields:" &&
-echo "Country name: CA" &&
-echo "State or Province Name: Quebec" &&
-echo "Locality Name: Montreal" &&
-echo "Organization Name: Hugo Villeneuve" &&
-echo "Organizational Unit Name: ." &&
-echo "Common Name: mail.hugovil.com" &&
-echo "Email Address: postmaster@hugovil.com" &&
-echo "" &&
-echo "Please enter the following 'extra' attributes" &&
-echo "to be sent with your certificate request" &&
-echo "A challenge password []: (press enter) " &&
-echo "An optional company name []: (press enter) " &&
-echo "-------------------------------------------------" &&
-echo "" &&
-echo "-------------------------------------------------" &&
-echo "Generation of a self-signed certificate" &&
-echo "-------------------------------------------------" &&
-cd /etc/ssl/certs &&
+echo "-------------------------------------------------"
+echo "Generation of a Certificate Signing Request (CSR)"
+echo ""
+echo "Example fields:"
+echo "Country name: CA"
+echo "State or Province Name: Quebec"
+echo "Locality Name: Montreal"
+echo "Organization Name: Hugo Villeneuve"
+echo "Organizational Unit Name: ."
+echo "Common Name: mail.hugovil.com"
+echo "Email Address: postmaster@hugovil.com"
+echo ""
+echo "Please enter the following 'extra' attributes"
+echo "to be sent with your certificate request"
+echo "A challenge password []: (press enter) "
+echo "An optional company name []: (press enter) "
+echo "-------------------------------------------------"
+echo ""
+echo "-------------------------------------------------"
+echo "Generation of a self-signed certificate"
+echo "-------------------------------------------------"
+cd /etc/ssl/certs
openssl req -new -x509 -nodes -out imapd.pem -keyout imapd.pem -days 10000
exit $?
EOF
-chmod 740 /etc/mail/imap-ssl-certs &&
+chmod 740 /etc/mail/imap-ssl-certs
# Making sure cram-md5.pwd is created.
if [ ! -f /etc/cram-md5.pwd ]; then
chmod 600 /etc/cram-md5.pwd
fi
-# Return last error
exit $?