Skip to content

Commit 2f0b79f

Browse files
cliffmccarthymissytake
authored andcommitted
feat: Automate file ownership setting from host migration process
- Added a step to deploy_chatmail() that sets ownership of paths that are copied over as part of the upgrade process. - Removed manual chown step from README.md.
1 parent ffa5609 commit 2f0b79f

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

README.md

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -395,15 +395,6 @@ in this case, just run `ssh-keygen -R "mail.example.org"` as recommended.
395395
Postfix and Dovecot are disabled for now; we will enable them later.
396396
We first need to make the new site fully operational.
397397

398-
3. On the new site, run the following to ensure the ownership is correct in case UIDs/GIDs changed:
399-
400-
```
401-
chown root: -R /var/lib/acme
402-
chown opendkim: -R /etc/dkimkeys
403-
chown vmail: -R /home/vmail/mail
404-
chown echobot: -R /run/echobot
405-
```
406-
407398
4. Now, update DNS entries.
408399

409400
If other MTAs try to deliver messages to your chatmail domain they may fail intermittently,

cmdeploy/src/cmdeploy/__init__.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -748,6 +748,20 @@ def deploy_chatmail(config_path: Path, disable_mail: bool) -> None:
748748
_remove_rspamd()
749749
opendkim_need_restart = _configure_opendkim(mail_domain, "opendkim")
750750

751+
#
752+
# If this system is pre-populated with data from a previous instance,
753+
# we might need to adjust ownership of files.
754+
#
755+
stateful_paths = {
756+
"/etc/dkimkeys": "opendkim",
757+
"/home/vmail/mail": "vmail",
758+
"/run/echobot": "echobot",
759+
"/var/lib/acme": "root",
760+
}
761+
for stateful_path, path_owner in stateful_paths.items():
762+
files.directory(stateful_path) # In case it doesn't exist yet.
763+
server.shell("chown {}: -R {}".format(path_owner, stateful_path))
764+
751765
systemd.service(
752766
name="Start and enable OpenDKIM",
753767
service="opendkim.service",

0 commit comments

Comments
 (0)