- Home
- Workspace
- Installation
- Enterprise
- Docker
- Running an external script after starting ONLYOFFICE Mail Docker container
Running an external script after starting ONLYOFFICE Mail Docker container
If you need to change the default settings of the onlyoffice-mail-server, starting from v1.6.57, it is possible to run an external script after the container is started. To do that, create your script at the following path: /app/onlyoffice/MailServer/data/external.sh and write the commands you need to edit the configuration in it, or use any other bash commands (see the example below). The script will be executed each time after the version update or restart.
Previously, if it was necessary to change the configuration, you had to make the same changes in the configuration files again after the version update. Now, if you write the necessary commands to edit configuration files into the script and save it under the specified path, all the changes will be applied automatically each time the script is run after the version update.
Below is an example of the external.sh file, which can be used to customize ONLYOFFICE Mail according to your needs. You do not have to use all the commands listed in the example; use only the ones you need, or add your own commands.
{ANY-YOUR-IPS} must be replaced with any set of IP addresses (separated with spaces) that you trust.
#!/bin/bash
echo "Add ignore IP addresses"
sed -i -e 's/ignoreip = 127.0.0.1\/8 onlyoffice-community-server 172.18.0.1/ignoreip = 127.0.0.1\/8 onlyoffice-community-server 172.18.0.1 {ANY-YOUR-IPS}/g' /etc/fail2ban/jail.conf
echo "Disable greylist"
sed -i -e '/\[Greylisting\]/!b;n;c enable=0' /etc/policyd/cluebringer.conf
echo "Increase imap connections from one IP"
sed -i -e 's/mail_max_userip_connections = 20/mail_max_userip_connections = 100/g' /etc/dovecot/dovecot.conf
echo "Setup mynetwork"
sed -i -e 's/mynetworks = 127.0.0.1$/mynetworks = 127.0.0.1 {ANY-YOUR-IPS}/g' /etc/postfix/main.cf
fail2ban-client reload
dovecot reload
postfix reload
Where:
Add ignore IP addressesis used to create a list of IP addresses, which are not affected by common Fail2ban rules. If a user from the specified IP address enters an incorrect login or password, this IP address will not be blocked, while unknown IP addresses will be blocked after unsuccessful login attempts.Disable greylistis used to disable the greylisting feature enabled by default (a spam protection feature based on the principle that, if the recipient's server is temporarily unable to receive a message, mail servers repeat the attempt to send the message, unlike spammers). Disabling this function may be necessary, for example, to avoid slowing down business processes if you receive many messages from unknown mail servers.Increase imap connections from one IPis used to allow connecting a larger number of clients from a single IP address than specified by default. In the example above, 100 connections from a single IP address are allowed instead of 20 connections.Setup mynetworkis used to specify a list of trusted networks in the Postfix configuration file, which allows making mail server checks less strict for the IP addresses that belong to the trusted networks.- Once the changes are made, the
fail2ban-client,dovecot, andpostfixservices read the configuration files again.
To find out how to perform specific operations using a script, refer to the following articles: