Difference between revisions of "Rocket Chat:Contrib"

From SME Server
Jump to navigationJump to search
Line 9: Line 9:
 
11th Jan 2018
 
11th Jan 2018
  
Current RPM in my repo is 0.59.6
+
Current RPM in my repo is 0.60.4
  
 
https://reetspetit.com/smeserver/6/repoview/rocketchat.html
 
https://reetspetit.com/smeserver/6/repoview/rocketchat.html
Line 17: Line 17:
 
https://github.com/RocketChat/Rocket.Chat/tags
 
https://github.com/RocketChat/Rocket.Chat/tags
  
{{Note box|Latest Development version is 0.60.4 but this is not working correctly due to upgrades to node and requiring a prebuilt fibers module.
+
{{Note box|Latest version is 0.60.4
It will work by starting it manually with 'node main.js'}}
+
This requires node 8.x and a prebuilt module which the RPM should install}}
  
 
==Required repos==
 
==Required repos==
Line 66: Line 66:
 
From Rocketchat 0.40 onwards you require a higher version of node than the one in the SCL repos.
 
From Rocketchat 0.40 onwards you require a higher version of node than the one in the SCL repos.
  
Rocket.Chat v 49.0+ requires:
+
Rocket.Chat v 60.0+ requires:
node: v4.7.2
+
node: v8.9.3
npm: v3.10.9
+
npm: v5.6.0
  
This can be installed from the node repo
+
This can be installed from the node repo. The following is how to check and set up node versions manually - the rpm should sort this out for you.
  
 
===Setup node versions:===
 
===Setup node versions:===
  
Install node version
+
Some of this is magic (to me!) and I still don't get the local and global stuff. Be careful with paths. See NPM Usage below for more.
n 4.7.2
 
  
[root@test ~]# node -v
+
The node rpm install node to /usr/bin but the npm 'n' module will install to /usr/local/bin
v4.7.2
 
  
Install latest version:
+
Check the version of node in /usr/bin
npm install -g npm
 
  
Install specific version:
+
[root@test ~]# node -v
  npm install -g npm@3.10.9
+
  v8.9.3
  
 
Install n version manager:
 
Install n version manager:
 
  npm install -g n
 
  npm install -g n
 +
Install specific node version (which will go in /usr/local/bin)<syntaxhighlight>
 +
n 8.9.3
 +
</syntaxhighlight>Install the LTS version<syntaxhighlight>
 +
n lts
 +
</syntaxhighlight>List available versions<syntaxhighlight>
 +
n ls
 +
</syntaxhighlight>Install latest version of npm:
 +
npm install -g npm
  
  [root@test ~]# npm --version
+
Install specific npm version:
3.10.9
+
  npm install -g npm@5.6.0
 +
Show the npm version<syntaxhighlight>
 +
[root@test ~]# npm --version
 +
5.6.0
 +
</syntaxhighlight>
  
yum --enablerepo=centos-sclo-rh,epel install scl-utils rh-python34-python rh-mongodb26-mongodb rh-mongodb26-mongodb-server \
+
=== Install required rpms ===
GraphicsMagick  
+
<syntaxhighlight>
 +
yum --enablerepo=centos-sclo-rh,epel install scl-utils rh-python34-python rh-mongodb26-mongodb rh-mongodb26-mongodb-server \
 +
GraphicsMagick  
 +
</syntaxhighlight>
  
 
You should be able to install the smeserver-rocketchat RPM now
 
You should be able to install the smeserver-rocketchat RPM now
Line 137: Line 149:
 
  use rocketchat
 
  use rocketchat
 
  db.rocketchat_settings.update({"_id" <nowiki>: "SMTP_Host"}, {$set: {"value":"mail.yourdomain.com"}})
 
  db.rocketchat_settings.update({"_id" <nowiki>: "SMTP_Host"}, {$set: {"value":"mail.yourdomain.com"}})
  db.rocketchat_settings.update({"_id"</nowiki> <nowiki>: "From_Email"}, {$set: {"value":"admin@yourdomain.com"}})
+
  db.rocketchat_settings.update({"_id"</nowiki> <nowiki>: "From_Email"}, {$set: {"value":"admin@yourdomain.com"}})
  exit</nowiki>
+
  exit</nowiki>
  
 
Restart Rocket.Chat to be sure:
 
Restart Rocket.Chat to be sure:
Line 158: Line 170:
 
