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