Changes

From SME Server
Jump to navigationJump to search
5,280 bytes added ,  15: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 Rcoket.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
+
 
 +
===Version===
 +
{{ #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===
 +
 
 +
There is now a smeserver-rocketchat contrib to install Rocket.Chat with docker.
 +
 
 +
Install Mongo DB natively as per the wiki page https://wiki.koozali.org/MongoDB
 +
 
 +
Currently it is suggested to use Mongo 4.4
 +
 
 +
Mongo 5+ requires additional instructions in the CPU that older CPUs may not have. See teh wiki page for more.
   −
scl enable nodejs010 bash
+
Do not go further than initiating the replicaset. Users are not required.
npm install -g inherits
  −
npm install -g n
  −
n 0.10.40
  −
exit
     −
You should now be able to install the rocketchat bundle with:
+
Next install smeserver-docker following the wiki page https://wiki.koozali.org/Docker
   −
yum --enablerepo=reetp install rocketchat
     −
This may take a while on first install as it installs the npm modules for the first time.
     −
Now you should be able to install the rocketchat contrib:
+
Settings
   −
  yum enablerepo=reetp install smeserver-rocketchat
+
  config set rocketchat service TCPPort 3000 mailPort 25 mailURL localhost access private status enabled SSLProxy yes Version 5.4.9 rootURL chat.domain.com
   −
db setprop rocketchat status enabled
      
  signal-event post-upgrade;signal-event reboot
 
  signal-event post-upgrade;signal-event reboot
   −
DB settings
     −
  rocketchat=service
+
  System ➔ startup
    TCPPort=3000
+
+----------------------------------------------------+
    access=public
+
|                  SERVER RUNNING                    |
    mailPort=25
+
+----------------------------------------------------+
    mailURL=localhost
+
|                                                    |
    status=enabled
+
|      Version: 0.xx.x                              |
 +
|  Process Port: 3000                                |
 +
|      Site URL: <nowiki>http://rocketchat.local.net:3000</nowiki>    |
 +
|        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<
 +
 
 +
 
 +
===Reverse proxy===
 +
 
 +
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 smeserver-rocketchat-update
 +
 
 +
Now start the docker container (always run compose from the docker directory)
 +
 
 +
cd /home/e-smith/files/docker/configs
 +
docker-compose up -d rocketchat
 +
docker logs -f rocketchat
 +
 
 +
db accounts setprop Primary SSL enabled
 +
signal-event ibay-modify Primary
 +
 
 +
 
 +
==Bugs==
 +
 
 +
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}}.
 +
 
 +
 
 +
{{#bugzilla:columns=id,product,version,status,summary |sort=id |order=desc |disablecache=1 |component=smeserver-rocketchat |noresultsmessage="No open bugs found."}}
   −
rh-mongodb26-mongod=service
  −
    TCPPort=27017
  −
    access=private
  −
    mongoURL=localhost
  −
    status=enabled
     −
BEFORE we login for the first time we need to set up mail settings correctly:
+
==Mongo DB examples==
   −
From bash:
+
===Usage===
   −
mongo rocketchat --eval 'db.rocketchat_settings.update({"_id" : "SMTP_Host"}, {$set: {"value":"localhost"}});'
+
Example using mongo itself:
mongo rocketchat --eval 'db.rocketchat_settings.update({"_id" : "From_Email"}, {$set: {"value":"admin@yourdomain.com"}});'
     −
We can check the individual values set like this:
+
mongo
   −
  mongo rocketchat --eval 'db.rocketchat_settings.find({"_id":"From_Email"}, {_id:0, value:1}).shellPrint();'
+
  use rocketchat
mongo rocketchat --eval 'db.rocketchat_settings.find({"_id":"SMTP_Host"}, {_id:0, value: 1}).shellPrint();'
     −
All values per _id:
+
Show all collections in DB
  mongo rocketchat --eval 'db.rocketchat_settings.find({"_id" : "SMTP_Host"}).shellPrint();'
+
  show collections
mongo rocketchat --eval 'db.rocketchat_settings.find({"_id" : "From_Email"}).shellPrint();'
      +
Show all entries in a collection
 +
db.rocketchat_avatars.chunks.find()
   −
Now restart rocketchat to reread the DB settings:
+
db.rocketchat_settings.find({"_id" : "SMTP_Host"})
 +
db.rocketchat_settings.find({"_id" : "From_Email"})
   −
  service rocketchat restart
+
  db.getCollection("rocketchat_settings").find({"name":"Joe Blogs"})
   −
Login at http://yourdomain:3000
+
db.getCollection("rocketchat_settings").find({"_id":{$regex:"^LDAP"}})
   −
It will first get you to create an admin user.  
+
db.rocketchat_settings.findOne({_id : "From_Email"}, {_id:0, value: 1})
 +
db.rocketchat_settings.findOne({_id : "SMTP_Host"}, {_id:0, value: 1})
   −
If you have an issue with no email sent/received then login using the email address and password you just set
+
db.rocketchat_settings.update({"_id":"From_Email"}, {$set: {"value":"admin@yourdomain.com"}})
 +
db.rocketchat_settings.update({"_id":"SMTP_Host"}, {$set: {"value":"mail.yourdomain.com"}})
   −
===Updates===
     −
If there is an update to rocket chat you should just be able to run:
+
Remove all entries in a collection (CAREFUL!!!!!!)
 +
db.rocketchat_avatars.chunks.remove({})
   −
  yum --enablerepo=reetp install rocketchat
+
Help
 +
  help
    +
Some more mongo commands for reference
   −
===Bugs===
+
https://github.com/RocketChat/Rocket.Chat/issues/15880#issuecomment-570070433
   −
Look for bugs :-) As the contrib is not in CVS please report them in the forum
+
Directly check a specific user ID from bash:
 +
mongo rocketchat --eval "db.users.find({'username':'usernamehere'}).forEach( function(u) { print(u._id + \" ; \" + u.username); } )"
   −
You ay get an error on install of the rocketchat rpm as follows:
+
Log into rocketchat database:
 +
mongo rocketchat
   −
  npm WARN deprecated minimatch@2.0.10: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
+
Check out all the user IDs in the database:
 +
  db.users.find().forEach( function(u) { print(u._id + ";" + u.username); } )
   −
This is due to the installed version of npm/node from SCL. Rocket.Chat should till work
+
Or just a specific user's ID:
 +
db.users.find({'username':'usernamehere'}).forEach( function(u) { print(u._id + \" ; \" + u.username); } )
   −
===SSL===
+
Replace specific user ID's password in the database:
 +
db.users.update( {'_id': 'useridhere'}, {$set: {'services.password.bcrypt': 'bcryptedpasswordhere'}}, {multi:true} )
   −
This works for me. You will need a minimum version of smeserver-rocketchat-0.1-4
+
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
+
If you have deactivated users it may fail so use this for individual accounts.
   −
Regenerate httpd.conf
+
However, you can get it for an individual user with:
   −
  signal-event remoteaccess-update
+
  db.users.find({'username':'SomeUserName'}).forEach( function(u) { print(u.services.password.bcrypt + " ; " + u.username); } )
   −
Now we need to setup our subdomain
+
Set a user config item:
   −
  db domains set chat.mycompany.local domain Description RocketChat Nameservers internet \
+
  db.users.update( {'username': 'SomeUserName'}, {$set: {'settings.preferences.showMessageInMainThread': 'true'}} )
TemplatePath ProxyPassVirtualRocketchat ProxyPassTarget http://localhost:3000/
     −
It should look like this:
+
Find a single user:
   −
  chat.mycompany.local=domain
+
  db.getCollection('users').find( {'username':'SomeUserName'} )
    Nameservers=internet
  −
    ProxyPassTarget=http://127.0.0.1:3000/
  −
    TemplatePath=ProxyPassVirtualRocketchat
      +
Get limited information:
   −
We need to set Rocket.Chat to listen on localhost now:
+
db.getCollection('users').find({}, {"username":1, "settings.preferences.showMessageInMainThread":1})
   −
config setprop rocketchat rootURL localhost
+
Reset 2FA nonsense:
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.users.update({'username': 'SomeUserName'}, {$unset: {'services.totp': 1}});
 +
db.users.update({'username': 'SomeUserName'}, {$unset: {'services.email2fa': 1}});
   −
config setprop rocketchat access private
+
===Database Backup===
signal-event remoteaccess-update
     −
===Letsencrypt support===
+
You can dump the tables to a directory of your choice:
   −
You can add letsencrypt should you wish - please see https://wiki.contribs.org/Letsencrypt
+
mongodump --dumpDbUsersAndRoles -d rocketchat -o /root/rocketchatmongo
   −
You will need to add the domain key as follows, and add your letsencrypt certificates as per the wiki page:
+
===Database Restore===
   −
db domains setprop chat.mycompany.local letsencryptSSLcert enabled
+
You can restore you database as follows:
   −
Note that smeserver-rocketchat adds a ProxyPass directive for the letsencrypt directory .well-known/acme-challenge
+
mongorestore --restoreDbUsersAndRoles -d rocketchat -dir  /root/rocketchatmongo/rocketchat --quiet
   −
===Mongo DB examples===
+
===Database Fix tables===
   −
Example using mongo itself:
+
To remove user data file links a variation on this link
 +
https://github.com/RocketChat/feature-requests/issues/718
    
  mongo
 
  mongo
 +
use rocketchat
 +
db.rocketchat_user_data_files.remove( { } )
 +
db.runCommand({ compact: 'rocketchat_user_data_files', force: true });
 +
quit;
 +
 +
==Node usage==
 +
 +
* This should go to a new Node page for reference
 +
 +
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
   −
  use rocketchat
+
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
 +
 
 +
 
 +
 
 +
==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
 +
 
 +
Docker environment settings to disable 2FA
 +
 
 +
  - OVERWRITE_SETTING_Accounts_TwoFactorAuthentication_Enforce_Password_Fallback=false
 +
  - OVERWRITE_SETTING_Accounts_TwoFactorAuthentication_Enabled=false
 +
 
 +
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 and set it up:
 +
 
 +
mongo --eval "printjson(rs.initiate())"
 +
 
 +
 
 +
I'll add more later, and try and make a full contrib in due course
 +
 
 +
FAQ
 +
 
 +
https://handbook.rocket.chat/company/tools/rocket.chat
   −
db.rocketchat_settings.find({"_id" : "SMTP_Host"})
+
==Bugs==
db.rocketchat_settings.find({"_id" : "From_Email"})
     −
db.rocketchat_settings.findOne({_id : "From_Email"}, {_id:0, value: 1})
+
Please raise bugs under the SME-Contribs section in {{BugzillaFileBug|product=|component=|title=bugzilla}}and select the smeserver-rocketchat component or use
  db.rocketchat_settings.findOne({_id : "SMTP_Host"}, {_id:0, value: 1})
+
  {{BugzillaFileBug|product=SME%20Contribs|component=smeserver-rocketchat |title=this link}}.
      −
db.rocketchat_settings.update({"_id" : "From_Email"}, {$set: {"value":"admin@reetspetit.info"}})
+
{{#bugzilla:columns=id,product,version,status,summary |sort=id |order=desc |disablecache=1 |component=smeserver-rocketchat |noresultsmessage="No open bugs found."}}
db.rocketchat_settings.update({"_id" : "SMTP_Host"}, {$set: {"value":"mail.reetspetit.info"}})
 

Navigation menu