Rocket Chat:Contrib

From SME Server
Revision as of 12:43, 21 December 2016 by ReetP (talk | contribs) (→‎Proxy Pass)
Jump to navigationJump to search

Contrib: 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

Add repos:

RocketChat 0.40+

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

Rocket.Chat v 48.1 requires: node: v4.6.2 npm: v3.10.9

Setup

Add the following 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 nodejs \
repository Name 'Node JS 4' \
BaseURL https://rpm.nodesource.com/pub_4.x/el/6/x86_64 \
EnableGroups no GPGCheck no Visible yes status disabled
signal-event yum-modify
yum --enablerepo=nodejs install nodejs nodejs-devel

Setup node versions:

Install latest version:

npm install -g npm

Install specific version:

npm install -g npm@3.10.9

Install n version manager:

npm install -g n
[root@test ~]# node -v
v4.7.0
[root@test ~]# npm --version
3.10.9
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

yum --enablerepo=reetp install rocketchat

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                            |
|                                                    |
+----------------------------------------------------+

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

service rocketchat stop

Try running main.js

/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.

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
  ProxyPassTarget=http://127.0.0.1:3000/
  TemplatePath=ProxyPassVirtualRocketchat

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

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


Mongo DB examples

Example using mongo itself:

mongo
use rocketchat
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"}})

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