DB2 HOUSEKEEPING SUITE
======================
(copyleft) Alex Levy t/a Sustainable Software Ltd. http://www.sustainablesoftware.net/downloads.htm

This looks like a lot of stuff, but should take under an hour. Properly implemented, it will save you hundreds of hours.

The suite is assumed to run under DB2 instance owner credentials and will only run properly under Korn Shell.
1. cd to the instance home directory and unpack the DB2MAINTENANCE.tar.gz file
2. If you have not already done so, also unpack DB2FUNCTIONS.tar.gz into the $INSTHOME directory and follow the readme instructions under $INSTHOME/FUNCTIONS/1_README	
3. Runtime shell environment.
   This suite runs under the Korn Shell. There are sound practical and ideological reasons for this.
   If the instance owner does not already run ksh93:
   - as root (Linux): chsh -s /bin/ksh instanceowner # or /bin/ksh93, if /bin/ksh is not a symlink to ksh93; on AIX - use smitty to change the shell.
   - as the instance owner: set up $INSTHOME/.profile using $INSTHOME/MAINTENANCE/TEMPLATES/.profile.template 
   - logout and back in to take effect
4. mkdir -p -m 755 $INSTHOME/MAINTENANCE/log/work/LOBS 
5. mkdir -m 755 $INSTHOME/sqllib/db2dump/CFG
6. chmod 544  $INSTHOME/FUNCTIONS/F_* ; chmod 444 $INSTHOME/FUNCTIONS/1*
7. edit $INSTHOME/sqllib/userprofile adding the following lines
   (making substitutions for the instance and db names)
	export INSTHOME=$INSTHOME       # this export may be useful for shell scripts that have not yet dotted in the db2profile but wish to reference the variable
	export DB2INSTANCE=$DB2INSTANCE # ditto
	export DBALIAS=????????			# default database name; do not set this for multi-database instances.
									# Use the base name, not the alias as some utilities like db2pd only accept the base catalog name.
	export FPATH=${INSTHOME}/FUNCTIONS	# if this entry has not already been made following instructions at $FPATH/1_readme.
	# Maintenance scripts, log and work directories
	export MAINTENANCE_DIR=${INSTHOME}/MAINTENANCE
	export MAINTENANCE_LOGS=${MAINTENANCE_DIR}/log
	export MAINTENANCE_WORK=${MAINTENANCE_LOGS}/work
    # The next 2 values must be exported even if you do not run SQL replication
	export SQL_REPLICATION_SOURCE=0 # or 1 if this is a capture server
	export SQL_REPLICATION_TARGET=0 # or 1 if this is an apply server
	# Configuration capture directory
    export CFG_DIR=${INSTHOME}/sqllib/db2dump/CFG
8. edit $MAINTENANCE_DIR/TEMPLATES/ExportInoperativeViews.template: substitute the full expansion of $MAINTENANCE_WORK and $MAINTENANCE_WORK/LOBS to the export and lob paths respectively. 

9. logout and back in to take effect
10 There are specific customisations in the A_SETUP_REORGS_README file of the REORGS directory, which you must follow. 
11 There are also specific instructions in the A_SETUP_STATS_README file of the STATS directory, which you must follow. 

Legal Stuff
-----------
All code here is copyleft from http://www.sustainablesoftware.net/downloads.htm
Please respect copyleft conditions.
In particular:

- You keep comment lines specifying the original author and purpose in place.
- You comment any amendments to the original in a clearly marked amendment history.
- You do not sell or charge for it.
- Usual disclaimers: we accept no responsibility, give no warranty, no guarantees express or implied, at your own risk blaa blaa etc.
Alex Levy, Sustainable Software Ltd., June 2012.
Est modus in rebus - There is a method in all things.
