You should never try to manage multiple instances from the same init script, as this creates a whole redundant administrative work when you start / end any of the instances.
You should look for one init script for each individual instance of the database process, as this is the best Linux practice.
For the most part, you should be able to use the generic MongoDB provided by the init script, and then make a renamed copy for each database instance.
Then you must create separate configuration files for each instance, which should contain slightly different configurations and run each instance on its own port, its own dbpath and its own log file.
You can then specify each init script in the configuration file for your instance, and everything should work as planned.
Finally, in MongoDB you should use the --fork option, which provides a safe way to separate MongoDB from the shell instance. If you need to continue using shell fork (the and operator), then you should migrate MongoDB to "nohup" to avoid closing the instance by terminating your shell. It will look something like this: nohup <mongodb cmd and arguments> &
Edit: You can use the same process to use the same initialization scripts to start MongoS. You need to find the line that sets the mongod binary as the one to be executed. Under all debian derivatives, this will be the DAEMON variable. Change this to point to mongos instead of mongod and exit.
daveh source share