Check /var/log/rocketchat.log
 
Check /var/log/rocketchat.log
  
Try running main.js
+
Try running main.js manually:<syntaxhighlight>
/opt/Rocket.Chat
+
export PORT=3000
node main.js
+
export MAIL_URL=smtp://localhost:25
 +
export MONGO_URL=mongodb://localhost:27017/rocketchat
 +
export ROOT_URL=http://my.smeserver.net/opt/Rocket.Chat
 +
node main.js
 +
</syntaxhighlight>
  
 
===SSL with Proxypass===
 
===SSL with Proxypass===
Line 293: Line 309:
  
 
  db.rocketchat_settings.update({"_id" <nowiki>: "From_Email"}, {$set: {"value":"admin@yourdomain.com"}})
 
  db.rocketchat_settings.update({"_id" <nowiki>: "From_Email"}, {$set: {"value":"admin@yourdomain.com"}})
  db.rocketchat_settings.update({"_id"</nowiki> <nowiki>: "SMTP_Host"}, {$set: {"value":"mail.yourdomain.com"}})</nowiki>
+
  db.rocketchat_settings.update({"_id"</nowiki> <nowiki>: "SMTP_Host"}, {$set: {"value":"mail.yourdomain.com"}})</nowiki>
  
  

Revision as of 12:40, 12 January 2018

Contrib: [1]John Crisp

Important.png Note:
Please note that there is also a howto on manually installing Rocket.Chat here


smeserver-rocketchat contrib

Warning.png Work in Progress:
This page is a Work in Progress. The contents off this page may be in flux, please have a look at this page history the to see list of changes.


This contrib aims to reduce some of the setup for rocketchat and add some flexibility with settings

Current version

11th Jan 2018

Current RPM in my repo is 0.60.4

https://reetspetit.com/smeserver/6/repoview/rocketchat.html

Latest source is here:

https://github.com/RocketChat/Rocket.Chat/tags


Important.png Note:
Latest version is 0.60.4

This requires node 8.x and a prebuilt module which the RPM should install


Required repos

Add repos:

/sbin/e-smith/db yum_repositories set epel repository \
Name 'Epel - EL6' \
BaseURL 'http://download.fedoraproject.org/pub/epel/6/$basearch' \
MirrorList 'http://mirrors.fedoraproject.org/mirrorlist?repo=epel-6&arch=$basearch' \
EnableGroups no \
GPGCheck yes \
GPGKey http://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL \
Exclude perl-Razor-Agent \
Visible no \
status disabled
/sbin/e-smith/db yum_repositories set reetp repository \
BaseURL http://www.reetspetit.com/smeserver/\$releasever \
EnableGroups no \
GPGCheck no \
Name "ReetP Repo" \
GPGKey http://www.reetspetit.com/RPM-GPG-KEY \
Visible yes status disabled
/sbin/e-smith/db yum_repositories set centos-sclo-rh \
repository Name 'Centos-RH Software collections' \
BaseURL 'http://mirror.centos.org/centos/$releasever/sclo/$basearch/rh/' \
EnableGroups no Visible yes status disabled
/sbin/e-smith/db yum_repositories set nodejs8 \
repository Name 'Node JS 8' \
BaseURL https://rpm.nodesource.com/pub_8.x/el/6/x86_64 \
EnableGroups no GPGCheck no Visible yes status disabled
signal-event yum-modify
yum --enablerepo=nodejs install nodejs nodejs-devel

RocketChat 0.40+

From Rocketchat 0.40 onwards you require a higher version of node than the one in the SCL repos.

Rocket.Chat v 60.0+ requires: node: v8.9.3 npm: v5.6.0

This can be installed from the node repo. The following is how to check and set up node versions manually - the rpm should sort this out for you.

Setup node versions:

Some of this is magic (to me!) and I still don't get the local and global stuff. Be careful with paths. See NPM Usage below for more.

The node rpm install node to /usr/bin but the npm 'n' module will install to /usr/local/bin

Check the version of node in /usr/bin

[root@test ~]# node -v
v8.9.3

Install n version manager:

npm install -g n

Install specific node version (which will go in /usr/local/bin)

n 8.9.3

Install the LTS version

 n lts

List available versions

n ls

Install latest version of npm:

npm install -g npm

Install specific npm version:

npm install -g npm@5.6.0

Show the npm version

[root@test ~]# npm --version
5.6.0

