Skip to content

Instantly share code, notes, and snippets.

@JC1738
Forked from kparlante/couchdb-ec2-install.sh
Created November 26, 2013 04:21
Show Gist options
  • Save JC1738/7653416 to your computer and use it in GitHub Desktop.
Save JC1738/7653416 to your computer and use it in GitHub Desktop.
#!/bin/bash
#
# This script installs and configures couchdb on a fresh Amazon Linux AMI instance.
#
# Must be run with root privileges
# Tested with Amazon Linux AMI release 2011.02.1.1 (ami-8c1fece5)
#
export BUILD_DIR="$PWD"
# install gem dependencies
yum install -y gcc gcc-c++ libtool curl-devel ruby-rdoc zlib-devel openssl-devel make automake rubygems perl git-core
gem install rake --no-ri --no-rdoc
if [ ! -e "/usr/local/bin/couchdb" ]
then
if [ ! -d "$BUILD_DIR/build-couchdb" ]
then
# get build-couch code
git clone git://github.com/iriscouch/build-couchdb
cd $BUILD_DIR/build-couchdb/
git submodule init
git submodule update
fi
# run build-couch
cd $BUILD_DIR/build-couchdb/
rake git="git://git.apache.org/couchdb.git tags/1.2.0" install=/usr/local
fi
# install our .ini
cat << 'EOF' > /usr/local/etc/couchdb/local.ini
[couchdb]
delayed_commits = false
[httpd]
bind_address = 0.0.0.0
[couch_httpd_auth]
require_valid_user = false
[log]
level = debug
[admins]
EOF
# generate & set the initial password
export ADMIN_PASSWORD=`mkpasswd`
echo "admin = ${ADMIN_PASSWORD}" >> /usr/local/etc/couchdb/local.ini
# allow beam to bind to port 80 (not necessary if you make httpd.port >=1024)
setcap 'cap_net_bind_service=+ep' /usr/local/lib/erlang/erts-5.9.2/bin/beam
if [ ! -e "/etc/logrotate.d/couchdb" ]
then
# add couch.log to logrotate
ln -s /usr/local/etc/logrotate.d/couchdb /etc/logrotate.d/
# change to daily rotation
sed -e s/weekly/daily/g -i /usr/local/etc/logrotate.d/couchdb
#logrotate -v -f /etc/logrotate.d/couchdb
fi
# add couchdb user
adduser --system --home /usr/local/var/lib/couchdb -M --shell /bin/bash --comment "CouchDB" couchdb
# change file ownership
chown -R couchdb:couchdb /usr/local/etc/couchdb /usr/local/var/lib/couchdb /usr/local/var/log/couchdb /usr/local/var/run/couchdb
# run couchdb on startup
ln -s /usr/local/etc/rc.d/couchdb /etc/init.d/couchdb
chkconfig --add couchdb
chkconfig --level 345 couchdb on
# done!
echo
echo
echo "Installation complete!"
echo "Couchdb admin password was set to: ${ADMIN_PASSWORD}"
echo
echo "Couchdb is ready to start. Run:"
echo " sudo service couchdb start"
@JC1738
Copy link
Author

JC1738 commented Nov 26, 2013

need to add texinfo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment