#!/bin/bash
+set -e
+
+echo -n "Checking for sudo..."
+if ! which sudo ;
+then
+ echo "Please install sudo and grant yourself access to sudo:"
+ echo
+ echo " # apt-get install sudo"
+ echo " # addgroup $USER sudo"
+ echo
+ exit 1
+fi
+
alias sudo='sudo env PATH=$PATH $@'
-NODE_VERSION=0.8.26
+# Make sure we have all the essential tools we need
+sudo apt-get update
+sudo apt-get -q -y install \
+ git \
+ curl \
+ python-software-properties \
+ software-properties-common
+
+NODE_VERSION=0.10.31
+
+DEBDIST=`lsb_release -c -s`
+echo "Trying to install xTuple for platform ${DEBDIST}"
RUN_DIR=$(pwd)
LOG_FILE=$RUN_DIR/install.log
-cp $LOG_FILE $LOG_FILE.old 2>&1 &> /dev/null
+cp $LOG_FILE $LOG_FILE.old 2>&1 &> /dev/null || true
log() {
echo "xtuple >> $@"
echo $@ >> $LOG_FILE
echo "Usage: install_xtuple [OPTION]"
echo "Build the full xTuple Mobile Development Environment."
echo ""
- echo "To install everything, run sudo ./scripts/install_xtuple.sh"
- echo "Everything will go in /usr/local/src/xtuple"
+ echo "To install everything, run bash /scripts/install_xtuple.sh"
echo ""
echo -e " -h\t\t"
echo -e " -i\t\t"
install_packages() {
log "installing debian packages..."
- echo 'deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main' | sudo tee /etc/apt/sources.list.d/pgdg.list > /dev/null
+ if [ "${DEBDIST}" = "wheezy" ];
+ then
+ # for Debian wheezy (7.x) we need some things from the wheezy-backports
+ sudo add-apt-repository -y "deb http://ftp.debian.org/debian wheezy-backports main"
+ fi
+ sudo add-apt-repository -y "deb http://apt.postgresql.org/pub/repos/apt/ ${DEBDIST}-pgdg main"
sudo wget -qO- https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get -qq update 2>&1 | tee -a $LOG_FILE
sudo apt-get -q -y install curl build-essential libssl-dev postgresql-9.1 postgresql-server-dev-9.1 postgresql-contrib-9.1 postgresql-9.1-plv8 2>&1 | tee -a $LOG_FILE
sudo nvm alias default $NODE_VERSION
sudo nvm alias xtuple $NODE_VERSION
- // npm no longer supports its self-signed certificates
+ # use latest npm
+ sudo npm install -fg npm@1.4.25
+ # npm no longer supports its self-signed certificates
log "telling npm to use known registrars..."
npm config set ca ""
sudo service postgresql restart
log "dropping existing db, if any..."
- sudo -u postgres dropdb $DATABASE
+ sudo -u postgres dropdb $DATABASE || true
cdir $BASEDIR/postgres
cdir $XT_DIR/node-datasource/lib/private
cat /dev/urandom | tr -dc '0-9a-zA-Z!@#$%^&*_+-'| head -c 64 > salt.txt
log "Created salt"
+ cat /dev/urandom | tr -dc '0-9a-zA-Z!@#$%^&*_+-'| head -c 64 > encryption_key.txt
+ log "Created encryption key"
openssl genrsa -des3 -out server.key -passout pass:xtuple 1024 2>&1 | tee -a $LOG_FILE
openssl rsa -in server.key -passin pass:xtuple -out key.pem -passout pass:xtuple 2>&1 | tee -a $LOG_FILE
openssl req -batch -new -key key.pem -out server.csr -subj '/CN='$(hostname) 2>&1 | tee -a $LOG_FILE