Install required rpms

yum --enablerepo=centos-sclo-rh,epel install scl-utils rh-python34-python rh-mongodb26-mongodb rh-mongodb26-mongodb-server \
GraphicsMagick

You should be able to install the smeserver-rocketchat RPM now

yum --enablerepo=reetp install smeserver-rocketchat

Don't post-upgrade yet.

config set rocketchat service TCPPort 3000 mailPort 25 mailURL localhost access public status enabled
config set rh-mongodb26-mongod service TCPPort 27017 mongoURL localhost access private status enabled
signal-event post-upgrade;signal-event reboot

Now we should be able to install rocketchat itself - it is better to specify a version here in case a newer version breaks anything:

yum --enablerepo=reetp install rocketchat-0.59.6

Check the progress:

tailf /var/log/rocketchat.log
System ➔ startup
+----------------------------------------------------+
|                  SERVER RUNNING                    |
+----------------------------------------------------+
|                                                    |
|       Version: 0.xx.x                              |
|  Process Port: 3000                                |
|      Site URL: http://rocketchat.local.net:3000    |
|         OpLog: Disabled                            |
|                                                    |
+----------------------------------------------------+

You should now be able to connect to your Rocket.Chat instance

http://rocketchat.local.net:3000

Registering a new account

Because the SME mail server is fussy you may find it easier to force some settings in the Rocket.Chat DB before trying to register:

You can set your SMTP host as localhost or mail.yourdomain.com

mongo
use rocketchat
db.rocketchat_settings.update({"_id" : "SMTP_Host"}, {$set: {"value":"mail.yourdomain.com"}})
   db.rocketchat_settings.update({"_id" : "From_Email"}, {$set: {"value":"admin@yourdomain.com"}})
   exit

Restart Rocket.Chat to be sure:

service rocketchat restart

You should now be able to register a new account and get a confirmation email. Check /var/log/qpsmtpd/current for any errors.

If you have not set the From address you are likely to get:

Mail with no From header not accepted here

Errors

If you have issues make sure you stop the rocket chat service

service rocketchat stop

Check /var/log/rocketchat.log

Try running main.js manually:

export PORT=3000
export MAIL_URL=smtp://localhost:25
export MONGO_URL=mongodb://localhost:27017/rocketchat
export ROOT_URL=http://my.smeserver.net/opt/Rocket.Chat
node main.js

SSL with Proxypass

Important.png Note:
This is still experimental and there may be issues with SSL only for the Primary iBay and Letsencrypt. You will need a minimum version of smeserver-rocketchat-0.1-5


It is recommended to add Letsencrypt support as detailed below (see here for my contrib https://wiki.contribs.org/Letsencrypt)

We need some extra settings to enable SSL with ProxyPass.

Add the FWS repo:

db yum_repositories set fws repository \
BaseURL http://repo.firewall-services.com/centos/\$releasever \
EnableGroups no GPGCheck yes \
Name "Firewall Services" \
GPGKey http://repo.firewall-services.com/RPM-GPG-KEY \
Visible yes status disabled

Update the repos:

signal-event yum-modify

Install proxy pass rpm:

yum --enablerepo=fws install mod_proxy_wstunnel

Regenerate httpd.conf

signal-event remoteaccess-update

Now we need to setup our subdomain

db domains set chat.mycompany.local domain Description RocketChat Nameservers internet \
TemplatePath ProxyPassVirtualRocketchat ProxyPassTarget http://localhost:3000/

It should look like this:

chat.mycompany.local=domain
  Nameservers=internet (can be localhost)
  ProxyPassTarget=http://127.0.0.1:3000/
  TemplatePath=ProxyPassVirtualRocketchat
  letsencryptSSLcert=enabled (with letsencrypt support)

We need to set Rocket.Chat to listen on localhost now:

config setprop rocketchat rootURL chat.mycompany.domain SSLProxy yes
signal-event remoteaccess-update
service rocketchat restart

If you can now successfully get to Rocketchat on your subdomain https://chat.mycompany.local you can disable default access on port 3000:

config setprop rocketchat access private
signal-event remoteaccess-update

You may find you need to clear your browser cache before it works correctly on https://chat.mycompany.local rather than http://chat.mycompany.local:3000

IF you have Letsencrypt support you can now set your main domain to SSL only:

db accounts setprop Primary SSL enabled
signal-event ibay-modify Primary

Upgrades

To upgrade rocketchat:

yum --enablerepo=reetp install rocketchat

To upgrade the rocketchat configurator:

yum --enablerepo=reetp install smeserver-rocketchat

Bugs

Look for bugs :-) As the contrib is not in CVS please report them in the forum and I will try and keep an eye out.

