mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
56 lines
1.2 KiB
Text
56 lines
1.2 KiB
Text
set -e
|
|
|
|
force=$1
|
|
|
|
function safe_copy () {
|
|
if [[ "$force" == "True" ]]; then
|
|
sudo yunohost service safecopy \
|
|
-s postfix \
|
|
$1 $2 \
|
|
--force
|
|
else
|
|
sudo yunohost service safecopy \
|
|
-s postfix \
|
|
$1 $2
|
|
fi
|
|
}
|
|
|
|
cd /usr/share/yunohost/templates/postfix
|
|
|
|
# Copy plain single configuration files
|
|
files="header_checks
|
|
ldap-accounts.cf
|
|
ldap-aliases.cf
|
|
ldap-domains.cf
|
|
master.cf
|
|
sender_canonical
|
|
smtp_reply_filter"
|
|
|
|
for file in $files; do
|
|
safe_copy $file /etc/postfix/$file
|
|
done
|
|
|
|
main_domain=$(cat /etc/yunohost/current_host)
|
|
|
|
# Replace main domain in the main configuration file
|
|
cat main.cf.sed \
|
|
| sed "s/{{ main_domain }}/$main_domain/g" \
|
|
| sudo tee main.cf
|
|
|
|
# And adapt it to IPv4-only hosts
|
|
if [ ! -f /proc/net/if_inet6 ]; then
|
|
sudo sed -i \
|
|
's/ \[::ffff:127.0.0.0\]\/104 \[::1\]\/128//g' \
|
|
main.cf
|
|
|
|
sudo sed -i \
|
|
's/inet_interfaces = all/inet_interfaces = all\ninet_protocols = ipv4/' \
|
|
main.cf
|
|
fi
|
|
|
|
if [[ $(safe_copy main.cf /etc/postfix/main.cf) == "True" ]]; then
|
|
sudo service postfix restart
|
|
else
|
|
sudo service postfix reload \
|
|
|| sudo service postfix restart
|
|
fi
|