EG install scripts: specify git branch for sysadmin.git
[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 8SITKACONF="${HOMEDIR}/sysadmin"
902a19b7 9SITKACONF_BRANCH="eg28"
0155bbac 10
5dfacac3
JD
11# test for ejabberd passwords
12if [ -z "$PRIVATE_ROUTER_PASSWD" -o -z "$PRIVATE_OPENSRF_PASSWD" -o -z "$PUBLIC_ROUTER_PASSWD" -o -z "$PUBLIC_OPENSRF_PASSWD" ]
13then
14 echo "Missing ejabberd password(s), no OpenSRF install!"
15 exit
16fi
17
0155bbac
JD
18# as root
19usermod -a -G sudo ${DEFAULT_USER}
20apt-get install git-core build-essential translate-toolkit python-polib bsdmainutils
21
22# as DEFAULT_USER
23if [ ! -d "${SITKACONF}" ]
24then
25 # this will fail unless DEFAULT_USER has read access to the repo
26 su -l -c "cd ${HOMEDIR} && git clone git+ssh://git@git.sitka.bclibraries.ca/sitka-infra/sysadmin" ${DEFAULT_USER}
27fi
902a19b7 28su -l -c "cd ${HOMEDIR}/sysadmin && git fetch origin && git checkout ${SITKACONF_BRANCH} && git pull" ${DEFAULT_USER}
0f2c1897
JD
29if [ ! -d "${BUILDDIR}/.git" ] ; then
30 su -l -c "cd ${HOMEDIR} && git clone git://git.evergreen-ils.org/OpenSRF.git opensrf" ${DEFAULT_USER}
e724d7db 31fi
0f2c1897 32su -l -c "cd ${BUILDDIR} && git fetch origin && git checkout ${BRANCH} && git pull" ${DEFAULT_USER}
0155bbac
JD
33
34# as root
15e3aada
JD
35echo "need a placeholder apache2.conf, installing from config repo..."
36if [ -f '/etc/apache2/apache2.conf' ]
37then
38 mv /etc/apache2/apache2.conf /etc/apache2/apache2.conf.bak
39fi
40cp ${SITKACONF}/files/etc/apache2/apache2.conf/${HOSTNAME} /etc/apache2/apache2.conf
41
42# as root
0155bbac 43echo "Installing OpenSRF prerequisites for Ubuntu..."
61bfabc2 44cd ${BUILDDIR} && make -f src/extras/Makefile.install ubuntu-trusty
0155bbac
JD
45
46# as DEFAULT_USER
47echo "Configuring and building OpenSRF..."
0f2c1897
JD
48su -l -c "cd ${BUILDDIR} && autoreconf -i" ${DEFAULT_USER}
49su -l -c "cd ${BUILDDIR} && ./configure --prefix=${INSTALLDIR} --sysconfdir=${INSTALLDIR}/conf" ${DEFAULT_USER}
50su -l -c "cd ${BUILDDIR} && make" ${DEFAULT_USER}
0155bbac
JD
51
52# as root
53echo "Installing OpenSRF..."
0f2c1897 54cd ${BUILDDIR} && make install
0155bbac
JD
55useradd -m -s /bin/bash opensrf
56echo "export PATH=\$PATH:${INSTALLDIR}/bin" >> /home/opensrf/.bashrc
57chown -R opensrf:opensrf ${INSTALLDIR}
58
59# as root, add the following two lines to /etc/hosts:
60#127.0.1.2 public.localhost public
61#127.0.1.3 private.localhost private
62echo "Updating /etc/hosts..."
63echo -e "127.0.1.2\tpublic.localhost\tpublic\n127.0.1.3\tprivate.localhost\tprivate\n" | \
64 cat - /etc/hosts > /etc/hosts.new && mv /etc/hosts.new /etc/hosts
65
66# as root
67echo "ldconfig stuff..."
68echo "${INSTALLDIR}/lib" > /etc/ld.so.conf.d/opensrf.conf
69ldconfig
70
71# as root
72echo "Setting up ejabberd..."
e83deee7 73cp ${SITKACONF}/files/etc/ejabberd/ejabberd.cfg/${HOSTNAME} /etc/ejabberd/ejabberd.cfg
0155bbac
JD
74chgrp ejabberd /etc/ejabberd/ejabberd.cfg
75chmod 640 /etc/ejabberd/ejabberd.cfg
e83deee7
JD
76/etc/init.d/ejabberd restart && sleep 10 && \
77 ejabberdctl register router private.localhost ${PRIVATE_ROUTER_PASSWD} && \
78 ejabberdctl register opensrf private.localhost ${PRIVATE_OPENSRF_PASSWD} && \
79 ejabberdctl register router public.localhost ${PUBLIC_ROUTER_PASSWD} && \
80 ejabberdctl register opensrf public.localhost ${PUBLIC_OPENSRF_PASSWD}
0155bbac
JD
81
82echo "OpenSRF is installed!"
61bfabc2
JD
83
84# websockets install (REQUIRED for web client)
85# XXX a valid SSL cert is required!
e62cefb4
JD
86#rm -r /tmp/apache-websocket
87#cd /tmp && git clone https://github.com/disconnect/apache-websocket
88#cd apache-websocket && apxs2 -i -a -c mod_websocket.c
89#sh /usr/share/doc/apache2/examples/setup-instance websockets
90#a2dismod websocket
91#cp ${SITKACONF}/files/etc/apache2-websockets/apache2.conf/${HOSTNAME} /etc/apache2-websockets/apache2.conf
92#cp ${SITKACONF}/files/etc/apache2-websockets/envvars/${HOSTNAME} /etc/apache2-websockets/envvars
61bfabc2
JD
93
94#/etc/init.d/apache2-websockets start
95
96echo "websockets is installed!"
97