Manual config of templates

expand-template /etc/rc.d/init.d/rocketchat
expand-template /etc/profile.d/scls-rh-mongodb26.sh
expand-template /etc/profile.d/scls-rh-python34.sh
expand-template /etc/profile.d/scls-rh-java-common.sh
expand-template /etc/opt/rh/rh-mongodb26/mongod.conf
/etc/rc.d/init.d/rocketchat start
/etc/rc.d/init.d/rh-mongodb26-mongos start

Mongod fails to start after reboot

Sometimes it appears that mongo fails to start after a reboot.

I believe that this may be caused due to rocketchat being run by the forever service which means that rocketchat tries to keep running as the server shuts down despite mongod being stopped. This leaves lock files and prevents mongod from restarting properly. I think I probably need to look at the shutdown/start order of scripts.

A simple cure is as follows:

/etc/rc.d/init.d/rh-mongodb26-mongod stop

Remove the following files if they exist:

rm /var/opt/rh/rh-mongodb26/lib/mongodb/mongod.lock
rm /var/opt/rh/rh-mongodb26/run/mongodb/mongod.pid

Restart the mongod service:

/etc/rc.d/init.d/rh-mongodb26-mongod start

Restart the rocketchat service:

service rocketchat restart

The following is simpler and appears to work:

service rocketchat stop
/etc/rc.d/init.d/rh-mongodb26-mongod restart
service rocketchat start

Mongo DB examples

Usage

Example using mongo itself:

mongo
use rocketchat

Show all collections in DB

show collections

Show all entries in a collection

db.rocketchat_avatars.chunks.find()
db.rocketchat_settings.find({"_id" : "SMTP_Host"})
db.rocketchat_settings.find({"_id" : "From_Email"})
db.rocketchat_settings.findOne({_id : "From_Email"}, {_id:0, value: 1})
db.rocketchat_settings.findOne({_id : "SMTP_Host"}, {_id:0, value: 1})
db.rocketchat_settings.update({"_id" : "From_Email"}, {$set: {"value":"admin@yourdomain.com"}})
   db.rocketchat_settings.update({"_id" : "SMTP_Host"}, {$set: {"value":"mail.yourdomain.com"}})


Remove all entries in a collection (CAREFUL!!!!!!)

db.rocketchat_avatars.chunks.remove({})

Help

help

Database Backup

You can dump the tables to a directory of your choice:

mongodump --dumpDbUsersAndRoles -d rocketchat -o /root/rocketchatmongo

Database Restore

You can restore you database as follows:

mongorestore --restoreDbUsersAndRoles -d rocketchat -dir  /root/rocketchatmongo/rocketchat --quiet

Node usage

Use n, an extremely simple Node version manager that can be installed via npm (See http://stackoverflow.com/questions/7718313/how-to-change-to-an-older-version-of-node-js)

Say you want Node.js v0.10.x to build Atom.

npm install -g n   # Install n globally
n 0.10.33          # Install and use v0.10.33 local only

Usage:

n                            # Output versions installed
n latest                     # Install or activate the latest node release
n stable                     # Install or activate the latest stable node release
n <version>                  # Install node <version>
n use <version> [args ...]   # Execute node <version> with [args ...]
n bin <version>              # Output bin path for <version>
n rm <version ...>           # Remove the given version(s)
n --latest                   # Output the latest node version available
n --stable                   # Output the latest stable node version available
n ls                         # Output the versions of node available


NPM Usage

To update your version of npm run the following

npm install -g npm

Or for a specific version:

npm install -g npm@3.10.9

DB settings

Typical standard setup:

rocketchat=service
   TCPPort=3000
   access=public
   mailPort=25
   mailURL=localhost
   status=enabled

Typical proxy subdomain setup:

rocketchat=service
   SSLProxy=yes
   TCPPort=3000
   access=private
   mailPort=25
   mailURL=localhost
   rootURL=chat.mydomain.co.uk
   status=enabled
rh-mongodb26-mongod=service
   TCPPort=27017
   access=private
   mongoURL=localhost
   status=enabled