Update install scripts for EG 2.4.0 and OpenSRF 2.2.0
[sitka/sitka-tools.git] / deployment / install-osrf.sh
CommitLineData
0155bbac 1#!/bin/bash
d4e88b8a 2OSRF="opensrf-2.2.0"
0155bbac 3INSTALLDIR="/srv/openils"
e83deee7 4HOSTNAME="nonprod"
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}
27su -l -c "cd ${HOMEDIR} && wget http://open-ils.org/downloads/${OSRF}.tar.gz && tar xzf ${OSRF}.tar.gz" ${DEFAULT_USER}
28
29# as root
30echo "Installing OpenSRF prerequisites for Ubuntu..."
31cd ${HOMEDIR}/${OSRF} && make -f src/extras/Makefile.install ubuntu-precise
32
33# as DEFAULT_USER
34echo "Configuring and building OpenSRF..."
35su -l -c "cd ${HOMEDIR}/${OSRF} && autoreconf -i" ${DEFAULT_USER}
36su -l -c "cd ${HOMEDIR}/${OSRF} && ./configure --prefix=${INSTALLDIR} --sysconfdir=${INSTALLDIR}/conf" ${DEFAULT_USER}
37su -l -c "cd ${HOMEDIR}/${OSRF} && make" ${DEFAULT_USER}
38
39# as root
40echo "Installing OpenSRF..."
41cd ${HOMEDIR}/${OSRF} && make install
42useradd -m -s /bin/bash opensrf
43echo "export PATH=\$PATH:${INSTALLDIR}/bin" >> /home/opensrf/.bashrc
44chown -R opensrf:opensrf ${INSTALLDIR}
45
46# as root, add the following two lines to /etc/hosts:
47#127.0.1.2 public.localhost public
48#127.0.1.3 private.localhost private
49echo "Updating /etc/hosts..."
50echo -e "127.0.1.2\tpublic.localhost\tpublic\n127.0.1.3\tprivate.localhost\tprivate\n" | \
51 cat - /etc/hosts > /etc/hosts.new && mv /etc/hosts.new /etc/hosts
52
53# as root
54echo "ldconfig stuff..."
55echo "${INSTALLDIR}/lib" > /etc/ld.so.conf.d/opensrf.conf
56ldconfig
57
58# as root
59echo "Setting up ejabberd..."
e83deee7 60cp ${SITKACONF}/files/etc/ejabberd/ejabberd.cfg/${HOSTNAME} /etc/ejabberd/ejabberd.cfg
0155bbac
JD
61chgrp ejabberd /etc/ejabberd/ejabberd.cfg
62chmod 640 /etc/ejabberd/ejabberd.cfg
e83deee7
JD
63/etc/init.d/ejabberd restart && sleep 10 && \
64 ejabberdctl register router private.localhost ${PRIVATE_ROUTER_PASSWD} && \
65 ejabberdctl register opensrf private.localhost ${PRIVATE_OPENSRF_PASSWD} && \
66 ejabberdctl register router public.localhost ${PUBLIC_ROUTER_PASSWD} && \
67 ejabberdctl register opensrf public.localhost ${PUBLIC_OPENSRF_PASSWD}
0155bbac
JD
68
69echo "OpenSRF is installed!"