Difference between revisions of "Rocket Chat:Contrib"

From SME Server
Jump to navigationJump to search
(45 intermediate revisions by 2 users not shown)
Line 1: Line 1:
'''[[Rocket_Chat#smeserver-rocketchat_contrib|Contrib]]''': [mailto:jcrisp@safeandsound.co.uk[[User:ReetP|John Crisp]]]
+
'''[[Rocket_Chat#smeserver-rocketchat_contrib|Contrib]]''': [mailto:jcrisp@safeandsound.co.uk][[User:ReetP|John Crisp]]
{{Note box|Please note that there is also a howto on installing Rocket.Chat manually [[Rocket_Chat|'''here''']]}}
+
{{Note box|Please note that there is also a howto on manually installing Rocket.Chat [[Rocket_Chat|'''here''']]
 +
However, due to dependencies a manual install will not work on SME}}Version up to 0.61.2 will work with this contrib.
 +
 
 +
Later versions will need my newer smeserver-rocketchat-0.2.x contrib which uses docker.
 +
 
 
==smeserver-rocketchat contrib==
 
==smeserver-rocketchat contrib==
 
{{WIP box}}
 
{{WIP box}}
 
This contrib aims to reduce some of the setup for rocketchat and add some flexibility with settings
 
This contrib aims to reduce some of the setup for rocketchat and add some flexibility with settings
  
==RocketChat 0.39.0==
+
==Current version==
{{Note box | This section will ONLY work up to Rocket Chat version 0.39 as they changed the required node version after that. To run version 0.40 and higher please see further down the page}}
+
 
 +
3rd March 2018
 +
 
 +
Rocket RPM in my repo is 0.61.2
 +
 
 +
0.61.2 is likely to be the last version that can be installed direct to CentOS 6/ Koozali SME v9.x due to node module dependency requirements
 +
 
 +
I have tried to build 0.62.0 so far without success see this bug https://github.com/RocketChat/Rocket.Chat/issues/9943
 +
 
 +
https://reetspetit.com/smeserver/6/repoview/rocketchat.html
 +
 
 +
Latest source is here:
 +
 
 +
https://github.com/RocketChat/Rocket.Chat/tags
 +
 
 +
{{Note box|Latest version is 0.61.2
 +
This requires node 8.x and a prebuilt module which the RPM should install}}I am currently looking at running Rocket 0.62 on docker in CentOS 6 which I do have working using the existing local Mongo DB
 +
 
 +
I will post a link to a new wiki page when I have it tested further and know what I am doing with Docker
 +
 
 +
==Required repos==
  
 
Add repos:
 
Add repos:
Line 13: Line 37:
 
* [[Centos-sclo-rh]]
 
* [[Centos-sclo-rh]]
 
* [[User:ReetP|reetp]]  
 
* [[User:ReetP|reetp]]  
 +
* [[Fws]]
 +
 +
/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
  
  yum install rh-python34-python rh-mongodb26-mongodb rh-mongodb26-mongodb-server nodejs010 GraphicsMagick --enablerepo=centos-sclo-rh,epel
+
  /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
  
  scl enable nodejs010 bash
+
  /sbin/e-smith/db yum_repositories set centos-sclo-rh \
  npm install -g inherits
+
repository Name 'Centos-RH Software collections' \
  npm install -g n
+
BaseURL 'http://mirror.centos.org/centos/$releasever/sclo/$basearch/rh/' \
n 0.10.40
+
EnableGroups no Visible yes status disabled
exit
+
 
 +
/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=nodejs8 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
  
{{Note box | Please be careful to only install JUST the required packages in my repo. There are various testing packages in there that will BREAK YOUR SYSTEM ! }}
+
[root@test ~]# node -v
 +
v8.9.3
  
You should now be able to install the rocketchat bundle with:
+
Install n version manager:
 +
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
  
  yum --enablerepo=reetp install rocketchat
+
Install specific npm version:
 +
  npm install -g npm@5.6.0
 +
Show the npm version<syntaxhighlight>
 +
[root@test ~]# npm --version
 +
5.6.0
 +
</syntaxhighlight>
  
This may take a while on first install as it installs the npm modules for the first time.
+
=== Install required rpms ===
 +
<syntaxhighlight>
 +
yum --enablerepo=centos-sclo-rh,epel install scl-utils rh-python34-python rh-mongodb26-mongodb rh-mongodb26-mongodb-server \
 +
