Skip to content

Instantly share code, notes, and snippets.

@pdelteil
Last active September 5, 2023 22:51
Show Gist options
  • Save pdelteil/ba005609789ae14862f023da4191826d to your computer and use it in GitHub Desktop.
Save pdelteil/ba005609789ae14862f023da4191826d to your computer and use it in GitHub Desktop.
Config script for bbrf
ADDRESS='127.0.0.1'
PORT=6984
COUCHDB="https://$ADDRESS:$PORT"
#username of the admin (created previously)
ADMIN_NAME='admin'
#admin password
ADMIN_PASS='admin'
#the password to assign to user bbrf
USER_PASS='admin123'
#Creates the database _users
curl -k -X PUT $COUCHDB"/_users" -u $ADMIN_NAME":"$ADMIN_PASS
#Creates user bbrf
curl -k -X PUT $COUCHDB"/_users/org.couchdb.user:bbrf" -u $ADMIN_NAME":"$ADMIN_PASS \
-H "Accept: application/json" -H "Content-Type: application/json" \
-d "{\"name\": \"bbrf\", \"password\":\"$USER_PASS\", \"roles\": [], \"type\": \"user\"}"
#Creates database bbrf
curl -k -X PUT $COUCHDB"/bbrf" -u $ADMIN_NAME":"$ADMIN_PASS
# security
curl -k -X PUT $COUCHDB"/bbrf/_security" -u $ADMIN_NAME":"$ADMIN_PASS -d "{\"admins\": {\"names\": [\"bbrf\"],\"roles\": []}}"
#Download the views
wget -q https://raw.githubusercontent.com/honoki/bbrf-server/main/couchdb/views.json
#Load the views to the database BBRF
curl -k -X PUT $COUCHDB"/bbrf/_design/bbrf" -u $ADMIN_NAME":"$ADMIN_PASS -H "Content-Type: application/json" -d @views.json
#CORS Configs
curl -k -X PUT $COUCHDB"/_node/_local/_config/cors/origins" -u $ADMIN_NAME":"$ADMIN_PASS -d '"https://bbrf.me"'
curl -k -X PUT $COUCHDB"/_node/_local/_config/httpd/enable_cors" -u $ADMIN_NAME":"$ADMIN_PASS -d '"true"'
curl -k -X PUT $COUCHDB"/_node/_local/_config/cors/credentials" -u $ADMIN_NAME":"$ADMIN_PASS -d '"true"'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment