Commit | Line | Data |
---|---|---|
0155bbac | 1 | #!/bin/bash |
0155bbac JD |
2 | DEFAULT_USER="sitkastaff" |
3 | HOMEDIR="/home/${DEFAULT_USER}" | |
0f2c1897 JD |
4 | BUILDDIR="${HOMEDIR}/opensrf" |
5 | INSTALLDIR="/srv/openils" | |
61bfabc2 JD |
6 | BRANCH="rel_2_4" |
7 | HOSTNAME="nonprod-28" | |
0155bbac JD |
8 | SITKACONF="${HOMEDIR}/sysadmin" |
9 | ||
5dfacac3 JD |
10 | # test for ejabberd passwords |
11 | if [ -z "$PRIVATE_ROUTER_PASSWD" -o -z "$PRIVATE_OPENSRF_PASSWD" -o -z "$PUBLIC_ROUTER_PASSWD" -o -z "$PUBLIC_OPENSRF_PASSWD" ] | |
12 | then | |
13 | echo "Missing ejabberd password(s), no OpenSRF install!" | |
14 | exit | |
15 | fi | |
16 | ||
0155bbac JD |
17 | # as root |
18 | usermod -a -G sudo ${DEFAULT_USER} | |
19 | apt-get install git-core build-essential translate-toolkit python-polib bsdmainutils | |
20 | ||
21 | # as DEFAULT_USER | |
22 | if [ ! -d "${SITKACONF}" ] | |
23 | then | |
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} | |
26 | fi | |
27 | su -l -c "cd ${HOMEDIR}/sysadmin && git pull" ${DEFAULT_USER} | |
0f2c1897 JD |
28 | if [ ! -d "${BUILDDIR}/.git" ] ; then |
29 | su -l -c "cd ${HOMEDIR} && git clone git://git.evergreen-ils.org/OpenSRF.git opensrf" ${DEFAULT_USER} | |
e724d7db | 30 | fi |
0f2c1897 | 31 | su -l -c "cd ${BUILDDIR} && git fetch origin && git checkout ${BRANCH} && git pull" ${DEFAULT_USER} |
0155bbac JD |
32 | |
33 | # as root | |
15e3aada JD |
34 | echo "need a placeholder apache2.conf, installing from config repo..." |
35 | if [ -f '/etc/apache2/apache2.conf' ] | |
36 | then | |
37 | mv /etc/apache2/apache2.conf /etc/apache2/apache2.conf.bak | |
38 | fi | |
39 | cp ${SITKACONF}/files/etc/apache2/apache2.conf/${HOSTNAME} /etc/apache2/apache2.conf | |
40 | ||
41 | # as root | |
0155bbac | 42 | echo "Installing OpenSRF prerequisites for Ubuntu..." |
61bfabc2 | 43 | cd ${BUILDDIR} && make -f src/extras/Makefile.install ubuntu-trusty |
0155bbac JD |
44 | |
45 | # as DEFAULT_USER | |
46 | echo "Configuring and building OpenSRF..." | |
0f2c1897 JD |
47 | su -l -c "cd ${BUILDDIR} && autoreconf -i" ${DEFAULT_USER} |
48 | su -l -c "cd ${BUILDDIR} && ./configure --prefix=${INSTALLDIR} --sysconfdir=${INSTALLDIR}/conf" ${DEFAULT_USER} | |
49 | su -l -c "cd ${BUILDDIR} && make" ${DEFAULT_USER} | |
0155bbac JD |
50 | |
51 | # as root | |
52 | echo "Installing OpenSRF..." | |
0f2c1897 | 53 | cd ${BUILDDIR} && make install |
0155bbac JD |
54 | useradd -m -s /bin/bash opensrf |
55 | echo "export PATH=\$PATH:${INSTALLDIR}/bin" >> /home/opensrf/.bashrc | |
56 | chown -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 | |
61 | echo "Updating /etc/hosts..." | |
62 | echo -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 | |
66 | echo "ldconfig stuff..." | |
67 | echo "${INSTALLDIR}/lib" > /etc/ld.so.conf.d/opensrf.conf | |
68 | ldconfig | |
69 | ||
70 | # as root | |
71 | echo "Setting up ejabberd..." | |
e83deee7 | 72 | cp ${SITKACONF}/files/etc/ejabberd/ejabberd.cfg/${HOSTNAME} /etc/ejabberd/ejabberd.cfg |
0155bbac JD |
73 | chgrp ejabberd /etc/ejabberd/ejabberd.cfg |
74 | chmod 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 | |
81 | echo "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 | ||
95 | echo "websockets is installed!" | |
96 |