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