Pulling in drt24's changes to ubuntu-setup.bash

This commit is contained in:
Raphael 2010-09-27 17:54:20 -07:00
parent efe85a4c28
commit fad27483cd

View file

@ -8,21 +8,36 @@
# licensed under the Affero General Public License version 3. See # licensed under the Affero General Public License version 3. See
# the COPYRIGHT file. # the COPYRIGHT file.
# USAGE: ./script/ubuntu-setup.bash
# Do NOT run this script as root.
# Set extented globbing # Set extented globbing
shopt -s extglob shopt -s extglob
# fail on error
set -e
[ "$(whoami)" == "root" ] && echo "Please do not run this script as root/sudo
We need to do some actions as an ordinary user. We use sudo where necessary." && exit 1
# Check if the user has sudo privileges. # Check if the user has sudo privileges.
sudo -v >/dev/null 2>&1 || { echo $(whoami) has no sudo privileges ; exit 1; } sudo -v >/dev/null 2>&1 || { echo $(whoami) has no sudo privileges ; exit 1; }
# Check if universal repository is enabled # Check if universal repository is enabled
grep -i universe /etc/apt/sources.list > /dev/null || { echo "Please enable universe repository" ; exit 1 ; } grep -i universe /etc/apt/sources.list > /dev/null || \
{ echo "Please enable universe repository" ; exit 1 ; }
# Make sure that we only install the latest version of packages
sudo apt-get update
# Check if wget is installed # Check if wget is installed
test wget || echo "Installing wget.." && sudo apt-get install wget && echo "Installed wget.." test wget || { echo "Installing wget.." && sudo apt-get install wget \
&& echo "Installed wget.." ; }
# Install build tools # Install build tools
echo "Installing build tools.." echo "Installing build tools.."
sudo apt-get -y --no-install-recommends install build-essential libxslt1.1 libxslt1-dev libxml2 sudo apt-get -y --no-install-recommends install \
build-essential libxslt1.1 libxslt1-dev libxml2
echo "..Done installing build tools" echo "..Done installing build tools"
# Install Ruby 1.8.7 # Install Ruby 1.8.7
@ -35,21 +50,39 @@ echo "Installing rake.."
sudo apt-get -y --no-install-recommends install rake sudo apt-get -y --no-install-recommends install rake
echo "..Done installing rake" echo "..Done installing rake"
#Store the release name so we can use it here and later
RELEASE=$(lsb_release -c | cut -f2)
# Get the current release and install mongodb # Get the current release and install mongodb
lsb=$(lsb_release -rs) if [ $RELEASE == "maverick" ]
ver=${lsb//.+(0)/.} then
repo="deb http://downloads.mongodb.org/distros/ubuntu ${ver} 10gen" #mongodb does not supply a repository for maverick yet so install
echo "Setting up MongoDB.." # an older version from the ubuntu repositories
echo "." if [ ! -f /usr/lib/libmozjs.so ]
echo ${repo} | sudo tee -a /etc/apt/sources.list then
echo "." echo "Lanchpad bug https://bugs.launchpad.net/ubuntu/+source/mongodb/+bug/557024
echo "Fetching keys.." has not been fixed using workaround:"
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10 echo "sudo ln -s /usr/lib/xulrunner-1.9.2.10/libmozjs.so /usr/lib/libmozjs.so"
echo "." sudo ln -s /usr/lib/xulrunner-1.9.2.10/libmozjs.so /usr/lib/libmozjs.so
sudo apt-get update fi
echo "."
sudo apt-get -y --no-install-recommends install mongodb-stable sudo apt-get -y --no-install-recommends install mongodb
echo "Done installing monngodb-stable.." else
lsb=$(lsb_release -rs)
ver=${lsb//.+(0)/.}
repo="deb http://downloads.mongodb.org/distros/ubuntu ${ver} 10gen"
echo "Setting up MongoDB.."
echo "."
echo ${repo} | sudo tee -a /etc/apt/sources.list
echo "."
echo "Fetching keys.."
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10
echo "."
sudo apt-get update
echo "."
sudo apt-get -y --no-install-recommends install mongodb-stable
echo "Done installing monngodb-stable.."
fi
# Install imagemagick # Install imagemagick
echo "Installing imagemagick.." echo "Installing imagemagick.."
@ -64,32 +97,31 @@ echo "Installed git-core.."
# Setting up ruby gems # Setting up ruby gems
echo "Fetching and installing ruby gems.." echo "Fetching and installing ruby gems.."
( (
RELEASE=$(lsb_release -c | cut -f2) if [ $RELEASE == "maverick" ]
if [ RELEASE == "maverick" ] then
then sudo apt-get install --no-install-recommends -y rubygems
sudo apt-get install --no-install-recommends -y rubygems sudo ln -s /var/lib/gems/1.8/bin/bundle /usr/local/bin/bundle #for PATH
sudo ln -s /var/lib/gems/1.8/bin/bundle /usr/local/bin/bundle #for PATH elif [ $RELEASE == "lucid" ]
elif [ RELEASE == "lucid" ] then
then sudo add-apt-repository ppa:maco.m/ruby
sudo add-apt-repository ppa:maco.m/ruby sudo apt-get update
sudo apt-get update sudo apt-get install --no-install-recommends -y rubygems
sudo apt-get install --no-install-recommends -y rubygems sudo ln -s /var/lib/gems/1.8/bin/bundle /usr/local/bin/bundle #for PATH
sudo ln -s /var/lib/gems/1.8/bin/bundle /usr/local/bin/bundle #for PATH else
else # Old version
# Old version echo "."
echo "." cd /tmp
cd /tmp wget http://production.cf.rubygems.org/rubygems/rubygems-1.3.7.tgz
wget http://production.cf.rubygems.org/rubygems/rubygems-1.3.7.tgz echo "."
echo "." tar -xf rubygems-1.3.7.tgz
tar -xf rubygems-1.3.7.tgz echo "."
echo "." cd rubygems-1.3.7
cd rubygems-1.3.7 echo "."
echo "." sudo ruby setup.rb
sudo ruby setup.rb echo "."
echo "." sudo ln -s /usr/bin/gem1.8 /usr/bin/gem
sudo ln -s /usr/bin/gem1.8 /usr/bin/gem echo "."
echo "." fi
fi
) )
echo "Done installing the gems.." echo "Done installing the gems.."
@ -100,23 +132,40 @@ echo "Installed bundler.."
# Take a clone of Diaspora # Take a clone of Diaspora
( (
# Check if the user is already in a cloned source if not clone the source
[[ $( basename $PWD ) == "diaspora" ]] && \
echo "Already in diaspora directory" || \
{ git clone http://github.com/diaspora/diaspora.git && cd diaspora
echo "Cloned the source.."
}
# Check if the user is already in a cloned source if not clone the source # Install extra gems
[[ $( basename $PWD ) == "diaspora" ]] && echo "Already in diaspora directory" || git clone http://github.com/diaspora/diaspora.git ; cd diaspora echo "Installing more gems.."
echo "Cloned the source.." bundle install
echo "Installed."
# Install extra gems #Configure diaspora
cd diaspora cp config/app_config.yml.example config/app_config.yml
echo "Installing more gems.." echo "You need to configure diaspora to tell it which URL it has.
sudo bundle install Opening editor in 5 seconds and then continuing with install."
echo "Installed." sleep 5
#ensure EDITOR is set
if [ -z "${EDITOR}"]
then
EDITOR=vi
fi
$EDITOR config/app_config.yml
# Install DB setup # Create the shared directory which is used by rake db:seed:tom
echo "Seting up DB.." mkdir shared
rake db:seed:tom
echo "DB ready. Login -> tom and password -> evankorth. More details ./diaspora/db/seeds/tom.rb."
# Run appserver # Install DB setup
echo "Starting server" echo "Seting up DB.."
bundle exec thin start rake db:seed:tom
echo "DB ready. Login -> tom and password -> evankorth.
More details ./diaspora/db/seeds/tom.rb."
# Run appserver
echo "Starting server"
bundle exec thin start
) )