added automated deployment tools
[sitka/sitka-tools.git] / deployment / install-osrf.sh
CommitLineData
0155bbac
JD
1#!/bin/bash
2OSRF="opensrf-2.1.0"
3INSTALLDIR="/srv/openils"
4DEFAULT_USER="sitkastaff"
5HOMEDIR="/home/${DEFAULT_USER}"
6SITKACONF="${HOMEDIR}/sysadmin"
7
8# as root
9usermod -a -G sudo ${DEFAULT_USER}
10apt-get install git-core build-essential translate-toolkit python-polib bsdmainutils
11
12# as DEFAULT_USER
13if [ ! -d "${SITKACONF}" ]
14then
15 # this will fail unless DEFAULT_USER has read access to the repo
16 su -l -c "cd ${HOMEDIR} && git clone git+ssh://git@git.sitka.bclibraries.ca/sitka-infra/sysadmin" ${DEFAULT_USER}
17fi
18su -l -c "cd ${HOMEDIR}/sysadmin && git pull" ${DEFAULT_USER}
19su -l -c "cd ${HOMEDIR} && wget http://open-ils.org/downloads/${OSRF}.tar.gz && tar xzf ${OSRF}.tar.gz" ${DEFAULT_USER}
20
21# as root
22echo "Installing OpenSRF prerequisites for Ubuntu..."
23cd ${HOMEDIR}/${OSRF} && make -f src/extras/Makefile.install ubuntu-precise
24
25# as DEFAULT_USER
26echo "Configuring and building OpenSRF..."
27su -l -c "cd ${HOMEDIR}/${OSRF} && autoreconf -i" ${DEFAULT_USER}
28su -l -c "cd ${HOMEDIR}/${OSRF} && ./configure --prefix=${INSTALLDIR} --sysconfdir=${INSTALLDIR}/conf" ${DEFAULT_USER}
29su -l -c "cd ${HOMEDIR}/${OSRF} && make" ${DEFAULT_USER}
30
31# as root
32echo "Installing OpenSRF..."
33cd ${HOMEDIR}/${OSRF} && make install
34useradd -m -s /bin/bash opensrf
35echo "export PATH=\$PATH:${INSTALLDIR}/bin" >> /home/opensrf/.bashrc
36chown -R opensrf:opensrf ${INSTALLDIR}
37
38# as root, add the following two lines to /etc/hosts:
39#127.0.1.2 public.localhost public
40#127.0.1.3 private.localhost private
41echo "Updating /etc/hosts..."
42echo -e "127.0.1.2\tpublic.localhost\tpublic\n127.0.1.3\tprivate.localhost\tprivate\n" | \
43 cat - /etc/hosts > /etc/hosts.new && mv /etc/hosts.new /etc/hosts
44
45# as root
46echo "ldconfig stuff..."
47echo "${INSTALLDIR}/lib" > /etc/ld.so.conf.d/opensrf.conf
48ldconfig
49
50# as root
51echo "Setting up ejabberd..."
52mv /etc/ejabberd/ejabberd.cfg /etc/ejabberd/ejabberd.cfg.orig && cp ${SITKACONF}/files/etc/ejabberd/ejabberd.cfg/nonprod /etc/ejabberd/
53chgrp ejabberd /etc/ejabberd/ejabberd.cfg
54chmod 640 /etc/ejabberd/ejabberd.cfg
55/etc/init.d/ejabberd restart
56ejabberdctl register router private.localhost passwd
57ejabberdctl register opensrf private.localhost passwd
58ejabberdctl register router public.localhost passwd
59ejabberdctl register opensrf public.localhost passwd
60
61echo "OpenSRF is installed!"