Created
February 17, 2012 17:46
-
-
Save wraithmonster/1854569 to your computer and use it in GitHub Desktop.
Installs the latest CouchDB version on Ubuntu from source, not from a repository
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Title: install-couchdb.sh | |
# Description: Installs the latest CouchDB version from source, | |
# not from a repository. | |
# Author: wraithmonster | |
# Reference: https://github.com/iriscouch/build-couchdb | |
# http://comments.gmane.org/gmane.comp.db.couchdb.user/16292 | |
# Uninstalling from Ubuntu's repository: | |
# http://serverfault.com/questions/348044 | |
# http://stackoverflow.com/questions/8783621 | |
# Dependencies: git | |
# | |
################################################################################ | |
# Packages | |
################################################################################ | |
PKGS_COUCH="make gcc zlib1g-dev libssl-dev rake" | |
################################################################################ | |
# Default locations | |
################################################################################ | |
DST_DIR=$HOME/dev/tools | |
################################################################################ | |
# Helper functions | |
################################################################################ | |
# Prints the given error message and exits. | |
function errorMessage() { | |
echo -e "Error: $1. Type '`basename $0` -h' for usage and options." | |
exit 1 | |
} | |
# Prints the given warning message and exits. | |
function warningMessage() { | |
echo -e "Warning: $1." | |
exit 2 | |
} | |
# Prints this script's usage and exists. | |
function outputUsage() { | |
echo "Usage: `basename $0` [options...]" | |
echo "Options:" | |
echo " -h/--help Prints this message" | |
echo " -d/--dst Directory to install CouchDB" | |
echo " -r/--remove Removes CouchDB from system" | |
echo " If CouchDB is installed anywhere besides the " | |
echo " default directory, specify it using the -d option." | |
exit 1 | |
} | |
################################################################################ | |
# Installation functions | |
################################################################################ | |
# Installs packages and sets up directories and files. | |
function installPackages() { | |
echo "Installing `basename $0` tools & libraries..." | |
sudo apt-get install $PKGS_COUCH -y | |
mkdir -p $DST_DIR | |
cd $DST_DIR | |
git clone git://github.com/iriscouch/build-couchdb | |
cd build-couchdb | |
git submodule init | |
git submodule update | |
# TODO: For some reason, rake was jumping the gun and trying to run | |
# before git finished. Fix this. (Note: rake takes FOREVER to complete.) | |
# rake | |
echo "You're almost done!" | |
echo "cd into '$DST_DIR/build-couchdb' and run 'rake' now. NOTE: This will take awhile." | |
# TODO: Maybe install couchapp too. | |
# http://guide.couchdb.org/draft/managing.html#installing | |
exit 0 | |
} | |
# Removes CouchDB-specific directories and files created. However, all of the | |
# packages installed (rather, upgraded) are kept. Other packages are dependent | |
# on these files as well, so we don't want to remove them. | |
function removePackages() { | |
echo "Removing `basename $0` tools & libraries..." | |
rm -fr $DST_DIR/build-couchdb/ | |
echo "Done." | |
# Note: If we were to install from Ubuntu's repository using apt-get, | |
# we'd have to be sure to purge ALL files or we'd see errors when | |
# reinstalling. | |
# | |
# http://serverfault.com/a/348082/106402 | |
# http://stackoverflow.com/questions/8783621/ | |
exit 0 | |
} | |
################################################################################ | |
# Command line processing | |
################################################################################ | |
# Parse the command line arguments. | |
while [ "$#" -gt "0" ]; do | |
case "$1" in | |
-d|--dst) | |
shift 1 | |
DST_DIR="$1" | |
shift 1 | |
;; | |
-r|--remove) | |
shift 1 | |
removePackages | |
;; | |
-h|--help) | |
outputUsage | |
;; | |
-*|--*) | |
errorMessage "Unknown option $1" | |
;; | |
*) | |
errorMessage "Unknown parameter $1" | |
;; | |
esac | |
done | |
################################################################################ | |
# Main | |
################################################################################ | |
echo "Executing `basename $0`..." | |
installPackages | |
echo "Done." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment