updated on Mon Jan 23 12:00:23 UTC 2012
[aur-mirror.git] / evergreen-ils / evergreen-ils.install
blobff2c94a67c1e46a0450ce14664898a79edd32578
1 post_install() {
2     ln -sf /openils/var/web/xul/rel_2_0_7/server/openils/var/web/xul/ /openils/var/web/xul/server
3     cp /openils/etc/opensrf.xml.example /opensrf/conf/opensrf.xml
4     ln -s /opensrf/conf/opensrf.xml /openils/etc/
5     cp /openils/etc/opensrf_core.xml.example /opensrf/conf/opensrf_core.xml
6     ln -s /opensrf/conf/opensrf_core.xml /openils/etc/
7     cp /openils/etc/oils_web.xml.example /opensrf/conf/oils_web.xml
8     ln -s /opensrf/conf/oils_web.xml /openils/etc/
9     
10     # Set up the evergreen database
11     if su - postgres -c "createdb -T template0 --lc-ctype=C --lc-collate=C -E UNICODE evergreen" > /dev/null 2>&1
12     then
13         su - postgres -c "createlang plperl evergreen"
14         su - postgres -c "createlang plperlu evergreen"
15         su - postgres -c "createlang plpgsql evergreen"
16         su - postgres -c "psql -f /usr/share/postgresql/8.4/contrib/tablefunc.sql evergreen"
17         su - postgres -c "psql -f /usr/share/postgresql/8.4/contrib/tsearch2.sql evergreen"
18         su - postgres -c "psql -f /usr/share/postgresql/8.4/contrib/pgxml.sql evergreen"
19     fi
20     # Add evergreen database user
21     if [ `su - postgres -c "psql -A -t -c \"select count(*) from pg_roles where rolname='evergreen'\""` = "0" ]
22     then  
23         tfile=`mktemp`
24     cat << EOF > $tfile
25 CREATE ROLE evergreen PASSWORD 'fixmepls' SUPERUSER CREATEDB CREATEROLE INHERIT LOGIN;
26 EOF
27         chown postgres.postgres $tfile
28         su - postgres -c "psql -f $tfile"
29         rm $tfile
30     fi
31         
32     # Populate database
33     cd /openils/bin/ && perl eg_db_config.pl --update-config --service all --create-schema \
34             --create-offline --hostname localhost --port 5432 --user evergreen --password fixmepls \
35             --database evergreen --admin-user admin --admin-pass open-ils
36     
37     echo "Example apache configuration placed at /etc/httpd/conf/eg.conf - you need"
38     echo "to incorporate this into your actual configuration for Evergreen to work."
39     
40     if [ ! -d "/etc/httpd/ssl" ]; then
41         mkdir /etc/httpd/ssl
42         cd /etc/httpd/ssl
43         openssl req -new -x509 -days 365 -nodes -out server.crt -keyout server.key
44     fi
45     
46     if grep -q "export PERL5LIB=/openils/lib/perl5:\$PERL5LIB" /home/opensrf/.bashrc
47         then echo "export PERL5LIB=/openils/lib/perl5:\$PERL5LIB" | sudo -u opensrf tee -a /home/opensrf/.bashrc
48     fi
49     
50     chown -R opensrf:opensrf /openils/ /opensrf/