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