2023-05-01 11:48:30 +03:00
|
|
|
# zimbra-management
|
2023-05-01 00:30:38 +03:00
|
|
|
|
2023-05-01 11:48:30 +03:00
|
|
|
Zimbra management and monitoring utils.
|
2023-05-01 00:30:38 +03:00
|
|
|
|
2023-05-01 11:48:30 +03:00
|
|
|
* [`zimbra-man.sh`](https://git.hmp.today/pavel.muhortov/zimbra-management#zimbra-man-sh)
|
2023-05-01 00:30:38 +03:00
|
|
|
|
|
|
|
____
|
|
|
|
|
2023-05-01 11:48:30 +03:00
|
|
|
## `zimbra-man`.sh
|
2023-05-01 00:30:38 +03:00
|
|
|
|
|
|
|
**Description:**
|
2023-05-01 11:48:30 +03:00
|
|
|
> Print length of all zimbra queues or letsencrypt update certificate procedure.
|
2023-05-01 00:30:38 +03:00
|
|
|
|
|
|
|
**Dependencies:**
|
|
|
|
>
|
2023-05-01 11:48:30 +03:00
|
|
|
> * privileged rights
|
|
|
|
> * [zimbra zmcontrol, zmqstat, zmcertmgr](https://www.zimbra.com/) (tested version 8.8.15 on [CentOS 7](https://wiki.centos.org/Manuals/ReleaseNotes/CentOS7.2009))
|
|
|
|
> * [curl](https://curl.se/download.html) (tested version 7.29 on [CentOS 7](https://wiki.centos.org/Manuals/ReleaseNotes/CentOS7.2009))
|
|
|
|
> * [openssl](https://www.openssl.org/) (tested version 1.0.2k on [CentOS 7](https://wiki.centos.org/Manuals/ReleaseNotes/CentOS7.2009))
|
|
|
|
> * [cerbot](https://certbot.eff.org/) (tested version 2.5.0 on [CentOS 7](https://wiki.centos.org/Manuals/ReleaseNotes/CentOS7.2009))
|
|
|
|
> * [Python 3](https://www.python.org/downloads/) (tested version 3.9.5 on [CentOS 7](https://wiki.centos.org/Manuals/ReleaseNotes/CentOS7.2009))
|
|
|
|
> * existing [/usr/local/bin/sendmail.py](https://git.hmp.today/pavel.muhortov/utils#sendmail-py)
|
2023-05-01 00:30:38 +03:00
|
|
|
|
|
|
|
| POSITION | PARAMETERS | DESCRIPTION | DEFAULT |
|
|
|
|
|-----------|--------------|------------------------|---------------|
|
|
|
|
| 1 |**[qn]**|execution without pauses||
|
2023-05-01 11:48:30 +03:00
|
|
|
| 2 |**que**|print length of all zimbra queues|`None`|
|
2023-05-04 16:48:48 +03:00
|
|
|
| 2 |**svc**|print number of stopped services|`None`|
|
2023-05-01 11:48:30 +03:00
|
|
|
| 2 |**ssl**|letsencrypt certificate update procedure|`None`|
|
|
|
|
| 3 |**[/path/to/conf]**|custom configuration file path|`./zimbra-man.conf`|
|
2023-05-01 00:30:38 +03:00
|
|
|
|
2023-05-01 11:48:30 +03:00
|
|
|
### Renew certificate by crontab
|
|
|
|
|
|
|
|
The first issue of the certificate must be done manually, because you need to answer letsencrypt questions.
|
|
|
|
|
|
|
|
```bash
|
|
|
|
# define first certificate
|
|
|
|
certfirst=mail.domain.zone
|
|
|
|
|
|
|
|
# stop zimbra
|
|
|
|
sudo su - zimbra -c "/opt/zimbra/bin/zmcontrol stop"
|
|
|
|
|
|
|
|
# add additional hostnames, issue certificate and download chain
|
2023-06-02 08:35:55 +03:00
|
|
|
sudo certbot certonly --standalone --email mail@domain.zone --preferred-chain "ISRG Root X1" --key-type rsa --rsa-key-size 2048 -d "${certfirst}" -d smtp.domain.zone -d pop3.domain.zone -d imap.domain.zone
|
2023-05-01 11:48:30 +03:00
|
|
|
sudo sh -c "wget -O - https://letsencrypt.org/certs/isrgrootx1.pem.txt --no-check-certificate >> /etc/letsencrypt/live/${certfirst}/chain.pem"
|
|
|
|
|
|
|
|
# start zimbra
|
|
|
|
sudo su - zimbra -c "/opt/zimbra/bin/zmcontrol start"
|
|
|
|
|
|
|
|
# copy certificate, define files permission
|
|
|
|
sudo cp "/etc/letsencrypt/live/${certfirst}/privkey.pem" /opt/zimbra/ssl/zimbra/commercial/commercial.key
|
|
|
|
sudo cp "/etc/letsencrypt/live/${certfirst}/chain.pem" /opt/zimbra/ssl/zimbra/commercial/chain.pem
|
|
|
|
sudo cp "/etc/letsencrypt/live/${certfirst}/cert.pem" /opt/zimbra/ssl/zimbra/commercial/cert.pem
|
|
|
|
sudo chown -R zimbra:zimbra /opt/zimbra/ssl/zimbra/commercial/
|
|
|
|
|
|
|
|
# deploy certificate
|
|
|
|
sudo su - zimbra -c "/opt/zimbra/bin/zmcertmgr verifycrt comm /opt/zimbra/ssl/zimbra/commercial/commercial.key /opt/zimbra/ssl/zimbra/commercial/cert.pem /opt/zimbra/ssl/zimbra/commercial/chain.pem"
|
|
|
|
sudo su - zimbra -c "/opt/zimbra/bin/zmcertmgr deploycrt comm /opt/zimbra/ssl/zimbra/commercial/cert.pem /opt/zimbra/ssl/zimbra/commercial/chain.pem"
|
|
|
|
|
|
|
|
# restart zimbra
|
|
|
|
sudo su - zimbra -c "/opt/zimbra/bin/zmcontrol restart"
|
|
|
|
```
|
|
|
|
|
2023-06-02 06:55:43 +03:00
|
|
|
When the certificate issued, renew certificate is possible by crontab.
|
2023-05-01 11:48:30 +03:00
|
|
|
|
|
|
|
```bash
|
|
|
|
# download
|
|
|
|
sudo wget https://git.hmp.today/pavel.muhortov/zimbra-management/raw/branch/master/zimbra-man.sh -O /usr/local/bin/zimbra-man.sh
|
|
|
|
sudo chmod +x /usr/local/bin/zimbra-man.sh
|
|
|
|
```
|
|
|
|
|
|
|
|
```bash
|
|
|
|
# edit config
|
|
|
|
sudo tee /usr/local/bin/zimbra-man.conf > /dev/null <<'EOF'
|
|
|
|
logs=/var/log/zimbra-man.log
|
|
|
|
python3=/usr/local/opt/python-3.9/bin/python3.9
|
|
|
|
certfirst=mail.domain.zone
|
|
|
|
certalias=smtp.domain.zone pop3.domain.zone imap.domain.zone
|
|
|
|
certemail=mail@domain.zone
|
|
|
|
EOF
|
|
|
|
```
|
|
|
|
|
|
|
|
```bash
|
|
|
|
# sudo sh -c "EDITOR=nano crontab -e"
|
|
|
|
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
|
|
|
|
0 0 * * 1 bash /usr/local/bin/zimbra-man.sh qn ssl >> /dev/null 2>&1
|
|
|
|
```
|
2023-05-01 00:30:38 +03:00
|
|
|
|
|
|
|
```bash
|
2023-05-01 11:48:30 +03:00
|
|
|
# check journal
|
|
|
|
tail -f -n 50 /var/log/zimbra-man.log
|
2023-05-01 00:30:38 +03:00
|
|
|
```
|
|
|
|
|
2023-05-01 11:48:30 +03:00
|
|
|
### Print length of all zimbra queues
|
2023-05-01 00:30:38 +03:00
|
|
|
|
|
|
|
```bash
|
2023-05-01 11:48:30 +03:00
|
|
|
sudo /usr/local/bin/zimbra-man.sh - que
|
2023-05-01 00:30:38 +03:00
|
|
|
```
|