GraphicsMagick
 +
</syntaxhighlight>
  
Now you should be able to install the rocketchat contrib:
+
You should be able to install the smeserver-rocketchat RPM now
  
 
  yum --enablerepo=reetp install smeserver-rocketchat
 
  yum --enablerepo=reetp install smeserver-rocketchat
  
  db configuration setprop rocketchat status enabled
+
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
 
  signal-event post-upgrade;signal-event reboot
  
DB settings
+
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
  
  rocketchat=service
+
Check the progress:
    TCPPort=3000
+
  tailf /var/log/rocketchat.log
    access=public
 
    mailPort=25
 
    mailURL=localhost
 
    status=enabled
 
  
  rh-mongodb26-mongod=service
+
  System ➔ startup
    TCPPort=27017
+
+----------------------------------------------------+
    access=private
+
|                  SERVER RUNNING                    |
    mongoURL=localhost
+
+----------------------------------------------------+
    status=enabled
+
|                                                    |
 +
|      Version: 0.xx.x                              |
 +
|  Process Port: 3000                                |
 +
|      Site URL: <nowiki>http://rocketchat.local.net:3000</nowiki>    |
 +
|        OpLog: Disabled                            |
 +
|                                                    |
 +
+----------------------------------------------------+
  
BEFORE we login for the first time we need to set up mail settings correctly:
+
You should now be able to connect to your Rocket.Chat instance
  
From bash:
+
http://rocketchat.local.net:3000
  
mongo rocketchat --eval 'db.rocketchat_settings.update({"_id" : "SMTP_Host"}, {$set: {"value":"localhost"}});'
+
===Registering a new account===
mongo rocketchat --eval 'db.rocketchat_settings.update({"_id" : "From_Email"}, {$set: {"value":"admin@yourdomain.com"}});'
 
  
We can check the individual values set like this:
+
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:
  
mongo rocketchat --eval 'db.rocketchat_settings.find({"_id":"From_Email"}, {_id:0, value:1}).shellPrint();'
+
You can set your SMTP host as localhost or mail.yourdomain.com
mongo rocketchat --eval 'db.rocketchat_settings.find({"_id":"SMTP_Host"}, {_id:0, value: 1}).shellPrint();'
 
 
 
All values per _id:
 
mongo rocketchat --eval 'db.rocketchat_settings.find({"_id" : "SMTP_Host"}).shellPrint();'
 
mongo rocketchat --eval 'db.rocketchat_settings.find({"_id" : "From_Email"}).shellPrint();'
 
  
 +
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<
  
Now restart rocketchat to reread the DB settings:
+
Restart Rocket.Chat to be sure:
  
 
  service rocketchat restart
 
  service rocketchat restart
  
Login at http://yourdomain:3000
+
You should now be able to register a new account and get a confirmation email. Check /var/log/qpsmtpd/current for any errors.
  
It will first get you to create an admin user.
+
If you have not set the From address you are likely to get:
  
If you have an issue with no email sent/received then login using the email address and password you just set
+
Mail with no From header not accepted here
  
===Updates===
+
===Errors===
  
If there is an update to Rocket.Chat I will add to my repo. You should just be able to run:
+
If you have issues make sure you stop the rocket chat service
  
  yum --enablerepo=reetp install rocketchat
+
  service rocketchat stop
  
You can also update the smeserver-rocketchat contrib in the same way
+
Check /var/log/rocketchat.log
  
yum --enablerepo=reetp install smeserver-rocketchat
+
Try running main.js manually:<syntaxhighlight>
 +
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
 +
</syntaxhighlight>
  
===SSL===
+
===SSL with Proxypass===
 +
{{Note box|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 }}
  
