--- /dev/null
+= Evergreen on FreeBSD Install Notes =
+======================================
+:Author: Bill Erickson
+
+About this document
+-------------------
+
+ * Each chunk of commands should be run as root, unless it starts with 'su'
+ * All ports were installed with the default configurations selected (batch mode)
+ * Install was tested on FreeBSD-9.0-RC2-i386
+ * I am not a FreeBSD expert.
+
+Basic Setup and PreReqs
+-----------------------
+
+FreeBSD first steps
+~~~~~~~~~~~~~~~~~~~
+
+[source, sh]
+------------------------------------------------------------------------------
+portsnap fetch
+# 'portstap extract' is only needed the first time portsnap is fetched
+portsnap extract
+portsnap update
+cd /usr/ports/ports-mgmt/portupgrade
+make -DBATCH install clean
+rehash
+portinstall --batch shells/bash shells/bash-completion devel/git ftp/wget
+rehash
+echo ". /usr/local/etc/bash_completion" >> ~/.bash_profile
+bash
+------------------------------------------------------------------------------
+
+Utilities, etc. (OPTIONAL)
+~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Stuff I regularly use.
+
+[source, sh]
+------------------------------------------------------------------------------
+portinstall --batch \
+ security/sudo \
+ sysutils/screen \
+ editors/vim
+------------------------------------------------------------------------------
+
+OpenSRF PreReqs
+~~~~~~~~~~~~~~~
+
+[source, sh]
+------------------------------------------------------------------------------
+portinstall --batch \
+ devel/autoconf \
+ devel/automake \
+ devel/libtool \
+ devel/pkg-config \
+ www/apache22 \
+ net-im/ejabberd \
+ textproc/libxml2 \
+ textproc/libxslt \
+ databases/memcached \
+ databases/libmemcached \
+ www/mod_perl2 \
+ databases/p5-Cache-Memcached \
+ databases/p5-Class-DBI-AbstractSearch \
+ databases/p5-Class-DBI-SQLite \
+ devel/p5-DateTime \
+ devel/p5-DateTime-Format-Builder \
+ devel/p5-DateTime-Format-Mail \
+ devel/p5-DateTime-TimeZone \
+ lang/p5-Error \
+ devel/p5-File-Find-Rule \
+ textproc/expat2 \
+ security/libgcrypt \
+ databases/gdbm \
+ devel/p5-Log-Log4perl \
+ devel/readline \
+ net/p5-RPC-XML \
+ devel/p5-Module-Build \
+ www/p5-Template-Toolkit \
+ devel/p5-Test-Pod \
+ devel/p5-Tie-IxHash \
+ devel/p5-UNIVERSAL-require \
+ sysutils/p5-Unix-Syslog \
+ www/p5-libwww \
+ textproc/p5-XML-LibXML \
+ textproc/p5-XML-LibXSLT \
+ textproc/p5-XML-SimpleObject-LibXML \
+ textproc/py-libxml2 \
+ devel/py-setuptools \
+ converters/p5-JSON-XS
+------------------------------------------------------------------------------
+
+Evergreen PreReqs
+~~~~~~~~~~~~~~~~~
+
+Install Postgres 9 first so any ports that rely on postgres will know to
+use version 9.
+
+[source, sh]
+------------------------------------------------------------------------------
+portinstall --batch \
+ databases/postgresql91-server \
+ databases/postgresql91-contrib
+------------------------------------------------------------------------------
+
+[source, sh]
+------------------------------------------------------------------------------
+portinstall --batch \
+ databases/p5-postgresql-plperl \
+ databases/libdbi \
+ databases/libdbi-drivers \
+ databases/p5-DBD-Pg \
+ textproc/aspell \
+ finance/p5-Business-CreditCard \
+ finance/p5-Business-OnlinePayment \
+ finance/p5-Business-OnlinePayment-AuthorizeNet \
+ devel/p5-DateTime-Format-ISO8601 \
+ devel/p5-DateTime-Set \
+ devel/ncurses \
+ mail/p5-Email-Send \
+ mail/p5-Email-Simple \
+ graphics/p5-GD-Graph3d \
+ net/p5-Net-Server \
+ net/p5-Net-SSH2 \
+ devel/nspr \
+ devel/p5-OLE-Storage_Lite \
+ devel/p5-parent \
+ security/libssh2 \
+ textproc/p5-Text-Aspell \
+ textproc/p5-Text-CSV \
+ textproc/p5-XML-Simple\
+ textproc/p5-Spreadsheet-WriteExcel \
+ devel/p5-UNIVERSAL-require \
+ net-mgmt/p5-Net-IP \
+ devel/p5-Locale-Maketext-Lexicon \
+ sysutils/p5-Unix-Syslog \
+ net/p5-Net-Z3950-ZOOM \
+ net/yaz \
+ devel/p5-UUID-Tiny \
+ devel/p5-Parse-RecDescent \
+ lang/p5-JavaScript-SpiderMonkey
+------------------------------------------------------------------------------
+
+Evergreen CPAN Mods
+~~~~~~~~~~~~~~~~~~~
+
+*Note* : Install all MARC Perl mods from CPAN to get the latest version of
+MARC::Record and to ensure MARC::Charset is correctly installed (prob w/
+code table)
+
+[source, sh]
+------------------------------------------------------------------------------
+cpan \
+ MARC::Record \
+ MARC::Charset \
+ MARC::File::XML \
+ Business::EDI \
+ Business::ISBN \
+ Business::ISBN::Data \
+ SRU::Request \
+ Library::CallNumber::LC \
+ M/MI/MIRK/Net-Z3950-SimpleServer-1.12.tar.gz \
+ Template::Plugin::POSIX \
+ Business::CreditCard::Object \
+ RPC::XML::Method \
+ SRU
+------------------------------------------------------------------------------
+
+[source, sh]
+------------------------------------------------------------------------------
+cpan -f -i Class::DBI::Frozen::301
+------------------------------------------------------------------------------
+
+Add the following to /etc/rc.conf
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+[source, sh]
+------------------------------------------------------------------------------
+postgresql_enable="YES"
+postgresql_data="/usr/local/postgres/data"
+postgresql_user="postgres"
+memcached_enable="YES"
+apache22_enable="YES"
+ejabberd_enable="YES"
+------------------------------------------------------------------------------
+
+Create the opensrf user
+~~~~~~~~~~~~~~~~~~~~~~~
+
+[source, sh]
+------------------------------------------------------------------------------
+pw useradd -m -n opensrf -s /usr/local/bin/bash
+echo 'export PATH=/openils/bin:$PATH' >> /home/opensrf/.bashrc
+echo '. /home/opensrf/.bashrc' >> /home/opensrf/.bash_profile
+chown opensrf:opensrf /home/opensrf/.bash*
+------------------------------------------------------------------------------
+
+Ejabberd Config
+~~~~~~~~~~~~~~~
+
+[source, sh]
+------------------------------------------------------------------------------
+cd /usr/local/etc/ejabberd/
+cp ejabberd.cfg.example ejabberd.cfg
+cp inetrc.example inetrc; # TODO: investigate adding 127.0.1.* to match default /etc/hosts
+# XXX edit ejabberd.cfg per Evergreen instructions (see patch under Reference below)
+chown ejabberd:ejabberd ejabberd.cfg;
+ejabberdctl start
+sleep 2
+ejabberdctl register router private.localhost password
+ejabberdctl register opensrf private.localhost password
+ejabberdctl register router public.localhost password
+ejabberdctl register opensrf public.localhost password
+------------------------------------------------------------------------------
+
+Start Memcached
+~~~~~~~~~~~~~~~
+
+[source, sh]
+------------------------------------------------------------------------------
+/usr/local/etc/rc.d/memcached start
+------------------------------------------------------------------------------
+
+Postgres Setup
+~~~~~~~~~~~~~~
+
+*Note* : The postgres user on FreeBSD is 'pgsql' by default. Use 'postgres'
+instead for consistency w/ Evergreen docs.
+
+[source, sh]
+------------------------------------------------------------------------------
+pw useradd -m -n postgres -s /usr/local/bin/bash -d /usr/local/postgres
+su postgres
+mkdir /usr/local/postgres/data
+initdb --encoding=utf-8 --lc-collate=C -D /usr/local/postgres/data
+exit # su postgres
+/usr/local/etc/rc.d/postgresql start
+------------------------------------------------------------------------------
+
+Install OpenSRF and Evergreen
+-----------------------------
+
+Fetch the OpenSRF and Evergreen Sources
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+[source, sh]
+------------------------------------------------------------------------------
+su opensrf
+cd /home/opensrf
+git clone git://git.evergreen-ils.org/OpenSRF.git
+git clone git://git.evergreen-ils.org/Evergreen.git
+# XXX Add "working" remote for both repos and checkout the collab/berick/bsd-compat branch
+exit # su opensrf
+------------------------------------------------------------------------------
+
+Install OpenSRF
+~~~~~~~~~~~~~~~
+
+[source, sh]
+------------------------------------------------------------------------------
+su opensrf
+cd /home/opensrf/OpenSRF
+./autogen.sh
+CFLAGS="-I/usr/local/include" LDFLAGS="-L/usr/local/lib" ./configure \
+ --prefix=/openils --sysconfdir=/openils/conf --with-apxs=/usr/local/sbin/apxs \
+ --with-libxml=/usr/local/include/libxml2 --with-includes=/usr/local/include
+gmake
+exit # su opensrf
+gmake install
+------------------------------------------------------------------------------
+
+Install Evergreen
+~~~~~~~~~~~~~~~~~
+
+[source, sh]
+------------------------------------------------------------------------------
+ln -s /usr/local/bin/bash /bin/bash # still many hard-coded paths
+ln -s /sbin/md5 /sbin/md5sum # for /openils/bin/autogen.sh
+su opensrf
+cd /home/opensrf/Evergreen
+./autogen.sh
+CFLAGS="-I/usr/local/include" LDFLAGS="-L/usr/local/lib" ./configure \
+ --prefix=/openils --sysconfdir=/openils/conf \
+ --with-apxs=/usr/local/sbin/apxs --with-libxml2=/usr/local/include/libxml2
+gmake
+exit # su opensrf
+------------------------------------------------------------------------------
+
+[source, sh]
+------------------------------------------------------------------------------
+gmake install
+chown -R opensrf:opensrf /openils
+
+# copy some files into place
+su opensrf
+
+cp /openils/conf/opensrf.xml.example /openils/conf/opensrf.xml
+cp /openils/conf/opensrf_core.xml.example /openils/conf/opensrf_core.xml
+cp /openils/conf/srfsh.xml.example /home/opensrf/.srfsh.xml;
+
+# dojo
+cd /tmp
+wget http://download.dojotoolkit.org/release-1.3.3/dojo-release-1.3.3.tar.gz
+tar -C /openils/var/web/js -xzf dojo-release-1.3.3.tar.gz
+cp -r /openils/var/web/js/dojo-release-1.3.3/* /openils/var/web/js/dojo/.
+
+exit # su opensrf
+------------------------------------------------------------------------------
+
+Create the EG DB
+~~~~~~~~~~~~~~~~
+
+[source, sh]
+------------------------------------------------------------------------------
+su postgres
+createdb -T template0 --lc-ctype=C --lc-collate=C --encoding=utf-8 evergreen
+createlang plperl evergreen
+createlang plperlu evergreen
+psql -d evergreen -c "CREATE EXTENSION tablefunc"
+psql -d evergreen -c "CREATE EXTENSION tsearch2"
+psql -d evergreen -c "CREATE EXTENSION hstore"
+createuser -P -s evergreen
+exit # su postgres
+------------------------------------------------------------------------------
+
+Install the EG Schema
+~~~~~~~~~~~~~~~~~~~~~
+
+*alert* : First, apply the GDBM_File patch from below ("GDBM_File.pm Patch" below)
+
+[source, sh]
+------------------------------------------------------------------------------
+ADMIN_USER=admin # change to suit
+ADMIN_PASS=demo123 # change to suit
+DB_USER=evergreen # change to suit
+DB_PASS=evergreen # change to suit
+cd /home/opensrf/Evergreen;
+perl Open-ILS/src/support-scripts/eg_db_config.pl \
+ --update-config --service all --create-schema \
+ --create-bootstrap --create-offline --user $DB_USER \
+ --password $DB_PASS --hostname localhost --database evergreen \
+ --admin-user $ADMIN_USER --admin-pass $ADMIN_PASS
+------------------------------------------------------------------------------
+
+Edit /etc/hosts
+~~~~~~~~~~~~~~~
+
+[source, sh]
+------------------------------------------------------------------------------
+# Note the IPs..., result of ejabberd's inetrc
+127.0.0.1 public.localhost public
+127.0.0.1 private.localhost private
+------------------------------------------------------------------------------
+
+Start Evergreen
+~~~~~~~~~~~~~~~
+
+ * Since this is the first time, run the commands separately and watch for
+ errors.
+
+[source, sh]
+------------------------------------------------------------------------------
+su - opensrf
+osrf_ctl.sh -l -a start_router
+osrf_ctl.sh -l -a start_perl && sleep 10
+osrf_ctl.sh -l -a start_c && sleep 3
+------------------------------------------------------------------------------
+
+Test and run autogen
+~~~~~~~~~~~~~~~~~~~~
+
+[source, sh]
+------------------------------------------------------------------------------
+su - opensrf
+
+# do a quick test. This should return a blob of JSON
+echo "request open-ils.cstore open-ils.cstore.direct.actor.user.retrieve 1" | srfsh
+
+# run Evergreen's autogen
+/openils/bin/autogen.sh /openils/conf/opensrf_core.xml;
+exit # su opensrf
+------------------------------------------------------------------------------
+
+Setup Apache
+~~~~~~~~~~~
+
+[source, sh]
+------------------------------------------------------------------------------
+cp /home/opensrf/Evergreen/Open-ILS/examples/apache/eg_vhost.conf /usr/local/etc/apache22/
+cp /home/opensrf/Evergreen/Open-ILS/examples/apache/startup.pl /usr/local/etc/apache22/
+cp /home/opensrf/Evergreen/Open-ILS/examples/apache/eg.conf /usr/local/etc/apache22/Includes/
+# install dummy ssl cert
+mkdir /usr/local/etc/apache22/ssl
+openssl req -new -x509 -days 365 -nodes -out /usr/local/etc/apache22/ssl/server.crt -keyout /usr/local/etc/apache22/ssl/server.key
+mkdir /var/log/apache2 # for logs
+------------------------------------------------------------------------------
+
+ * Edit /usr/local/etc/apache22/Includes/eg.conf
+ ** Update import of eg_vhost.conf -> etc/apache22/eg_vhost.conf
+ ** Update SSL key/cert imports -> etc/apache22/ssl/server.crt, etc/apache22/ssl/server.key
+ ** Update startup.pl path -> /usr/local/etc/apache22/startup.pl
+* Edit /usr/local/etc/apache22/httpd.conf
+ ** Add: "LoadModule perl_module libexec/apache22/mod_perl.so"
+ *** before: Include etc/apache22/Includes/*.conf
+ ** update User and Group to 'opensrf'
+ ** Add Listen 443 to httpd.conf
+* Edit /usr/local/etc/apache22/extra/httpd-default.conf
+ ** Set KeepAliveTimeout to 1
+
+Fire it up...
+
+[source, sh]
+------------------------------------------------------------------------------
+ /usr/local/etc/rc.d/apache22 start
+------------------------------------------------------------------------------
+
+Use rsyslog for logging (OPTIONAL)
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+[source, sh]
+------------------------------------------------------------------------------
+portinstall --batch sysutils/rsyslog5
+/etc/rc.d/syslogd stop
+cp /etc/syslog.conf /usr/local/etc/rsyslog.conf
+mkdir /usr/local/etc/rsyslog.d
+# http://git.evergreen-ils.org/?p=working/Evergreen.git;a=commitdiff;h=a062fca66343e78c8c1c3203b34072bf557c499c
+# cp evergreen-rsyslog.conf /usr/local/etc/rsyslog.d/
+------------------------------------------------------------------------------
+
+Add these lines to the beginning of /usr/local/etc/rsyslog.conf
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+[source, sh]
+------------------------------------------------------------------------------
+$ModLoad immark.so # provides --MARK-- message capability
+$ModLoad imuxsock.so # provides support for local system logging
+$ModLoad imklog.so # kernel logging
+$IncludeConfig /usr/local/etc/rsyslog.d/*.conf
+------------------------------------------------------------------------------
+
+Add to /etc/rc.conf
+^^^^^^^^^^^^^^^^^^^
+
+[source, sh]
+------------------------------------------------------------------------------
+syslogd_enable="NO"
+rsyslogd_enable="YES"
+rsyslogd_flags="-c4"
+------------------------------------------------------------------------------
+
+Start rsyslogd
+^^^^^^^^^^^^^^
+[source, sh]
+------------------------------------------------------------------------------
+/usr/local/etc/rc.d/rsyslogd start
+------------------------------------------------------------------------------
+
+Reference
+---------
+
+OpenSRF Patches
+~~~~~~~~~~~~~~~
+
+http://git.evergreen-ils.org/?p=working/OpenSRF.git;a=shortlog;h=refs/heads/collab/berick/bsd-compat
+
+Evergreen Patches
+~~~~~~~~~~~~~~~~~
+
+http://git.evergreen-ils.org/?p=working/Evergreen.git;a=shortlog;h=refs/heads/collab/berick/bsd-compat
+
+GDBM_File.pm Patch
+~~~~~~~~~~~~~~~~~
+
+There is currently a version incompatibility with GDBM_File.pm and XSLoader.pm.
+This will fix it.
+
+[source, diff]
+------------------------------------------------------------------------------
+--- /tmp/GDBM_File.pm 2011-11-15 22:46:43.000000000 -0500
++++ /usr/local/lib/perl5/site_perl/5.12.4/mach/GDBM_File.pm 2011-11-15 17:16:15.000000000 -0500
+@@ -71,6 +71,6 @@
+ # This module isn't dual life, so no need for dev version numbers.
+ $VERSION = '1.14';
+
+-XSLoader::load;
++XSLoader::load('GDBM_File', $VERSION);
+
+ 1;
+------------------------------------------------------------------------------
+
+Ejabberd Config Patch
+~~~~~~~~~~~~~~~~~~~~~
+
+Nothing special here. Just adding it for reference.
+
+[source, diff]
+------------------------------------------------------------------------------
+--- ejabberd.cfg.example 2011-11-13 11:06:39.000000000 -0500
++++ ejabberd.cfg 2011-11-13 22:11:26.000000000 -0500
+@@ -88,7 +88,7 @@
+ %% You can define one or several, for example:
+ %% {hosts, ["example.net", "example.com", "example.org"]}.
+ %%
+-{hosts, ["localhost"]}.
++{hosts, ["public.localhost", "private.localhost"]}.
+
+ %%
+ %% route_subdomains: Delegate subdomains to other XMPP servers.
+@@ -119,7 +119,7 @@
+
+ {access, c2s},
+ {shaper, c2s_shaper},
+- {max_stanza_size, 65536}
++ {max_stanza_size, 200000}
+ ]},
+
+ %%
+@@ -134,7 +134,7 @@
+
+ {5269, ejabberd_s2s_in, [
+ {shaper, s2s_shaper},
+- {max_stanza_size, 131072}
++ {max_stanza_size, 200000}
+ ]},
+
+ %%
+@@ -341,12 +341,12 @@
+ %%
+ %% The "normal" shaper limits traffic speed to 1000 B/s
+ %%
+-{shaper, normal, {maxrate, 1000}}.
++{shaper, normal, {maxrate, 500000}}.
+
+ %%
+ %% The "fast" shaper limits traffic speed to 50000 B/s
+ %%
+-{shaper, fast, {maxrate, 50000}}.
++{shaper, fast, {maxrate, 500000}}.
+
+ %%
+ %% This option specifies the maximum number of elements in the queue
+@@ -398,7 +398,7 @@
+ %%%' ACCESS RULES
+
+ %% Maximum number of simultaneous sessions allowed for a single user:
+-{access, max_user_sessions, [{10, all}]}.
++{access, max_user_sessions, [{5000, all}]}.
+
+ %% Maximum number of offline messages that users can have:
+ {access, max_user_offline_messages, [{5000, admin}, {100, all}]}.
+@@ -518,7 +518,7 @@
+ {access_admin, muc_admin}
+ ]},
+ %%{mod_muc_log,[]},
+- {mod_offline, [{access_max_user_messages, max_user_offline_messages}]},
++ %%{mod_offline, [{access_max_user_messages, max_user_offline_messages}]},
+ {mod_ping, []},
+ %%{mod_pres_counter,[{count, 5}, {interval, 60}]},
+ {mod_privacy, []},
+------------------------------------------------------------------------------
+