Author : Devlyn Davis
Sources : SQL-Ledger Howto by david_d in contribs.org forums
Tested on SME Version 7.0 Final GPL
Updated : 15 Aug 2006
License : GPL


This Howto will show you how to install SQL-Ledger on SME 7.0




This is a modification of the excellent sql-ledger Howto done by david_d. His original howto can be found here: http://forums.contribs.org/viewtopic.php?t=25159

Assumptions: You are installing SQL-Ledger on a fresh (unmodified) install of SME 7.0.


1. Run yum to install all required packages:

yum --enablerepo=base --enablerepo=updates install postgresql postgresql-contrib postgresql-devel postgresql-docs postgresql-jdbc postgresql-libs postgresql-pl postgresql-python postgresql-test tetex-latex gcc

The above command will install everything needed including all dependencies.

2. Create and run the following bash script:


NOTE: The script will ask you for your IP address and subnet mask. You MUST enter both the IP address and subnet mask. The script DOES NOT transfer the default mask of 255.255.255.0


#!/bin/bash
#
/etc/init.d/postgresql start
# Create template directories
mkdir -p /etc/e-smith/templates/var/lib/pgsql/data
mkdir -p /etc/e-smith/templates-custom/var/lib/pgsql/data
# Copy original config file into template directory
cp /var/lib/pgsql/data/postgresql.conf /etc/e-smith/templates/var/lib/pgsql/data
cp /var/lib/pgsql/data/pg_hba.conf /etc/e-smith/templates/var/lib/pgsql/data
# Make modifications for this SME install
# This changes '#tcpip_socket = false' to 'tcpip_socket = true' whilst
# making the copy
sed '/#tcpip_socket/s/#tcpip_socket/tcpip_socket/;s/false/true/' \
/etc/e-smith/templates/var/lib/pgsql/data/postgresql.conf > \
/etc/e-smith/templates-custom/var/lib/pgsql/data/postgresql.conf
# This changes 'local all all ident sameuser' to '#local all all ident sameuser'
# whilst making the copy
sed -e '/local/s/local[ ]*all[ ]*all/#local all all/' \
/etc/e-smith/templates/var/lib/pgsql/data/pg_hba.conf > \
/etc/e-smith/templates-custom/var/lib/pgsql/data/pg_hba.conf
# ..and this adds some lines
echo ""
echo -n "Enter the IP address of this server (please get it right, there's no
checking!!) "
read ipstring
echo -n "Enter the IP mask of this server (probably 255.255.255.0) "
read maskstring
echo "host all all $ipstring $maskstring trust" >> /etc/e-smith/templates-custom/var/lib/pgsql/data/pg_hba.conf
echo "host all all 0.0.0.0 255.255.255.255 reject" >> /etc/e-smith/templates-custom/var/lib/pgsql/data/pg_hba.conf
#
# ..and these should not really be added - it's just for testing
echo "local all all trust" >> /etc/e-smith/templates-custom/var/lib/pgsql/data/pg_hba.conf
echo "host all all 127.0.0.1 255.255.255.255 trust" >> /etc/e-smith/templates-custom/var/lib/pgsql/data/pg_hba.conf
/sbin/e-smith/expand-template /var/lib/pgsql/data/pg_hba.conf
/sbin/e-smith/expand-template /var/lib/pgsql/data/postgresql.conf
# Just a symbolic link so that the actual postgress Java interfacec can be
# changed easily
ln -s /usr/share/java/pg74.1jdbc3.jar /usr/share/java/postgresql.jar
/etc/init.d/postgresql stop
/etc/init.d/postgresql start
# Enable automatic launching of postgres on system start
ln -s /etc/init.d/postgresql /etc/rc.d/rc7.d/S56postgresql
ln -s /etc/init.d/postgresql /etc/rc.d/rc6.d/K03postgresql

If you are copying and pasting, be carefull of the lines with ">>" in them. ie "echo "local all all trust" >> " due to wrapping in this post, the line may break in two, however, the entire line should be on one line with no line break or the script will have problems.


3. Update perl so that we can get Postgres connected to the SQL-Ledger application (this is where gcc is needed.)

perl -MCPAN -eshell
**(Lots of things happen here - just accept the defaults unless you know differntly!!)
cpan> install Bundle::CPAN
cpan> reload cpan
cpan> install MD5
cpan> install Storable
cpan> install DBI
**(Lots of things happen - check right at the end to see that the operation completed OK)
cpan> install DBD::Pg
**(Lots of things happen - check right at the end to see that the operation completed OK)
cpan> exit

4. Now we'll install the application


Use Server Manager to create the sql-ledger ibay.

**The rest of this howto assumes you have named the ibay sql-ledger.

cd /home/e-smith/files/ibays/sql-ledger/html
wget -nc http://www.sql-ledger.com/source/setup.perl
mv setup.perl setup.pl
perl setup.pl

- when asked, choose (i) to install from the internet.
- (type in 'www' as the internet user when asked)
**the setup routine will be unable to modify httpd.conf and will tell you what needs to be added. (The file /etc/httpd/conf/sql-ledger-httpd.conf will contain the bits that need to be added)

5. In order to make this installation SME standard, do the following....

mkdir -p /etc/e-smith/templates-custom/etc/httpd/conf/httpd.conf
cd /etc/e-smith/templates-custom/etc/httpd/conf/httpd.conf
pico 95sql-ledger
(insert the following ...)

Alias /sql-ledger/ /home/e-smith/files/ibays/sql-ledger/html/
<Directory /home/e-smith/files/ibays/sql-ledger/html>
AllowOverride All
AddHandler cgi-script .pl
Options ExecCGI Includes FollowSymlinks
Order Allow,Deny
Allow from All
</Directory>

<Directory /home/e-smith/files/ibays/sql-ledger/html/users>
Order Deny,Allow
Deny from All
</Directory>

(end of insert, hit CTRL/X to finish the edit)

- now expand the template and thus create a new httpd.conf file

/sbin/e-smith/expand-template /etc/httpd/conf/httpd.conf

- restart the web server

/etc/rc7.d/S86httpd-e-smith sigusr1

6. Create the default SQL-Ledger user and enable the plpgsql language ...

su - postgres -c "createuser -a -d sql-ledger"
su - postgres -c "createlang plpgsql template1"

7. Set permissions on users, templates, css and spool directories ...

chown -hR nobody:nogroup users templates css spool

8. Log on to http://<your-server>/sql-ledger/admin.pl with blank password


Back Howto