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