From a6ba2da68b43cf4f190e5c48a1aab3303b33d007 Mon Sep 17 00:00:00 2001 From: jkaberg Date: Tue, 12 Aug 2014 10:09:44 +0200 Subject: [PATCH] create an no-reply user to use with SMTP from ownCloud --- setup/owncloud.sh | 23 ++++++++++------------- setup/start.sh | 7 +++++++ 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/setup/owncloud.sh b/setup/owncloud.sh index 3bd75c72..aca99632 100644 --- a/setup/owncloud.sh +++ b/setup/owncloud.sh @@ -41,23 +41,20 @@ $CONFIG = array ( "memcached_servers" => array ( array('localhost', 11211), ), + 'mail_smtpmode' => 'smtp', + 'mail_smtpsecure' => 'ssl', + 'mail_from_address' => 'no-reply@$PRIMARY_HOSTNAME', + 'mail_domain' => '$PRIMARY_HOSTNAME', + 'mail_smtpauthtype' => 'LOGIN', + 'mail_smtpauth' => true, + 'mail_smtphost' => 'localhost', + 'mail_smtpport' => '587', + 'mail_smtpname' => 'no-reply@$PRIMARY_HOSTNAME', + 'mail_smtppassword' => '$SECRET_PASSWORD', ); ?> EOF fi - -# TODO: Insert the following above (owncloud config generation) when we found a good solution: -# 'mail_smtpmode' => 'smtp', -# 'mail_smtpsecure' => 'ssl', -# 'mail_from_address' => '**** need to figure this one out, nornamly: @. ****', -# 'mail_domain' => '**** need to figure this one out, nornamly: . ****', -# 'mail_smtpauthtype' => 'LOGIN', -# 'mail_smtpauth' => true, -# 'mail_smtphost' => 'localhost', -# 'mail_smtpport' => '587', -# 'mail_smtpname' => '**** need to figure this one out, nornamly: @. ****', -# 'mail_smtppassword' => '**** need to figure this one out ****', - # Set permissions mkdir -p $STORAGE_ROOT/owncloud chown -R www-data.www-data $STORAGE_ROOT/owncloud /usr/local/lib/owncloud diff --git a/setup/start.sh b/setup/start.sh index 39987401..26a081d1 100755 --- a/setup/start.sh +++ b/setup/start.sh @@ -250,11 +250,15 @@ if [ -z "$STORAGE_ROOT" ]; then chown $STORAGE_USER.$STORAGE_USER $STORAGE_ROOT/mailinabox.version fi +# Generate a secret password to use with no-reply user (mainly for ownCloud SMTP atm) +SECRET_PASSWORD=$(dd if=/dev/random bs=20 count=1 2>/dev/null | base64 | fold -w 24 | head -n 1) + # Save the global options in /etc/mailinabox.conf so that standalone # tools know where to look for data. cat > /etc/mailinabox.conf << EOF; STORAGE_USER=$STORAGE_USER STORAGE_ROOT=$STORAGE_ROOT +SECRET_PASSWORD=$SECRET_PASSWORD PRIMARY_HOSTNAME=$PRIMARY_HOSTNAME PUBLIC_IP=$PUBLIC_IP PUBLIC_IPV6=$PUBLIC_IPV6 @@ -319,5 +323,8 @@ if [ -z "`tools/mail.py user`" ]; then # Create an alias to which we'll direct all automatically-created administrative aliases. tools/mail.py alias add administrator@$PRIMARY_HOSTNAME $EMAIL_ADDR + + # Create an no-reply user to use with ownCloud + tools/mail.py user add no-reply@$PRIMARY_HOSTNAME $SECRET_PASSWORD fi