Changes

From SME Server
Jump to navigationJump to search
541 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 manually installing Rocket.Chat [[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
  −
  −
==Current version==
     −
4th July 2017
+
===Version===
 +
{{ #smeversion: smeserver-rocketchat }}
   −
Current RPM in my repo is 0.57.0
  −
  −
https://reetspetit.com/smeserver/6/repoview/rocketchat.html
  −
  −
  −
Latest source is here:
  −
  −
https://github.com/RocketChat/Rocket.Chat/tags
      
==Required repos==
 
==Required repos==
Line 23: Line 16:     
* [[epel]]
 
* [[epel]]
* [[Centos-sclo-rh]]
+
* [[mongoDB]]
 +
* [[Docker]]
 
* [[User:ReetP|reetp]]  
 
* [[User:ReetP|reetp]]  
* [[Fws]]
     −
/sbin/e-smith/db yum_repositories set epel repository \
+
===Installation===
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 \
+
There is now a smeserver-rocketchat contrib to install Rocket.Chat with docker.
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 \
+
Install Mongo DB natively as per the wiki page https://wiki.koozali.org/MongoDB
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 \
+
Currently it is suggested to use Mongo 4.4
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
+
Mongo 5+ requires additional instructions in the CPU that older CPUs may not have. See teh wiki page for more.
   −
yum --enablerepo=nodejs install nodejs nodejs-devel
+
Do not go further than initiating the replicaset. Users are not required.
    +
Next install smeserver-docker following the wiki page https://wiki.koozali.org/Docker
   −
==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 49.0+ requires:
+
Settings
node: v4.7.2
  −
npm: v3.10.9
     −
This can be installed from the node repo
+
config set rocketchat service TCPPort 3000 mailPort 25 mailURL localhost access private status enabled SSLProxy yes Version 5.4.9 rootURL chat.domain.com
   −
===Setup node versions:===
  −
  −
Install node version
  −
n 4.7.2
  −
  −
[root@test ~]# node -v
  −
v4.7.2
  −
  −
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 ~]# 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
 
  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
 
  System ➔ startup
Line 136: Line 69:  
  use rocketchat
 
  use rocketchat
 
  db.rocketchat_settings.update({"_id" : "SMTP_Host"}, {$set: {"value":"mail.yourdomain.com"}})
 
  db.rocketchat_settings.update({"_id" : "SMTP_Host"}, {$set: {"value":"mail.yourdomain.com"}})
  db.rocketchat_settings.update({"_id" : "From_Email"}, {$set: {"value":"admin@yourdomain.com"}})
+
  db.rocketchat_settings.update({"_id": "From_Email"}, {$set: {"value":"admin@yourdomain.com"}})
exit
+
      exit<
   −
Restart Rocket.Chat to be sure:
     −
service rocketchat restart
+
===Reverse proxy===
   −
You should now be able to register a new account and get a confirmation email. Check /var/log/qpsmtpd/current for any errors.
+
Now we need to setup our subdomain for the reverse proxy
   −
If you have not set the From address you are likely to get:
+
db domains set chat.mycompany.local domain Description RocketChat Nameservers internet \
 +
TemplatePath ProxyPassVirtualRocketchat ProxyPassTarget http://localhost:3000/
   −
  Mail with no From header not accepted here
+
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)
   −
===Errors===
+
We need to set Rocket.Chat to listen on localhost now:
   −
If you have issues make sure you stop the rocket chat service
+
config setprop rocketchat rootURL chat.mycompany.domain SSLProxy yes
 +
signal-event smeserver-rocketchat-update
   −
service rocketchat stop
+
Now start the docker container (always run compose from the docker directory)
   −
Check /var/log/rocketchat.log
+
cd /home/e-smith/files/docker/configs
 +
docker-compose up -d rocketchat
 +
docker logs -f rocketchat
   −
Try running main.js
+
  db accounts setprop Primary SSL enabled
  /opt/Rocket.Chat
+
  signal-event ibay-modify Primary
  node main.js
     −
===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 (see here for my contrib https://wiki.contribs.org/Letsencrypt)
+
==Bugs==
   −
We need some extra settings to enable SSL with ProxyPass.
+
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}}.
   −
Add the FWS repo:
     −
db yum_repositories set fws repository \
+
{{#bugzilla:columns=id,product,version,status,summary |sort=id |order=desc |disablecache=1 |component=smeserver-rocketchat |noresultsmessage="No open bugs found."}}
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:
+
==Mongo DB examples==
yum --enablerepo=fws install mod_proxy_wstunnel
     −
Regenerate httpd.conf
+
===Usage===
signal-event remoteaccess-update
     −
Now we need to setup our subdomain
+
Example using mongo itself:
   −
  db domains set chat.mycompany.local domain Description RocketChat Nameservers internet \
+
  mongo
TemplatePath ProxyPassVirtualRocketchat ProxyPassTarget http://localhost:3000/
     −
It should look like this:
+
  use rocketchat
  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:
+
Show all collections in DB
 +
show collections
   −
  config setprop rocketchat rootURL chat.mycompany.domain SSLProxy yes
+
Show all entries in a collection
signal-event remoteaccess-update
+
  db.rocketchat_avatars.chunks.find()
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.find({"_id" : "SMTP_Host"})
 +
db.rocketchat_settings.find({"_id" : "From_Email"})
   −
  config setprop rocketchat access private
+
  db.getCollection("rocketchat_settings").find({"name":"Joe Blogs"})
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
+
db.getCollection("rocketchat_settings").find({"_id":{$regex:"^LDAP"}})
   −
IF you have Letsencrypt support you can now set your main domain to SSL only:
+
db.rocketchat_settings.findOne({_id : "From_Email"}, {_id:0, value: 1})
 +
db.rocketchat_settings.findOne({_id : "SMTP_Host"}, {_id:0, value: 1})
   −
  db accounts setprop Primary SSL enabled
+
  db.rocketchat_settings.update({"_id":"From_Email"}, {$set: {"value":"admin@yourdomain.com"}})
  signal-event ibay-modify Primary
+
  db.rocketchat_settings.update({"_id":"SMTP_Host"}, {$set: {"value":"mail.yourdomain.com"}})
   −
===Upgrades===
     −
To upgrade rocketchat:
+
Remove all entries in a collection (CAREFUL!!!!!!)
 +
db.rocketchat_avatars.chunks.remove({})
   −
  yum --enablerepo=reetp install rocketchat
+
Help
 +
  help
   −
To upgrade the rocketchat configurator:
+
Some more mongo commands for reference
   −
yum --enablerepo=reetp install smeserver-rocketchat
+
https://github.com/RocketChat/Rocket.Chat/issues/15880#issuecomment-570070433
   −
===Bugs===
+
Directly check a specific user ID from bash:
 +
mongo rocketchat --eval "db.users.find({'username':'usernamehere'}).forEach( function(u) { print(u._id + \" ; \" + u.username); } )"
   −
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.
+
Log into rocketchat database:
 +
mongo rocketchat
   −
==Manual config of templates==
+
Check out all the user IDs in the database:
  expand-template /etc/rc.d/init.d/rocketchat
+
  db.users.find().forEach( function(u) { print(u._id + ";" + u.username); } )
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
+
Or just a specific user's ID:
/etc/rc.d/init.d/rh-mongodb26-mongos start
+
  db.users.find({'username':'usernamehere'}).forEach( function(u) { print(u._id + \" ; \" + u.username); } )
   −
==Mongod fails to start after reboot==
+
Replace specific user ID's password in the database:
 +
db.users.update( {'_id': 'useridhere'}, {$set: {'services.password.bcrypt': 'bcryptedpasswordhere'}}, {multi:true} )
   −
Sometimes it appears that mongo fails to start after a reboot.
+
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.
   −
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.
+
There are bcrypt password generators online, and various libraries you can use
   −
A simple cure is as follows:
+
For listing out any passwords in the database I used:
   −
/etc/rc.d/init.d/rh-mongodb26-mongod stop
+
  db.users.find().forEach( function(u) { print(u.services.password.bcrypt + " ; " + u.username); } )
   −
Remove the following files if they exist:
+
If you have deactivated users it may fail so use this for individual accounts.
   −
rm /var/opt/rh/rh-mongodb26/lib/mongodb/mongod.lock
+
However, you can get it for an individual user with:
rm /var/opt/rh/rh-mongodb26/run/mongodb/mongod.pid
     −
Restart the mongod service:
+
db.users.find({'username':'SomeUserName'}).forEach( function(u) { print(u.services.password.bcrypt + " ; " + u.username); } )
   −
/etc/rc.d/init.d/rh-mongodb26-mongod start
+
Set a user config item:
   −
Restart the rocketchat service:
+
db.users.update( {'username': 'SomeUserName'}, {$set: {'settings.preferences.showMessageInMainThread': 'true'}} )
   −
service rocketchat restart
+
Find a single user:
   −
The following is simpler and appears to work:
+
db.getCollection('users').find( {'username':'SomeUserName'} )
   −
service rocketchat stop
+
Get limited information:
/etc/rc.d/init.d/rh-mongodb26-mongod restart
  −
service rocketchat start
     −
==Mongo DB examples==
+
db.getCollection('users').find({}, {"username":1, "settings.preferences.showMessageInMainThread":1})
   −
===Usage===
+
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
  −
 
  −
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"}})
      
===Database Backup===
 
===Database Backup===
Line 300: Line 208:     
  mongorestore --restoreDbUsersAndRoles -d rocketchat -dir  /root/rocketchatmongo/rocketchat --quiet
 
  mongorestore --restoreDbUsersAndRoles -d rocketchat -dir  /root/rocketchatmongo/rocketchat --quiet
 +
 +
===Database Fix tables===
 +
 +
To remove user data file links a variation on this link
 +
https://github.com/RocketChat/feature-requests/issues/718
 +
 +
mongo
 +
use rocketchat
 +
db.rocketchat_user_data_files.remove( { } )
 +
db.runCommand({ compact: 'rocketchat_user_data_files', force: true });
 +
quit;
    
==Node usage==
 
==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)
 
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)
Line 353: Line 274:  
     status=enabled
 
     status=enabled
   −
  rh-mongodb26-mongod=service
+
 
    TCPPort=27017
+
 
    access=private
+
==Koozali SME v10==
    mongoURL=localhost
+
 
    status=enabled
+
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
 +
 
 +
==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."}}

Navigation menu