#!/bin/sh #------------------------------------------------------------------------------- # Eisfair configuration generator script # Copyright (c) 2007 - 2013 the eisfair team, team(at)eisfair(dot)org #------------------------------------------------------------------------------- #echo "Executing $0 ..." #exec 2> /tmp/ssmtp-trace$$.log #set -x # read base configuration file for domain . /etc/config.d/base . /etc/config.d/ssmtp #------------------------------------------------------------------------------- # creating/edit config file #------------------------------------------------------------------------------- { echo "#----------------------------------------------------------------------" echo "# Do not edit this file directly, modify '/etc/config.d/ssmtp' file and" echo "# re-run the /var/install/config.d/ssmtp.sh' command to update." echo "#----------------------------------------------------------------------" echo "" # Debug # ----- # Get enhanced (*really* enhanced) debugging information in the logs # If you want to have debugging of the config file parsing, move this option # to the top of the config file and uncomment [ "$SSMTP_DO_DEBUG" = "yes" ] && echo 'Debug=YES' # root # ---- # If sSMTP finds an unqualified e-mail address among the recipients, # and it corresponds to a username on your local machine with a userid # less than 1000, then the e-mail is sent to this value instead. # The idea is that mail sent to 'root' should probably go to # 'postmaster' instead. # If you set up your MUA to do its own handling of unqualified # addresses, this is irrelevant. (But note that cron does use # unqualified addresses corresponding to local usernames.) # Use your own e-mail address unless you know a better postmaster. echo "root=${SSMTP_FORWARD_TO}" # mailhub[:port] # -------------- # This is the computer responsible for handling your outgoing mail. # It could be the SMTP server of your ISP, or a departmental mailhub. # Use the fully-qualified domain name (foo.bar.baz) of the mailhub; # # If it uses an unusual SMTP port number, use the colon syntax # foo.bar.baz:2525 . Otherwise sSMTP will use the standard SMTP port # number (25). (Note that sSMTP can support a user-dependent mailhub # with the # 'reverse aliases' feature, for which see the man page.) echo -n "mailhub=${SSMTP_MAILHUB}" if [ -n "$SSMTP_MAILHUB_PORT" ]; then echo ":${SSMTP_MAILHUB_PORT}" else echo "" fi # hostname # -------- # sSMTP uses the hostname of your computer to identify itself to the # mailhub, and in the Received: headers of the outgoing mail. This has # relatively little effect on how the mail is handled. # Use the fully-qualified domain name (FQDN) of your computer (foo.bar.baz). # If it doesn't have a FQDN, use some name for your box. if [ -n "$SSMTP_HOSTNAME" ]; then echo "hostname=${SSMTP_HOSTNAME}" else echo "hostname=${HOSTNAME}.${DOMAIN_NAME}" fi # rewriteDomain # ------------- # sSMTP uses this value to add a domain to unqualified e-mail addresses # (addresses without an @-sign). You probably want to use the domain # from your own e-mail address. You probably want to set up your MUA to # handle unqualified addresses itself, in which case sSMTP will never # have to use this. # (Users of cron note that cron always uses unqualified addresses.) [ -n "$SSMTP_SENDER_DOMAIN" ] && echo "rewriteDomain=${SSMTP_SENDER_DOMAIN}" echo "" # FromLineOverride # ---------------- # Set this to never rewrite the "From:" line (unless not given) and to # use that address in the "from line" of the envelope. echo "FromLineOverride=YES" if [ "$SSMTP_USE_AUTH" = "yes" ]; then # AuthUser # -------- # The user name to use for SMTP AUTH. The default is blank, in which # case SMTP AUTH is not used. sent without echo "AuthUser=${SSMTP_AUTH_USER}" # AuthPass # -------- # The password to use for SMTP AUTH. echo "AuthPass=${SSMTP_AUTH_PASS}" # AuthMethod # ---------- # The authorization method to use. If unset, plain text is used. # May also be set to 'cram-md5'. echo "AuthMethod=${SSMTP_AUTH_METHOD}" fi case "$SSMTP_USE_TLS" in "tls") # UseTLS # ------ # Use SSL/TLS to send secure messages to server. echo "UseTLS=yes" ;; "starttls") # UseSTARTTLS # ----------- # Specifies whether ssmtp does a EHLO/STARTTLS before starting # SSL negotiation. See RFC 2487. echo "UseSTARTTLS=yes" ;; esac if [ "$SSMTP_USE_TLS" != "no" -a "$SSMTP_USE_TLS_CERT" = "yes" -a -f /etc/ssl/certs/ssmtp.pem ]; then # UseTLSCert # ---------- # Use SSL/TLS certificate to authenticate against smtp host. echo "UseTLSCert=YES" # TLSCert # ------- # Use this RSA certificate. echo "TLSCert=/etc/ssl/certs/ssmtp.pem" fi } > /etc/ssmtp/ssmtp.conf # Set rights for configuration file chmod 0644 /etc/ssmtp/ssmtp.conf # hide plaintext password [ "$SSMTP_USE_AUTH" = "yes" ] && chmod 0640 /etc/ssmtp/ssmtp.conf chown root /etc/ssmtp/ssmtp.conf #------------------------------------------------------------------------------- # create /etc/ssmtp/revaliases #------------------------------------------------------------------------------- if [ -n "$SSMTP_OUTGOING_N" ]; then if [ ${SSMTP_OUTGOING_N} -gt 0 ]; then { echo "#----------------------------------------------------------------------" echo "# Do not edit this file directly, modify '/etc/config.d/ssmtp' file and" echo "# re-run the /var/install/config.d/ssmtp.sh' command to update." echo "#----------------------------------------------------------------------" echo "# Format: local_account:outgoing_address[:mailhub][:port]" echo "#----------------------------------------------------------------------" # sSMTP aliases # # Format: local_account:outgoing_address:mailhub # # Example: root:your_login@your.domain:mailhub.your.domain[:port] # where [:port] is an optional port number that defaults to 25. idx=1 while [ ${idx} -le ${SSMTP_OUTGOING_N} ] do eval user='$SSMTP_OUTGOING_'${idx}'_USER' eval addr='$SSMTP_OUTGOING_'${idx}'_EMAIL' eval mh_name='$SSMTP_OUTGOING_'${idx}'_MAILHUB' eval mh_port='$SSMTP_OUTGOING_'${idx}'_MAILHUB_PORT' # check if system user exists grep -q "^${user}:" /etc/passwd if [ $? -eq 0 ]; then outstr="${user}:${addr}" [ -n "$mh_name" ] && outstr="${outstr}:${mh_name}" [ -n "$mh_port" ] && outstr="${outstr}:${mh_port}" echo ${outstr} fi idx=`expr ${idx} + 1` done } > /etc/ssmtp/revaliases # set rights for configuration file chmod 0644 /etc/ssmtp/revaliases chown root /etc/ssmtp/revaliases else rm -f /etc/ssmtp/revaliases fi else rm -f /etc/ssmtp/revaliases fi #------------------------------------------------------------------------------ exit 0