Changes

Jump to navigation Jump to search
1,556 bytes removed ,  16:49, 15 November 2023
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''' This is largely obsolete.]]}}
 +
 
 +
Later versions will need my newer smeserver-rocketchat-0.4.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
     −
==RocketChat 0.39.0==
+
===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}}
+
{{ #smeversion: smeserver-rocketchat }}
 +
 
 +
 
 +
==Required repos==
    
Add repos:
 
Add repos:
    
* [[epel]]
 
* [[epel]]
* [[Centos-sclo-rh]]
+
* [[mongoDB]]
 +
* [[Docker]]
 
* [[User:ReetP|reetp]]  
 
* [[User:ReetP|reetp]]  
   −
yum install rh-python34-python rh-mongodb26-mongodb rh-mongodb26-mongodb-server nodejs010 GraphicsMagick --enablerepo=centos-sclo-rh,epel
+
===Installation===
   −
scl enable nodejs010 bash
+
There is now a smeserver-rocketchat contrib to install Rocket.Chat with docker.
npm install -g inherits
  −
npm install -g n
  −
n 0.10.40
  −
exit
     −
{{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 ! }}
+
Install Mongo DB natively as per the wiki page https://wiki.koozali.org/MongoDB
   −
You should now be able to install the rocketchat bundle with:
+
Currently it is suggested to use Mongo 4.4
   −
yum --enablerepo=reetp install rocketchat
+
Mongo 5+ requires additional instructions in the CPU that older CPUs may not have. See teh wiki page for more.
   −
This may take a while on first install as it installs the npm modules for the first time.
+
Do not go further than initiating the replicaset. Users are not required.
   −
Now you should be able to install the rocketchat contrib:
+
Next install smeserver-docker following the wiki page https://wiki.koozali.org/Docker
   −
yum --enablerepo=reetp install smeserver-rocketchat
     −
db configuration setprop rocketchat status enabled
     −
signal-event post-upgrade;signal-event reboot
+
Settings
   −
DB settings
+
config set rocketchat service TCPPort 3000 mailPort 25 mailURL localhost access private status enabled SSLProxy yes Version 5.4.9 rootURL chat.domain.com
   −
rocketchat=service
  −
    TCPPort=3000
  −
    access=public
  −
    mailPort=25
  −
    mailURL=localhost
  −
    status=enabled
     −
  rh-mongodb26-mongod=service
+
  signal-event post-upgrade;signal-event reboot
    TCPPort=27017
  −
    access=private
  −
    mongoURL=localhost
  −
    status=enabled
     −
BEFORE we login for the first time we need to set up mail settings correctly:
     −
From bash:
+
System ➔ startup
 +
+----------------------------------------------------+
 +
|                  SERVER RUNNING                    |
 +
+----------------------------------------------------+
 +
|                                                    |
 +
|      Version: 0.xx.x                              |
 +
|  Process Port: 3000                                |
 +
|      Site URL: <nowiki>http://rocketchat.local.net:3000</nowiki>    |
 +
|        OpLog: Disabled                            |
 +
|                                                    |
 +
+----------------------------------------------------+
   −
mongo rocketchat --eval 'db.rocketchat_settings.update({"_id" : "SMTP_Host"}, {$set: {"value":"localhost"}});'
+
You should now be able to connect to your Rocket.Chat instance
mongo rocketchat --eval 'db.rocketchat_settings.update({"_id" : "From_Email"}, {$set: {"value":"admin@yourdomain.com"}});'
     −
We can check the individual values set like this:
+
http://rocketchat.local.net:3000
   −
mongo rocketchat --eval 'db.rocketchat_settings.find({"_id":"From_Email"}, {_id:0, value:1}).shellPrint();'
+
===Registering a new account===
mongo rocketchat --eval 'db.rocketchat_settings.find({"_id":"SMTP_Host"}, {_id:0, value: 1}).shellPrint();'
     −
All values per _id:
+
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" : "SMTP_Host"}).shellPrint();'
  −
mongo rocketchat --eval 'db.rocketchat_settings.find({"_id" : "From_Email"}).shellPrint();'
      +
You can set your SMTP host as localhost or mail.yourdomain.com
   −
Now restart rocketchat to reread the DB settings:
+
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<
   −
service rocketchat restart
     −
Login at http://yourdomain:3000
+
===Reverse proxy===
   −
It will first get you to create an admin user.
+
Now we need to setup our subdomain for the reverse proxy
   −
If you have an issue with no email sent/received then login using the email address and password you just set
+
db domains set chat.mycompany.local domain Description RocketChat Nameservers internet \
 +
TemplatePath ProxyPassVirtualRocketchat ProxyPassTarget http://localhost:3000/
   −
===Updates===
+
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)
   −
If there is an update to Rocket.Chat I will add to my repo. You should just be able to run:
+
We need to set Rocket.Chat to listen on localhost now:
   −
  yum --enablerepo=reetp install rocketchat
+
  config setprop rocketchat rootURL chat.mycompany.domain SSLProxy yes
 +
signal-event smeserver-rocketchat-update
   −
You can also update the smeserver-rocketchat contrib in the same way
+
Now start the docker container (always run compose from the docker directory)
   −
  yum --enablerepo=reetp install smeserver-rocketchat
+
  cd /home/e-smith/files/docker/configs
 +
docker-compose up -d rocketchat
 +
docker logs -f rocketchat
   −
===SSL===
+
db accounts setprop Primary SSL enabled
 +
signal-event ibay-modify Primary
   −
{{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 | 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}}
+
==Bugs==
   −
It is recommended to add Letsencrypt support as detailed below.
+
Please raise bugs under the SME-Contribs section in {{BugzillaFileBug|product=|component=|title=bugzilla}}and select the smeserver-rocketchat component or use
 +
{{BugzillaFileBug|product=SME%20Contribs|component=smeserver-rocketchat |title=this link}}.
   −
We need some extra settings to enable SSL with ProxyPass.
     −
First install proxy pass rpm:
+
{{#bugzilla:columns=id,product,version,status,summary |sort=id |order=desc |disablecache=1 |component=smeserver-rocketchat |noresultsmessage="No open bugs found."}}
   −
Add the FWS repo
     −
* [[Fws]]
+
==Mongo DB examples==
   −
yum --enablerepo=fws install mod_proxy_wstunnel
+
===Usage===
   −
Regenerate httpd.conf
+
Example using mongo itself:
   −
  signal-event remoteaccess-update
+
  mongo
   −
Now we need to setup our subdomain
+
use rocketchat
   −
db domains set chat.mycompany.local domain Description RocketChat Nameservers internet \
+
Show all collections in DB
  TemplatePath ProxyPassVirtualRocketchat ProxyPassTarget http://localhost:3000/
+
  show collections
   −
It should look like this:
+
Show all entries in a collection
 +
db.rocketchat_avatars.chunks.find()
   −
  chat.mycompany.local=domain
+
  db.rocketchat_settings.find({"_id" : "SMTP_Host"})
    Nameservers=internet
+
db.rocketchat_settings.find({"_id" : "From_Email"})
    ProxyPassTarget=http://127.0.0.1:3000/
  −
    TemplatePath=ProxyPassVirtualRocketchat
      +
db.getCollection("rocketchat_settings").find({"name":"Joe Blogs"})
   −
We need to set Rocket.Chat to listen on localhost now:
+
db.getCollection("rocketchat_settings").find({"_id":{$regex:"^LDAP"}})
   −
  config setprop rocketchat rootURL localhost
+
  db.rocketchat_settings.findOne({_id : "From_Email"}, {_id:0, value: 1})
  signal-event remoteaccess-update
+
  db.rocketchat_settings.findOne({_id : "SMTP_Host"}, {_id:0, value: 1})
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.rocketchat_settings.update({"_id":"From_Email"}, {$set: {"value":"admin@yourdomain.com"}})
 +
db.rocketchat_settings.update({"_id":"SMTP_Host"}, {$set: {"value":"mail.yourdomain.com"}})
   −
config setprop rocketchat access private
  −
signal-event remoteaccess-update
     −
===Letsencrypt support===
+
Remove all entries in a collection (CAREFUL!!!!!!)
 +
db.rocketchat_avatars.chunks.remove({})
   −
{{Note box | 26 Aug 2016 - This should now work for a subdomain}}
+
Help
 +
help
   −
You can add letsencrypt should you wish - please see https://wiki.contribs.org/Letsencrypt
+
Some more mongo commands for reference
   −
You will need to add the domain key as follows, and add your letsencrypt certificates as per the wiki page:
+
https://github.com/RocketChat/Rocket.Chat/issues/15880#issuecomment-570070433
   −
  db domains setprop chat.mycompany.local letsencryptSSLcert enabled
+
Directly check a specific user ID from bash:
 +
  mongo rocketchat --eval "db.users.find({'username':'usernamehere'}).forEach( function(u) { print(u._id + \" ; \" + u.username); } )"
   −
Note that smeserver-rocketchat adds redirect on port 80 for the letsencrypt directory .well-known/acme-challenge
+
Log into rocketchat database:
 +
mongo rocketchat
   −
You should be able to reach:
+
Check out all the user IDs in the database:  
 +
db.users.find().forEach( function(u) { print(u._id + ";" + u.username); } )
   −
  http://chat.mycompany.local/.well-known/acme-challenge/
+
Or just a specific user's ID:
 +
  db.users.find({'username':'usernamehere'}).forEach( function(u) { print(u._id + \" ; \" + u.username); } )
   −
This should redirect to:
+
Replace specific user ID's password in the database:
 +
db.users.update( {'_id': 'useridhere'}, {$set: {'services.password.bcrypt': 'bcryptedpasswordhere'}}, {multi:true} )
   −
https://chat.mycompany.local/.well-known/acme-challenge/
+
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.
   −
Anything else going to chat.mycompany.local should get to Rocket.Chat
+
There are bcrypt password generators online, and various libraries you can use
   −
===Errors===
+
For listing out any passwords in the database I used:
   −
You may get an error on install of the rocketchat rpm as follows:
+
  db.users.find().forEach( function(u) { print(u.services.password.bcrypt + " ; " + u.username); } )
   −
npm WARN deprecated minimatch@2.0.10: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
+
If you have deactivated users it may fail so use this for individual accounts.
   −
This is due to the installed version of npm/node from SCL. Rocket.Chat should till work
+
However, you can get it for an individual user with:
   −
==RocketChat 0.40+==
+
db.users.find({'username':'SomeUserName'}).forEach( function(u) { print(u.services.password.bcrypt + " ; " + u.username); } )
   −
From Rocketchat 0.40 onwards you require a higher version of node than the one in the EPEL repos.
+
Set a user config item:
   −
===Setup===
+
db.users.update( {'username': 'SomeUserName'}, {$set: {'settings.preferences.showMessageInMainThread': 'true'}} )
   −
Add the following repos:
+
Find a single user:
   −
  /sbin/e-smith/db yum_repositories set epel repository \
+
  db.getCollection('users').find( {'username':'SomeUserName'} )
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 \
+
Get limited information:
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 \
+
  db.getCollection('users').find({}, {"username":1, "settings.preferences.showMessageInMainThread":1})
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 \
+
Reset 2FA nonsense:
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
+
  db.users.update({'username': 'SomeUserName'}, {$unset: {'services.totp': 1}});
 +
db.users.update({'username': 'SomeUserName'}, {$unset: {'services.email2fa': 1}});
   −
yum --enablerepo=nodejs install nodejs nodejs-devel
+
===Database Backup===
   −
yum --enablerepo=centos-sclo-rh,epel install scl-utils rh-python34-python rh-mongodb26-mongodb rh-mongodb26-mongodb-server \
+
You can dump the tables to a directory of your choice:
GraphicsMagick
     −
You should be able to install the smeserver-rocketchat RPM now
+
mongodump --dumpDbUsersAndRoles -d rocketchat -o /root/rocketchatmongo
   −
yum --enablerepo=reetp install smeserver-rocketchat
+
===Database Restore===
   −
config set rocketchat service TCPPort 3000 mailPort 25 mailURL localhost access public status enabled
+
You can restore you database as follows:
config set rh-mongodb26-mongod service TCPPort 27017 mongoURL localhost access private status enabled
     −
  signal-event post-upgrade;signal-event reboot
+
  mongorestore --restoreDbUsersAndRoles -d rocketchat -dir  /root/rocketchatmongo/rocketchat --quiet
    +
===Database Fix tables===
   −
===RocketChat run checks===
+
To remove user data file links a variation on this link
 +
https://github.com/RocketChat/feature-requests/issues/718
   −
Check /var/log/rocketchat.log
+
mongo
 +
use rocketchat
 +
db.rocketchat_user_data_files.remove( { } )
 +
db.runCommand({ compact: 'rocketchat_user_data_files', force: true });
 +
quit;
   −
System ➔ startup
+
==Node usage==
+----------------------------------------------------+
  −
|                  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
+
* This should go to a new Node page for reference
   −
service rocketchat stop
+
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)
   −
Check your node versions:
+
Say you want Node.js v0.10.x to build Atom.
   −
  [root@test Rocket.Chat]# node -v
+
  npm install -g n  # Install n globally
v4.5.0
+
n 0.10.33          # Install and use v0.10.33 local only
[root@test Rocket.Chat]# npm -v
  −
3.10.8
     −
Modify with
+
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
   −
n 0.4.6
     −
Try running main.js
+
==NPM Usage==
/opt/Rocket.Chat
  −
node main.js
     −
===Manual config of templates===
+
To update your version of npm run the following
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
+
  npm install -g npm
/etc/rc.d/init.d/rh-mongodb26-mongos start
      +
Or for a specific version:
    +
npm install -g npm@3.10.9
   −
===Proxy Pass===
+
==DB settings==
   −
The contrib will sort out the templates. You just need some settings as follows:
+
Typical standard setup:
 +
rocketchat=service
 +
    TCPPort=3000
 +
    access=public
 +
    mailPort=25
 +
    mailURL=localhost
 +
    status=enabled
   −
[root@test e-smith]# db domains show
+
Typical proxy subdomain setup:
  chat.reetspetit.info=domain
+
  rocketchat=service
     Description=RocketChat
+
     SSLProxy=yes
     Nameservers=internet
+
     TCPPort=3000
     ProxyPassTarget=http://127.0.0.1:3000/
+
     access=private
     TemplatePath=ProxyPassVirtualRocketchat
+
     mailPort=25
     letsencryptSSLcert=enabled
+
     mailURL=localhost
 
+
    rootURL=chat.mydomain.co.uk
 
+
    status=enabled
===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 }}
  −
 
  −
 
  −
It is recommended to add Letsencrypt support as detailed below.
     −
We need some extra settings to enable SSL with ProxyPass.
     −
First install proxy pass rpm:
  −
yum --enablerepo=fws install mod_proxy_wstunnel
     −
Regenerate httpd.conf
+
==Koozali SME v10==
signal-event remoteaccess-update
     −
Now we need to setup our subdomain
+
I am starting to look at running this under docker on v10
 
  −
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
+
Some quick notes.
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:
+
You will need
   −
config setprop rocketchat access private
+
Docker
signal-event remoteaccess-update
+
https://wiki.contribs.org/Docker
   −
===Bugs===
+
Docker Compose  (because it makes it easier to template)
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.
+
https://github.com/docker/compose/releases
   −
==Mongo DB examples==
+
Docker environment settings to disable 2FA
   −
Example using mongo itself:
+
  - OVERWRITE_SETTING_Accounts_TwoFactorAuthentication_Enforce_Password_Fallback=false
 +
  - OVERWRITE_SETTING_Accounts_TwoFactorAuthentication_Enabled=false
   −
mongo
+
Mongo (I prefer to run a full instance rather than a docker one)
 +
https://wiki.contribs.org/MongoDB
   −
use rocketchat
+
Make sure you add replicaset support in Mongo and set it up:
   −
  db.rocketchat_settings.find({"_id" : "SMTP_Host"})
+
  mongo --eval "printjson(rs.initiate())"
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})
      +
I'll add more later, and try and make a full contrib in due course
   −
db.rocketchat_settings.update({"_id" : "From_Email"}, {$set: {"value":"admin@yourdomain.com"}})
+
FAQ
db.rocketchat_settings.update({"_id" : "SMTP_Host"}, {$set: {"value":"mail.yourdomain.com"}})
     −
==Node usage==
+
https://handbook.rocket.chat/company/tools/rocket.chat
   −
Use n, an extremely simple Node version manager that can be installed via npm.
+
==Bugs==
   −
Say you want Node.js v0.10.x to build Atom.
+
Please raise bugs under the SME-Contribs section in {{BugzillaFileBug|product=|component=|title=bugzilla}}and select the smeserver-rocketchat component or use
 +
{{BugzillaFileBug|product=SME%20Contribs|component=smeserver-rocketchat |title=this link}}.
   −
npm install -g n  # Install n globally
  −
n 0.10.33          # Install and use v0.10.33
     −
Usage:
+
{{#bugzilla:columns=id,product,version,status,summary |sort=id |order=desc |disablecache=1 |component=smeserver-rocketchat |noresultsmessage="No open bugs found."}}
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
 

Navigation menu