From ec0c7a74bbf5824adc4efa54e1f91984ac870a8e Mon Sep 17 00:00:00 2001 From: Natanael Copa Date: Wed, 6 May 2009 09:53:36 +0000 Subject: move to .in files --- setup-mta.in | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100755 setup-mta.in (limited to 'setup-mta.in') diff --git a/setup-mta.in b/setup-mta.in new file mode 100755 index 0000000..03af6bc --- /dev/null +++ b/setup-mta.in @@ -0,0 +1,51 @@ +#!/bin/sh + +PREFIX= +. "$PREFIX/lib/libalpine.sh" + +conf="$ROOT/etc/ssmtp/ssmtp.conf" + +cfgval() { + awk -F= "/^$1/ {print \$2}" $conf 2>/dev/null +} + +setcfg() { + local key=$1 + local value=$2 + sed -i "s/^\\(\\#\\)*$key=.*/$key=$value/" "$conf" + if ! grep "^$key=" "$conf" >/dev/null ; then + echo "$key=$value" >> "$conf" + fi +} + +if [ -f "$conf" ] ; then + mailhub=$(cfgval mailhub) +fi +domain=$(hostname -d $hostname 2>/dev/null) +if [ -z "$mailhub" ] ;then + if [ -n "$domain" ] ; then + mailhub="smtp.$domain" + else + mailhub=smtp + fi +fi + +res= + +while [ "$res" != "221" ]; do + echon "Outgoing mail server? (e.g 'smtp.isp.com') [$mailhub] " + default_read mailhub $mailhub + echon "Test connection? (y/n) [y] " + default_read testconn "y" + case "$testconn" in + [Nn]*) break;; + esac + res=$(echo -e "quit\r\n" | nc $mailhub 25 | awk '/^221/ {print $1}') + [ "x$res" = "x221" ] && echo "Connection to $mailhub is ok." +done + +apk_add ssmtp + +setcfg mailhub $mailhub +setcfg FromLineOverride YES + -- cgit v1.2.3