#!/bin/bash # Start MongoDB as mongodb user mongod --replSet rs0 --bind_ip_all --dbpath /data/db & # Wait for MongoDB to start sleep 10 # Initialize replica set mongosh --eval "rs.initiate({_id: 'rs0', members: [{_id: 0, host: 'localhost:27017'}]})" # Switch to rocketchat user and start the application su - rocketchat -c "cd /app/bundle && node main.js"