Skip to content
This repository has been archived by the owner on Jan 9, 2023. It is now read-only.

Commit

Permalink
Adding instructions for CouchDB
Browse files Browse the repository at this point in the history
1. Clarify both that you need to start CouchDB as well as how to verify
it.
2. Address the issues of setup created by the change in CouchDB 1.x vs.
2.x with a new script: initcouch2.sh
  • Loading branch information
tangollama committed Sep 23, 2016
1 parent c620552 commit 4d077f2
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,18 @@ To install the frontend please do the following:
5. Clone this repo with `git clone https://github.com/HospitalRun/hospitalrun-frontend`, go to the cloned folder and run `script/bootstrap`. (*Note: Depending on your [npm permissions](https://docs.npmjs.com/getting-started/fixing-npm-permissions) you might need root access to install PhantomJS2; also, Windows users must run with [Cygwin](http://cygwin.org/)*).
6. Install and configure [CouchDB](http://couchdb.apache.org/)
1. Download and install CouchDB from http://couchdb.apache.org/#download
2. Create admin user:
2. Start CouchDB
1. If you downloaded the installed app, navigate to CouchDB and double-click on the application.
2. If you installed CouchDB via Homebrew or some other command line tool, launch the tool from the command line
3. If you're stuck with the installation, check out the instructions published here: http://docs.couchdb.org/en/1.6.1/install/index.html
3. Verify that CouchDB is running by successfully navigating to 127.0.0.1:5984/_utils. If that fails, check the installation guide for CouchDB http://docs.couchdb.org/en/1.6.1/install/index.html
4. Create admin user:
If you are running CouchDB 1.x
1. If you have just installed CouchDB and have no admin user, please run `./script/initcouch.sh` in the folder you cloned the HospitalRun repo. A user `hradmin` will be created with password: `test`.
2. If you already have a CouchDB admin user, please run `./script/initcouch.sh USER PASS` in the folder you cloned the HospitalRun repo. `USER` and `PASS` are the CouchDB admin user credentials.
If you are running CouchDB 2.x
1. If you have just installed CouchDB and have no admin user, please run `./script/initcouch2.sh` in the folder you cloned the HospitalRun repo. A user `hradmin` will be created with password: `test`.
2. If you already have a CouchDB admin user, please run `./script/initcouch2.sh USER PASS` in the folder you cloned the HospitalRun repo. `USER` and `PASS` are the CouchDB admin user credentials.
7. Copy the `server/config-example.js` to `server/config.js` in the folder you cloned the HospitalRun repo. If you already had a CouchDB admin user that you passed into the couch script (`./script/initcouch.sh USER PASS`), then you will need to modify the `couchAdminUser` and `couchAdminPassword` values in `server/config.js` to reflect those credentials. (*Note: If on Mac, you need to make sure CouchDB can be run. See [How to open an app from a unidentified developer and exempt it from Gatekeeper](https://support.apple.com/en-us/HT202491).*)

### Experimental
Expand Down
23 changes: 23 additions & 0 deletions script/initcouch2.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash

URL="localhost"
PORT="5986"
PORT2="5986"

if [ -z "${1}" ] || [ -z "${2}" ]; then
HOST="http://$URL:$PORT"
curl -X PUT $HOST/_config/admins/couchadmin -d '"test"'
SECUREHOST="http://127.0.0.1:test@$URL:$PORT"
SECUREHOST2="http://127.0.0.1:test@$URL:$PORT2"
else
SECUREHOST="http://$1:$2@$URL:$PORT"
SECUREHOST2="http://$1:$2@$URL:$PORT2"
fi
curl -X PUT $SECUREHOST2/_users/_security -d '{ "admins": { "names": [], "roles": ["admin"]}, "members": { "names": [], "roles": []}}'
curl -X PUT $SECUREHOST/config
curl -X PUT $SECUREHOST/config/_security -d '{ "admins": { "names": [], "roles": ["admin"]}, "members": { "names": [], "roles": []}}'
curl -X PUT $SECUREHOST/main
curl -X PUT $SECUREHOST/main/_security -d '{ "admins": { "names": [], "roles": ["admin"]}, "members": { "names": [], "roles": ["user"]}}'
curl -X PUT $SECUREHOST2/_config/http/authentication_handlers -d '"{couch_httpd_oauth, oauth_authentication_handler}, {couch_httpd_auth, proxy_authentification_handler}, {couch_httpd_auth, cookie_authentication_handler}, {couch_httpd_auth, default_authentication_handler}"'
curl -X PUT $SECUREHOST2/_config/couch_httpd_oauth/use_users_db -d '"true"'
curl -X PUT $SECUREHOST2/_users/org.couchdb.user:hradmin -d '{"name": "hradmin", "password": "test", "roles": ["System Administrator","admin","user"], "type": "user", "userPrefix": "p1"}'

1 comment on commit 4d077f2

@chobberoni
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks so much for this updated to the readme. I was literally troubleshooting for hours the other night because I had CouchDB 2.0 and the instructions before didn't work well with that setup.

🙏

Please sign in to comment.