Updating wildduck via git - nodemailer/wildduck GitHub Wiki

Prerequisite

This page assumes you have installed the complete wildduck setup:

  • wildduck IMAP/POP3 server
  • zone-mta smtp server (outgoing emails)
  • haraka and haraka-wildduck plugin (incoming emails)
  • wildduck webmail interface (direct access to wildduck via REST api)
  • mongodb for emails and attachment
  • redis for communication between components (wildduck <-> haraka-wildduck <-> zone-mta) and also for multi-server setup

Via our /setup/get_install.sh script either on VPS or physical server (tested on ubuntu 16.04.4).

Filesystem

After installation .git directory is separated from the programs' folder:

  • /opt/haraka/plugins/wildduck <-> /var/opt/haraka-plugin-wildduck.git
  • /opt/wildduck <-> /var/opt/wildduck.git/
  • /opt/wildduck-webmail <-> /var/opt/wildduck-webmail.git/
  • /opt/zone-mta <-> /var/opt/zone-mta.git/
  • /opt/zone-mta/plugins/wildduck <-> /var/opt/zonemta-wildduck.git/

Precaution must be taken when updating git (git pull), as we need both specify the working director and also the git directory too.

1. Updating zone-mta-template

Check the status

$ git --git-dir=/var/opt/zone-mta.git --work-tree="/opt/zone-mta/" status
HEAD detached at f5f6a80

In case of this error message:

$ git --git-dir=/var/opt/zone-mta.git --work-tree="/opt/zone-mta/" log origin/master
fatal: ambiguous argument 'origin/master': unknown revision or path not in the working tree.

You need to add the following line to /var/opt/zone-mta.git/config:

	fetch = +refs/heads/*:refs/remotes/origin/*

See this answer. So the whole config file looks like this:

[core]
	repositoryformatversion = 0
	filemode = true
	bare = true
[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git://github.com/zone-eu/zone-mta-template.git
(root) $ sudo su deploy
(deploy) $ cd /var/opt/zone-mta.git
(deploy) $ git fetch origin # git fetch origin is needed before specific commit
(deploy) $ git fetch origin a84467fc4e576e0939f18270997f598d9e2830f7
(deploy) $ # git --git-dir=/var/opt/zone-mta.git --work-tree="/opt/zone-mta" checkout -- package.json
(deploy) $ git --git-dir=/var/opt/zone-mta.git --work-tree="/opt/zone-mta" checkout a84467fc4e576e0939f18270997f598d9e2830f7
(deploy) $ cd /opt/zone-mta/
(deploy) $ npm install --production 
(deploy) $ exit
(root) $ systemctl restart zone-mta

2. Updating zone-mta-wildduck

Check the status

git --git-dir=/var/opt/zonemta-wildduck.git --work-tree="/opt/zone-mta/plugins/wildduck/" status
(root) $ sudo su deploy
(deploy) $ cd /var/opt/zonemta-wildduck.git
(deploy) $ git fetch origin # git fetch origin is needed before specific commit
(deploy) $ git fetch origin 2798c42b235f9e1c1d8627d29eb742df27efb28a
(deploy) $ git --git-dir=/var/opt/zonemta-wildduck.git --work-tree="/opt/zone-mta/plugins/wildduck/" checkout 2798c42b235f9e1c1d8627d29eb742df27efb28a
(deploy) $ cd /opt/zone-mta/plugins/wildduck
(deploy) $ npm install --production 
(deploy) $ exit
(root) $ systemctl restart zone-mta

3. Update wildduck:

Precheck (not needed when updating)

Enable email notification when new user account is created.

(deploy) $ git --git-dir=/var/opt/wildduck.git --work-tree=/opt/wildduck diff -- emails/00*json
diff --git a/emails/00-example.json b/emails/00-example.json
index 2e2f326..b056776 100644
--- a/emails/00-example.json
+++ b/emails/00-example.json
@@ -1,5 +1,5 @@
 {
-    "disabled": true,
+    "disabled": false,
 
     "flag": true,

(need to doublecheck if disabled:true is the right settings)

Check the status

(root) $ sudo su deploy 
(deploy) $ cd /var/opt/wildduck.git
(deploy) $ git --git-dir=/var/opt/wildduck.git --work-tree=/opt/wildduck fetch origin
(deploy) $ git --git-dir=/var/opt/wildduck.git --work-tree=/opt/wildduck fetch origin 8789cce45fdf010c33580e417505ef26197c21dc
(deploy) $ git --git-dir=/var/opt/wildduck.git --work-tree=/opt/wildduck checkout 8789cce45fdf010c33580e417505ef26197c21dc
(deploy) $ cd /opt/wildduck
(deploy) $ npm install --production 
(deploy) $ exit 
(userr)  $ systemctl restart wildduck

Remark: First git fetch origin is needed, then git fetch origin [HASH], otherwise this error happens:

(deploy) $ git --git-dir=/var/opt/wildduck.git --work-tree=/opt/wildduck checkout 538da537ca3cef0bbd714da70085cfd4cc734b49
fatal: reference is not a tree: 538da537ca3cef0bbd714da70085cfd4cc734b49

4. Update haraka-plugin-wildduck:

(root) $ sudo su deploy
(deploy) $ cd /var/opt/haraka-plugin-wildduck.git/
(deploy) $ git --git-dir=/var/opt/haraka-plugin-wildduck.git --work-tree=/opt/haraka/plugins/wildduck fetch origin
(deploy) $ git --git-dir=/var/opt/haraka-plugin-wildduck.git --work-tree=/opt/haraka/plugins/wildduck checkout 14db1ceed857f8616094cfd2f52b6b58bf413173
(deploy) $ cd /opt/haraka/plugins/wildduck/
(deploy) $ npm install --unsafe-perm --production
(deploy) $ exit
(userr) $ systemctl restart haraka

5. Update wildduck-webmail

(root) $ sudo su deploy 
(deploy) $ cd /var/opt/wildduck-webmail.git/
(deploy) $ git --git-dir=/var/opt/wildduck-webmail.git --work-tree=/opt/wildduck-webmail fetch origin
(deploy) $ git --git-dir=/var/opt/wildduck-webmail.git --work-tree=/opt/wildduck-webmail fetch origin cc7829eeb79e7952b30f90a2c0c96cc213ce3ce4
(deploy) $ git --git-dir=/var/opt/wildduck-webmail.git --work-tree=/opt/wildduck-webmail checkout cc7829eeb79e7952b30f90a2c0c96cc213ce3ce4
(deploy) $ cd /opt/wildduck-webmail
(deploy) $ npm install --production 
(deploy) $ exit 
(userr)  $ systemctl restart wildduck-webmail

Check Redis, and flushes all the keys in all databases:

$ redis-cli
127.0.0.1:6379> info keyspace
# Keyspace
db3:keys=341,expires=322,avg_ttl=159758700
db5:keys=14,expires=14,avg_ttl=16665217
127.0.0.1:6379> select 3
127.0.0.1:6379> keys "*"
...
168) "unseen:5b1efd14c2253c04a787ab8b"
169) "unseen:5b18469dc4acb0049beafddf"
170) "unseen:5b184638c4acb0049beafdbd"
171) "unseen:5b1efd15c2253c04a787abcd"
172) "total:5b1f8ac986d833049cb8feab"
...
127.0.0.1:6379> flushall
127.0.0.1:6379> exit