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