install-osrf.sh: do not install web client stuff by default
[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"
61bfabc2
JD
6BRANCH="rel_2_4"
7HOSTNAME="nonprod-28"
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
15e3aada
JD
34echo "need a placeholder apache2.conf, installing from config repo..."
35if [ -f '/etc/apache2/apache2.conf' ]
36then
37 mv /etc/apache2/apache2.conf /etc/apache2/apache2.conf.bak
38fi
39cp ${SITKACONF}/files/etc/apache2/apache2.conf/${HOSTNAME} /etc/apache2/apache2.conf
40
41# as root
0155bbac 42echo "Installing OpenSRF prerequisites for Ubuntu..."
61bfabc2 43cd ${BUILDDIR} && make -f src/extras/Makefile.install ubuntu-trusty
0155bbac
JD
44
45# as DEFAULT_USER
46echo "Configuring and building OpenSRF..."
0f2c1897
JD
47su -l -c "cd ${BUILDDIR} && autoreconf -i" ${DEFAULT_USER}
48su -l -c "cd ${BUILDDIR} && ./configure --prefix=${INSTALLDIR} --sysconfdir=${INSTALLDIR}/conf" ${DEFAULT_USER}
49su -l -c "cd ${BUILDDIR} && make" ${DEFAULT_USER}
0155bbac
JD
50
51# as root
52echo "Installing OpenSRF..."
0f2c1897 53cd ${BUILDDIR} && make install
0155bbac
JD
54useradd -m -s /bin/bash opensrf
55echo "export PATH=\$PATH:${INSTALLDIR}/bin" >> /home/opensrf/.bashrc
56chown -R opensrf:opensrf ${INSTALLDIR}
57
58# as root, add the following two lines to /etc/hosts:
59#127.0.1.2 public.localhost public
60#127.0.1.3 private.localhost private
61echo "Updating /etc/hosts..."
62echo -e "127.0.1.2\tpublic.localhost\tpublic\n127.0.1.3\tprivate.localhost\tprivate\n" | \
63 cat - /etc/hosts > /etc/hosts.new && mv /etc/hosts.new /etc/hosts
64
65# as root
66echo "ldconfig stuff..."
67echo "${INSTALLDIR}/lib" > /etc/ld.so.conf.d/opensrf.conf
68ldconfig
69
70# as root
71echo "Setting up ejabberd..."
e83deee7 72cp ${SITKACONF}/files/etc/ejabberd/ejabberd.cfg/${HOSTNAME} /etc/ejabberd/ejabberd.cfg
0155bbac
JD
73chgrp ejabberd /etc/ejabberd/ejabberd.cfg
74chmod 640 /etc/ejabberd/ejabberd.cfg
e83deee7
JD
75/etc/init.d/ejabberd restart && sleep 10 && \
76 ejabberdctl register router private.localhost ${PRIVATE_ROUTER_PASSWD} && \
77 ejabberdctl register opensrf private.localhost ${PRIVATE_OPENSRF_PASSWD} && \
78 ejabberdctl register router public.localhost ${PUBLIC_ROUTER_PASSWD} && \
79 ejabberdctl register opensrf public.localhost ${PUBLIC_OPENSRF_PASSWD}
0155bbac
JD
80
81echo "OpenSRF is installed!"
61bfabc2
JD
82
83# websockets install (REQUIRED for web client)
84# XXX a valid SSL cert is required!
e62cefb4
JD
85#rm -r /tmp/apache-websocket
86#cd /tmp && git clone https://github.com/disconnect/apache-websocket
87#cd apache-websocket && apxs2 -i -a -c mod_websocket.c
88#sh /usr/share/doc/apache2/examples/setup-instance websockets
89#a2dismod websocket
90#cp ${SITKACONF}/files/etc/apache2-websockets/apache2.conf/${HOSTNAME} /etc/apache2-websockets/apache2.conf
91#cp ${SITKACONF}/files/etc/apache2-websockets/envvars/${HOSTNAME} /etc/apache2-websockets/envvars
61bfabc2
JD
92
93#/etc/init.d/apache2-websockets start
94
95echo "websockets is installed!"
96