{{Note box | 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)
 
 
{{Note box | I've realised I need to re-hack the web templates for this but still trying to work it out - please ask in the forums and I can give you some tips to get it working}}
 
 
 
It is recommended to add Letsencrypt support as detailed below.
 
  
 
We need some extra settings to enable SSL with ProxyPass.
 
We need some extra settings to enable SSL with ProxyPass.
  
First install proxy pass rpm:
+
Add the FWS repo:
  
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
  
* [[Fws]]
+
Update the repos:
 +
signal-event yum-modify
  
 +
Install proxy pass rpm:
 
  yum --enablerepo=fws install mod_proxy_wstunnel
 
  yum --enablerepo=fws install mod_proxy_wstunnel
  
 
Regenerate httpd.conf
 
Regenerate httpd.conf
 
 
  signal-event remoteaccess-update
 
  signal-event remoteaccess-update
  
Now we need to setup our subdomain
+
Now we need to setup our subdomain for the reverse proxy
  
 
  db domains set chat.mycompany.local domain Description RocketChat Nameservers internet \
 
  db domains set chat.mycompany.local domain Description RocketChat Nameservers internet \
Line 118: Line 219:
  
 
It should look like this:
 
It should look like this:
 
 
  chat.mycompany.local=domain
 
  chat.mycompany.local=domain
    Nameservers=internet
+
  Nameservers=internet (can be localhost)
    ProxyPassTarget=http://127.0.0.1:3000/
+
  ProxyPassTarget=http://127.0.0.1:3000/
    TemplatePath=ProxyPassVirtualRocketchat
+
  TemplatePath=ProxyPassVirtualRocketchat
 
+
  letsencryptSSLcert=enabled (with letsencrypt support)
  
 
We need to set Rocket.Chat to listen on localhost now:
 
We need to set Rocket.Chat to listen on localhost now:
  
  config setprop rocketchat rootURL localhost
+
  config setprop rocketchat rootURL chat.mycompany.domain SSLProxy yes
 
  signal-event remoteaccess-update
 
  signal-event remoteaccess-update
 
  service rocketchat restart
 
  service rocketchat restart
Line 136: Line 236:
 
  signal-event remoteaccess-update
 
  signal-event remoteaccess-update
  
===Letsencrypt support===
+
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
  
{{Note box | 26 Aug 2016 - This should now work for a subdomain}}
+
IF you have Letsencrypt support you can now set your main domain to SSL only:
  
You can add letsencrypt should you wish - please see https://wiki.contribs.org/Letsencrypt
+
db accounts setprop Primary SSL enabled
 +
signal-event ibay-modify Primary
  
You will need to add the domain key as follows, and add your letsencrypt certificates as per the wiki page:
+
===Upgrades===
  
db domains setprop chat.mycompany.local letsencryptSSLcert enabled
+
To upgrade rocketchat:
  
Note that smeserver-rocketchat adds redirect on port 80 for the letsencrypt directory .well-known/acme-challenge
+
yum --enablerepo=reetp install rocketchat
  
You should be able to reach:
+
To upgrade the rocketchat configurator:
  
  http://chat.mycompany.local/.well-known/acme-challenge/
+
  yum --enablerepo=reetp install smeserver-rocketchat
  
This should redirect to:
+
===Bugs===
  
https://chat.mycompany.local/.well-known/acme-challenge/
+
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.
  
Anything else going to chat.mycompany.local should get to Rocket.Chat
+
==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
  
===Errors===
+
  /etc/rc.d/init.d/rocketchat start
 
+
/etc/rc.d/init.d/rh-mongodb26-mongos start
You may get an error on install of the rocketchat rpm as follows:
 
 
 
  npm WARN deprecated minimatch@2.0.10: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
 
 
 
This is due to the installed version of npm/node from SCL. Rocket.Chat should till work
 
  
==RocketChat 0.40+==
+
==Mongod fails to start after reboot==
  
From Rocketchat 0.40 onwards you require a higher version of node than the one in the EPEL repos.
+
Sometimes it appears that mongo fails to start after a reboot.
  
Rocket.Chat v 48.1 requires:
+
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.
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 \
+
A simple cure is as follows:
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 \
+
  /etc/rc.d/init.d/rh-mongodb26-mongod stop
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 \
+
Remove the following files if they exist:
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
+
  rm /var/opt/rh/rh-mongodb26/lib/mongodb/mongod.lock
 +
rm /var/opt/rh/rh-mongodb26/run/mongodb/mongod.pid
  
yum --enablerepo=nodejs install nodejs nodejs-devel
+
Restart the mongod service:
  
  yum --enablerepo=centos-sclo-rh,epel install scl-utils rh-python34-python rh-mongodb26-mongodb rh-mongodb26-mongodb-server \
+
  /etc/rc.d/init.d/rh-mongodb26-mongod start
GraphicsMagick
 
  
You should be able to install the smeserver-rocketchat RPM now
+
Restart the rocketchat service:
  
  yum --enablerepo=reetp install smeserver-rocketchat
+
  service rocketchat restart
  
config set rocketchat service TCPPort 3000 mailPort 25 mailURL localhost access public status enabled
+
The following is simpler and appears to work:
config set rh-mongodb26-mongod service TCPPort 27017 mongoURL localhost access private status enabled
 
  
  signal-event post-upgrade;signal-event reboot
+
  service rocketchat stop
 +
/etc/rc.d/init.d/rh-mongodb26-mongod restart
 +
service rocketchat start
  
 +
==Mongo DB examples==
  
===RocketChat run checks===
+
===Usage===
  
Check /var/log/rocketchat.log
+
Example using mongo itself:
  
  System ➔ startup
+
  mongo
+----------------------------------------------------+
 
|                  SERVER RUNNING                    |
 
+----------------------------------------------------+
 
|                                                    |
 
|      Version: 0.xx.x                              |
 
|  Process Port: 3000                                |
 
|      Site URL: <nowiki>http://rocketchat.local.net:3000</nowiki>    |
 
|        OpLog: Disabled                            |
 
|                                                    |
 
+----------------------------------------------------+
 
  
If you have issues make sure you stop the rocket chat service
+
use rocketchat
  
  service rocketchat stop
+
Show all collections in DB
 +
  show collections
  
Check your node versions:
+
Show all entries in a collection
 +
db.rocketchat_avatars.chunks.find()
  
  [root@test Rocket.Chat]# node -v
+
  db.rocketchat_settings.find({"_id" : "SMTP_Host"})
v4.6.2
+
  db.rocketchat_settings.find({"_id" : "From_Email"})
[root@test Rocket.Chat]# npm -v
 
  v3.10.9
 
  
Modify with (see Node Usage below for details if not installed)
+
db.rocketchat_settings.findOne({_id : "From_Email"}, {_id:0, value: 1})
 +
db.rocketchat_settings.findOne({_id : "SMTP_Host"}, {_id:0, value: 1})
  
  n 4.6.2
+
  db.rocketchat_settings.update({"_id":"From_Email"}, {$set: {"value":"admin@yourdomain.com"}})
 +
db.rocketchat_settings.update({"_id":"SMTP_Host"}, {$set: {"value":"mail.yourdomain.com"}})
  
Try running main.js
 
/opt/Rocket.Chat
 
node main.js
 
  
===Manual config of templates===
+
Remove all entries in a collection (CAREFUL!!!!!!)
  expand-template /etc/rc.d/init.d/rocketchat
+
  db.rocketchat_avatars.chunks.remove({})
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
+
Help
  /etc/rc.d/init.d/rh-mongodb26-mongos start
+
  help
  
 +
Some more mongo commands for reference
  
 +
https://github.com/RocketChat/Rocket.Chat/issues/15880#issuecomment-570070433
  
===Proxy Pass===
+
Directly check a specific user ID from bash:
 +
mongo rocketchat --eval "db.users.find({'username':'usernamehere'}).forEach( function(u) { print(u._id + \" ; \" + u.username); } )"
  
The contrib will sort out the templates. You just need some settings as follows:
+
Log into rocketchat database:
 +
mongo rocketchat
  
  [root@test e-smith]# db domains show
+
Check out all the user IDs in the database:
chat.reetspetit.info=domain
+
  db.users.find().forEach( function(u) { print(u._id + ";" + u.username); } )
    Description=RocketChat
 
    Nameservers=internet
 
    ProxyPassTarget=http://127.0.0.1:3000/
 
    TemplatePath=ProxyPassVirtualRocketchat
 
    letsencryptSSLcert=enabled
 
  
 +
Or just a specific user's ID:
 +
db.users.find({'username':'usernamehere'}).forEach( function(u) { print(u._id + \" ; \" + u.username); } )
  
===SSL with Proxypass===
+
Replace specific user ID's password in the database:
{{Note box|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 }}
+
db.users.update( {'_id': 'useridhere'}, {$set: {'services.password.bcrypt': 'bcryptedpasswordhere'}}, {multi:true} )
  
 +
My only issue with above (only time I needed it for recovery purposes), was that I didn't know which tool to use to generate a bcrypted password. So in the hurry I copied the hash from one account I already knew (my own). If someone knows a good command for creating one directly in bash, I assume it would do.
  
It is recommended to add Letsencrypt support as detailed below.
+
There are bcrypt password generators online, and various libraries you can use
  
We need some extra settings to enable SSL with ProxyPass.
+
For listing out any passwords in the database I used:
  
First install proxy pass rpm:
+
  db.users.find().forEach( function(u) { print(u.services.password.bcrypt + " ; " + u.username); } )
yum --enablerepo=fws install mod_proxy_wstunnel
 
  
Regenerate httpd.conf
+
If you have deactivated users it may fail so use this for individual accounts.
signal-event remoteaccess-update
 
  
Now we need to setup our subdomain
+
However, you can get it for an individual user with:
  
  db domains set chat.mycompany.local domain Description RocketChat Nameservers internet \
+
  db.users.find({'username':'SomeUserName'}).forEach( function(u) { print(u.services.password.bcrypt + " ; " + u.username); } )
TemplatePath ProxyPassVirtualRocketchat ProxyPassTarget http://localhost:3000/
 
  
It should look like this:
+
Set a user config item:
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:
+
db.users.update( {'username': 'SomeUserName'}, {$set: {'settings.preferences.showMessageInMainThread': 'true'}} )
  
config setprop rocketchat rootURL chat.mycompany.domain SSLProxy yes
+
Find a single user:
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:
+
db.getCollection('users').find( {'username':'SomeUserName'} )
  
config setprop rocketchat access private
+
Get limited information:
signal-event remoteaccess-update
 
  
===Bugs===
+
db.getCollection('users').find({}, {"username":1, "settings.preferences.showMessageInMainThread":1})
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.
 
  
==Mongo DB examples==
+
Reset 2FA nonsense:
  
Example using mongo itself:
+
db.users.update({'username': 'SomeUserName'}, {$unset: {'services.totp': 1}});
 +
db.users.update({'username': 'SomeUserName'}, {$unset: {'services.email2fa': 1}});
  
mongo
+
===Database Backup===
  
use rocketchat
+
You can dump the tables to a directory of your choice:
  
  db.rocketchat_settings.find({"_id" : "SMTP_Host"})
+
  mongodump --dumpDbUsersAndRoles -d rocketchat -o /root/rocketchatmongo
db.rocketchat_settings.find({"_id" : "From_Email"})
 
  
db.rocketchat_settings.findOne({_id : "From_Email"}, {_id:0, value: 1})
+
===Database Restore===
db.rocketchat_settings.findOne({_id : "SMTP_Host"}, {_id:0, value: 1})
 
  
 +
You can restore you database as follows:
  
  db.rocketchat_settings.update({"_id" : "From_Email"}, {$set: {"value":"admin@yourdomain.com"}})
+
  mongorestore --restoreDbUsersAndRoles -d rocketchat -dir /root/rocketchatmongo/rocketchat --quiet
  db.rocketchat_settings.update({"_id" : "SMTP_Host"}, {$set: {"value":"mail.yourdomain.com"}})
 
  
 
==Node usage==
 
==Node usage==
Line 372: Line 421:
  
 
  npm install -g npm@3.10.9
 
  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
 +
 +
==Koozali SME v10==
 +
 +
I am starting to look at running this under docker on v10
 +
 +
Some quick notes.
 +
 +
You will need
 +
 +
Docker
 +
https://wiki.contribs.org/Docker
 +
 +
Docker Compose  (because it makes it easier to template)
 +
https://github.com/docker/compose/releases
 +
 +
Mongo (I prefer to run a full instance rather than a docker one)
 +
https://wiki.contribs.org/MongoDB
 +
 +
Make sure you add replicaset support in Mongo
 +
https://docs.rocket.chat/installation/manual-installation/centos
 +
 +
I'll add more later, and try and make a full contrib in due course
 +
 +
===CentOS 7 notes===
 +
 +
Setup storage engine and replication for MongoDB (mandatory for versions > 1), and enable and start MongoDB and Rocket.Chat:
 +
 +
They still recommend mmapv1 but it is probably better to stick with the default WiredTiger. Here's how to change if required:
 +
 +
sed -i "s/^#  engine:/  engine: mmapv1/"  /etc/mongod.conf
 +
 +
You MUST initialise a replicaset so we must add this to the conf file:
 +
 +
sed -i "s/^#replication:/replication:\n  replSetName: rs01/" /etc/mongod.conf
 +
 +
Start Mongo
 +
 +
systemctl enable mongod && sudo systemctl start mongod
 +
 +
Initiate the set:
 +
 +
mongo --eval "printjson(rs.initiate())"

Revision as of 13:08, 7 October 2020

Contrib: [1]John Crisp

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

However, due to dependencies a manual install will not work on SME


Version up to 0.61.2 will work with this contrib.

Later versions will need my newer smeserver-rocketchat-0.2.x contrib which uses docker.

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

3rd March 2018

Rocket RPM in my repo is 0.61.2

0.61.2 is likely to be the last version that can be installed direct to CentOS 6/ Koozali SME v9.x due to node module dependency requirements

I have tried to build 0.62.0 so far without success see this bug https://github.com/RocketChat/Rocket.Chat/issues/9943

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

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


I am currently looking at running Rocket 0.62 on docker in CentOS 6 which I do have working using the existing local Mongo DB

I will post a link to a new wiki page when I have it tested further and know what I am doing with Docker

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=nodejs8 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 for the reverse proxy

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

Some more mongo commands for reference

https://github.com/RocketChat/Rocket.Chat/issues/15880#issuecomment-570070433

Directly check a specific user ID from bash:

mongo rocketchat --eval "db.users.find({'username':'usernamehere'}).forEach( function(u) { print(u._id + \" ; \" + u.username); } )"

Log into rocketchat database:

mongo rocketchat

Check out all the user IDs in the database:

db.users.find().forEach( function(u) { print(u._id + ";" + u.username); } ) 

Or just a specific user's ID:

db.users.find({'username':'usernamehere'}).forEach( function(u) { print(u._id + \" ; \" + u.username); } )

Replace specific user ID's password in the database:

db.users.update( {'_id': 'useridhere'}, {$set: {'services.password.bcrypt': 'bcryptedpasswordhere'}}, {multi:true} )

My only issue with above (only time I needed it for recovery purposes), was that I didn't know which tool to use to generate a bcrypted password. So in the hurry I copied the hash from one account I already knew (my own). If someone knows a good command for creating one directly in bash, I assume it would do.

There are bcrypt password generators online, and various libraries you can use

For listing out any passwords in the database I used:

 db.users.find().forEach( function(u) { print(u.services.password.bcrypt + " ; " + u.username); } ) 

If you have deactivated users it may fail so use this for individual accounts.

However, you can get it for an individual user with:

db.users.find({'username':'SomeUserName'}).forEach( function(u) { print(u.services.password.bcrypt + " ; " + u.username); } ) 

Set a user config item:

db.users.update( {'username': 'SomeUserName'}, {$set: {'settings.preferences.showMessageInMainThread': 'true'}} )

Find a single user:

db.getCollection('users').find( {'username':'SomeUserName'} )

Get limited information:

db.getCollection('users').find({}, {"username":1, "settings.preferences.showMessageInMainThread":1})

Reset 2FA nonsense:

db.users.update({'username': 'SomeUserName'}, {$unset: {'services.totp': 1}});
db.users.update({'username': 'SomeUserName'}, {$unset: {'services.email2fa': 1}});

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

Koozali SME v10

I am starting to look at running this under docker on v10

Some quick notes.

You will need

Docker https://wiki.contribs.org/Docker

Docker Compose (because it makes it easier to template) https://github.com/docker/compose/releases

Mongo (I prefer to run a full instance rather than a docker one) https://wiki.contribs.org/MongoDB

Make sure you add replicaset support in Mongo https://docs.rocket.chat/installation/manual-installation/centos

I'll add more later, and try and make a full contrib in due course

CentOS 7 notes

Setup storage engine and replication for MongoDB (mandatory for versions > 1), and enable and start MongoDB and Rocket.Chat:

They still recommend mmapv1 but it is probably better to stick with the default WiredTiger. Here's how to change if required:

sed -i "s/^#  engine:/  engine: mmapv1/"  /etc/mongod.conf

You MUST initialise a replicaset so we must add this to the conf file:

sed -i "s/^#replication:/replication:\n  replSetName: rs01/" /etc/mongod.conf

Start Mongo

systemctl enable mongod && sudo systemctl start mongod

Initiate the set:

mongo --eval "printjson(rs.initiate())"