	 kź| cČ6cČ6’’’by name         by name         BUILD           d   	kźH      ķA                                                ./               ķA          ķA          
kź0 Åp`rm          Ø   cČ6cČ6cČ6             Ø       ./lpp_name               m          m          4 R I bos.docregister {
bos.docregister.com 04.03.0002.0000 01 N U en_US Docregister Common 
[
%
/usr/sbin 88
/usr/lib/objrepos 8
/usr/bin 24
INSTWORK 10 8
%
%
%
%
]
}
	kź\      ķA                                                ./usr            ķA          ķA          
kźŅ{      ķA                                                ./usr/lpp                ķA          ķA          kźÜx      ķA                                                ./usr/lpp/bos.docregister                ķA          ķA          kź g ’#`rm          	  < 6< 6< 6             	      ./usr/lpp/bos.docregister/liblpp.a               m          m          <aiaff>
2154        0           68          1992        0           263         454         0           906469435   2715        300         660         29  bos.docregister.com.copyright `
 Licensed Materials - Property of IBM

 5765C3403
   (C) Copyright International Business Machines Corp. 1998.

 All rights reserved.
 US Government Users Restricted Rights - Use, duplication or disclosure
 restricted by GSA ADP Schedule Contract with IBM Corp.

   27          584         68          888419542   2715        300         660         9   productid `
bos.docregister 5765-C3403
   1061        1768        454         906469435   2715        300         660         29  bos.docregister.com.inventory `
/usr/sbin:
          owner = bin
          group = bin
          mode = 755
          type = DIRECTORY
          class = apply,inventory,bos.docregister.com

/usr/sbin/index_config.sh:
          owner = bin
          group = bin
          mode = 555
          type = FILE
          class = apply,inventory,bos.docregister.com
          size = 19483
          checksum = "45228    20 "

/usr/sbin/index_unconfig.sh:
          owner = bin
          group = bin
          mode = 555
          type = FILE
          class = apply,inventory,bos.docregister.com
          size = 6519
          checksum = "05920     7 "

/usr/sbin/resolve_links:
          owner = bin
          group = bin
          mode = 555
          type = FILE
          class = apply,inventory,bos.docregister.com
          size = 11542
          checksum = "49834    12 "

/usr/bin/chdoclang:
          owner = bin
          group = bin
          mode = 555
          type = FILE
          class = apply,inventory,bos.docregister.com
          size = 9760
          checksum = "59436    10 "

   112         1992        584         906469435   2715        300         660         22  bos.docregister.com.al`
./usr/sbin
./usr/sbin/index_config.sh
./usr/sbin/index_unconfig.sh
./usr/sbin/resolve_links
./usr/bin/chdoclang
45          2154        1768        906469435   2715        300         660         24  bos.docregister.com.size`
/usr/sbin 88
/usr/lib/objrepos 8
/usr/bin 24
   190         0           1992        0           0           0           0           0   `
5           68          454         584         1768        1992        bos.docregister.com.copyright productid bos.docregister.com.inventory bos.docregister.com.al bos.docregister.com.size       
kź¤      ķA                                                ./usr/sbin               ķA          ķA          kźb: õDsm        L  : 6G66             L      ./usr/sbin/index_config.sh               m          m          #!/bin/ksh
# IBM_PROLOG_BEGIN_TAG 
# This is an automatically generated prolog. 
#  
# bos43K src/bos/docregister/bin/index_config.sh 1.9 
#  
# Licensed Materials - Property of IBM 
#  
# Restricted Materials of IBM 
#  
# (C) COPYRIGHT International Business Machines Corp. 1998 
# All Rights Reserved 
#  
# US Government Users Restricted Rights - Use, duplication or 
# disclosure restricted by GSA ADP Schedule Contract with IBM Corp. 
#  
# IBM_PROLOG_END_TAG 
# @(#)28	1.9  src/bos/docregister/bin/index_config.sh, docregister, bos43K, 9837C_43K 9/16/98 15:37:43
#
# Post install script for IMNSearch indexes
#       1) Registers the index with the search engine if possible
#       2) Adds an entry for the index in the lookup table
#
# script debug flag
# set -x
#
#
##############################################################################
#
# !!! DON'T CHANGE ANYTHING FROM HERE DOWN !!!
##############################################################################
dummy()
{
return
}

SetLocale() {
	#
	# Set the locale (based on the suffix of the index(es) being installed
	#	All indexes must be same locale
	#
	suffix=`echo "$indexdir_name_1" | awk '{print substr($0, length - 1)}'`
	case $suffix in
	'ca' | 'CA')			# Catalan
		LANG=ca_ES
		;;
	'de' | 'DE')			# German
		LANG=de_DE
		;;
	'en' | 'EN')			# English
		LANG=en_US
		;;
	'es' | 'ES')			# Spanish
		LANG=es_ES
		;;
	'fr' | 'FR')			# French
		LANG=fr_FR
		;;
	'it' | 'IT')			# Italian
		LANG=it_IT
		;;
	'pt' | 'PT')			# Portuguese (Brazil)
		LANG=pt_BR
		;;
	'sv' | 'SV')			# English
		LANG=sv_SE
		;;

	# ISO-8859-2
	'hu' | 'HU')			# Hungarian
		LANG=hu_HU
		;;
	'pl' | 'PL')			# Polish
		LANG=pl_PL
		;;
	'cs' | 'CS')			# Czech
		LANG=cs_CZ
		;;

	'ru' | 'RU')			# Russian
		LANG=ru_RU
		;;

	# Double byte locales
	'jp' | 'JP')			# Japanese
		LANG=Ja_JP
		;;
	'kr' | 'KR')			# Korean
		LANG=ko_KR
		;;
	'cn' | 'CN')			# Simplified Chinese
		LANG=zh_CN
		;;
	'tw' | 'TW')			# Traditional Chinese
		LANG=Zh_TW
		;;

	*)
		LANG=C			# Other
		;;
	esac

	export LANG
}


#
# ensure_enough_disk_space
#
# Return codes:
#	1 - File/directory given does not exist
#	2 - Can't parse the output of 'df' for free blocks
#	3 - Can't parse the output of 'df' for fileset
#	4 - Can't increase the size of filesystem
#
ensure_enough_disk_space() {

	sys_awk=/usr/bin/awk
	sys_df=/usr/bin/df
	sys_chfs=/usr/sbin/chfs


	filename=$1
	blocks_needed=$2
	inodes_needed=$3

	#
	# Filename must exist
	#
	if [ ! -e $filename ]; then
		return 1
	fi


	#
	# Do a 'df' on the filename given
	#
	$sys_df $filename 2> /dev/null > /dev/null
	rc=$?
	if [ $rc -ne 0 ]; then
		return $rc
	fi


	#
	# Get the amount of free 512 byte blocks from output of 'df'
	#
	free_512_byte_blocks=`$sys_df $filename | $sys_awk '/^\// {print $3}' | $sys_tail -1 2> /dev/null`
	if [ $? -ne 0 ]; then
		return 2
	fi
	#print "free_512_byte_blocks = $free_512_byte_blocks"


	#
	# Get the amount of free 512 byte blocks from output of 'df'
	#
	free_inodes=`$sys_df -v $filename | $sys_awk '/^\// {print $7}' | $sys_tail -1 2> /dev/null`
	if [ $? -ne 0 ]; then
		return 2
	fi
	#print "free_inodes = $free_inodes"


	#
	# Get filesystem path from output of 'df'
	#
	filesystem=`$sys_df $filename | $sys_awk '/^\// {print $7}' | $sys_tail -1 2> /dev/null`
	if [ $? -ne 0 ]; then
		return 3
	fi
	#print "filesystem = $filesystem"


	#
	# Do we need more space?
	#
	if [ $free_512_byte_blocks -le $blocks_needed -o $free_inodes -le $inodes_needed ]; then

		if [ $free_512_byte_blocks -le $blocks_needed ]; then
			additional_blocks_needed=`expr $blocks_needed - $free_512_byte_blocks`
		else
			additional_blocks_needed=`expr \( $inodes_needed - $free_inodes \) \* 1024`
		fi

		#print "Increasing size of filesystem '$filesystem'"

		#
		# Increase the size of the file system
		#
		$sys_chfs -a size=+$additional_blocks_needed $filesystem
		if [ $? -ne 0 ]; then
			exit 1
		fi
	fi

	return 0
} # END ensure_enough_disk_space


#
# main
#

system=`uname`
case "$system" in
	"AIX")	ECHO=echo
		netq_install_dir="/usr/IMNSearch"
		;;
	"HP-UX")ECHO=dummy
		netq_install_dir="/opt/IMNSearch"
		;;
	"SunOS")ECHO=dummy
		netq_install_dir="/opt/IMNSearch"
		;;
	*)	echo "Operating system not supported."
		exit 1
		;;
esac
umask 022
# directory where indexes are search by the engine
usr_index_dir="/usr/docsearch/indexes"
usr_dir="/usr/docsearch"

# directory for writeable file of the index
var_index_dir="/var/docsearch/indexes"
var_dir="/var/docsearch"

# lookup table file for all indexes
map_file="imnmap.dat"
#
# define system specific commands with full path
sys_ls="/usr/bin/ls"
sys_ln="/usr/bin/ln -sf"
sys_cp="/usr/bin/cp"
sys_rm="/usr/bin/rm"
sys_mkdir="/usr/bin/mkdir -p"
sys_chmod="/usr/bin/chmod"
sys_chown="/usr/bin/chown"
sys_grep="/usr/bin/grep"
sys_touch="/usr/bin/touch"
sys_tail="/usr/bin/tail"

# command to update the master table file
update_mt_sbcs="$netq_install_dir/cli/imnmtupd /etc/IMNSearch/data"
update_mt_dbcs="$netq_install_dir/cli/imqmtupd -m /etc/IMNSearch/dbcshelp"



# Count the number of indexes being installed
#
count=1
while [ ! -z "`eval echo \\$indexdir_name_$count`" ]
do
	count=`expr ${count} + 1`
done
num_indexes=`expr ${count} - 1`


#
# dependend on the index type, switch commands an environment
if [ $index_type = "SBCS" ]
then
	instance_name=imnhelp
	start_exe=/usr/bin/imnss
else
	if [ $index_type = "DBCS" ]
	then
		# set the correct environment
		if [ -x $netq_install_dir/bin/imq_env ]
		then
			. $netq_install_dir/bin/imq_env
		fi
		instance_name=dbcshelp
		start_exe=/usr/bin/imqss
	else
		/usr/bin/dspmsg -s 1 index_config.cat 1 "Either none or a wrong index_type has been specified ..."
		exit 1
	fi
fi

##########################
# initialize installation
##########################

if [ -e /tmp/index.pre_rm ]
then
	$sys_rm -f /tmp/index.pre_rm
fi


#
# Make sure there is enough space in /usr for a:
#	/usr/docsearch
#	/usr/docsearch/indexes
#
#	For each index:
#	/usr/docsearch/indexes/<indexname>
#	/usr/docsearch/indexes/<indexname>/data
#	/usr/docsearch/indexes/<indexname>/data/* (links)
#	/usr/docsearch/indexes/<indexname>/work (link)
#
#	/usr/docsearch/indexes/imnmap.dat (just adding one line)
#
space_needed=`expr ${num_indexes} \* 512`
inodes_needed=`expr ${num_indexes} \* 20`
ensure_enough_disk_space /usr $space_needed $inodes_needed

# create /usr/docsearch if it does not exist
if [ ! -d $usr_index_dir ]
then
	# create /usr/docsearch/indexes
	$sys_mkdir $usr_index_dir
	if [ $? -ne 0 ]
	then
		/usr/bin/dspmsg -s 1 index_config.cat 2 "Error creating directory %s !" "$usr_index_dir"
		/usr/bin/dspmsg -s 1 index_config.cat 3 "Exiting ..."
		exit 1
	fi
fi


#
# Make sure there is enough space in /var
#
ensure_enough_disk_space /var $space_needed $inodes_needed

# create /var/docsearch if it does not exist
if [ ! -d $var_index_dir ]
then
	# create /var/docsearch/indexes
	$sys_mkdir $var_index_dir
	if [ $? -ne 0 ]
	then
		/usr/bin/dspmsg -s 1 index_config.cat 2 "Error creating directory $var_index_dir !" "$var_index_dir"
		/usr/bin/dspmsg -s 1 index_config.cat 3 "Exiting ..."
		exit 1
	fi
fi

# if search service is installed, stop it
if [ -x $start_exe ]
then
	# Stop the Search engine
	$start_exe -stop $instance_name > /dev/null

	# change the ownership of the /var/docsearch directories
	$sys_chown -R imnadm:imnadm $var_dir
	if [ $? -ne 0 ]
	then
		/usr/bin/dspmsg -s 1 index_config.cat 4 "Error changing ownership of /var/docsearch directories !"
		/usr/bin/dspmsg -s 1 index_config.cat 3 "Exiting ..."
		exit 1
	fi
fi

# Make sure lookup table is same in /var and /usr
#	If /var/docsearch/indexes/$map_file exists,
if [ -f $var_index_dir/$map_file ]
then
	# Copy it over (force) /usr/docsearch/indexes/$map_file
	$sys_cp -f $var_index_dir/$map_file $usr_index_dir/$map_file
	if [ $? -ne 0 ]
	then
		/usr/bin/dspmsg -s 1 index_config.cat 5 "Could not copy $var_index_dir/$map_file over $usr_index_dir/$map_file !" "$var_index_dir" "$map_file" "$usr_index_dir"
		/usr/bin/dspmsg -s 1 index_config.cat 3 "Exiting...."
		exit 1
	fi

# If /var/docsearch/indexes/$map_file does not exist,
#	 If /usr/docsearch/indexes/$map_file exists,
elif [ -f $usr_index_dir/$map_file ]
then
	# Copy it to /var/docsearch/indexes/$map_file
	$sys_cp $usr_index_dir/$map_file $var_index_dir/$map_file
	if [ $? -ne 0 ]
	then
		/usr/bin/dspmsg -s 1 index_config.cat 6 "Could not copy $usr_index_dir/$map_file to $var_index_dir/$map_file !" "$usr_index_dir" "$map_file" "$var_index_dir" "$map_file"
		/usr/bin/dspmsg -s 1 index_config.cat 3 "Exiting...."
		exit 1
	fi
fi

# check if there is an existing configuration and save it
if [ -f $var_index_dir/$map_file ]
then
	# Copy /var/docsearch/indexes/$map_file to /tmp/$map_file.tmp
	$sys_cp $var_index_dir/$map_file /tmp/$map_file.tmp
	if [ $? -ne 0 ]
	then
		/usr/bin/dspmsg -s 1 index_config.cat 3 "Could not copy $var_index_dir/$map_file to /tmp/$map_file.tmp !" "$var_index_dir" "$map_file" "/tmp" "$map_file.tmp"
		/usr/bin/dspmsg -s 1 index_config.cat 3 "Exiting...."
		exit 1
	fi
fi


# Register every index in the lookup table
# If search service is installed,
#	Register every index with the search service
#
# arrays start with offset 1     DO NOT CHANGE
count=1

while [ ! -z "`eval echo \\$indexdir_name_$count`" ]
do
	indexdir_name="`eval echo \\$indexdir_name_$count`"
	indexname=`echo $indexdir_name | tr "[:lower:]" "[:upper:]"`
	document_loc="`eval echo \\$document_loc_$count`"
	index_loc="`eval echo \\$index_loc_$count`"
	index_title="`eval echo \\$index_title_$count`"

	# File used to record the state of the pre-install process
	state_file="$usr_index_dir/$indexdir_name.state"

	#
	# Change state to indicate:
	#	Start of index registration
	#
	$sys_touch $state_file
	if [ $? -ne 0 ]
	then
		/usr/bin/dspmsg -s 1 index_config.cat 7 "Error creating state file, you may need to increase the space allocated for the /usr fileset."
		/usr/bin/dspmsg -s 1 index_config.cat 3 "Exiting ..."
		exit 1
	fi


	# Add an entry in the lookup table for the index
	if [ -f /tmp/$map_file.tmp ]
	then
		found=`$sys_grep ^\"$indexname\" /tmp/$map_file.tmp`
		if [ ! -z "$found" ]
		then
			/usr/bin/dspmsg -s 1 index_config.cat 23 "\n\
Cannot install the document $index_title and its search index $indexname.\n\
\n\
There is already an index on this system with the same name as the index\n\
your are trying to install.  The new index cannot be installed since\n\
installation would overwrite and destroy the index that is already on this\n\
system.  If you are sure that you want to install this new index, go to the\n\
Documentation Search Service chapter in the AIX System Management Guide.\n\
Find the Updating Documents instruction section and just do steps 1 and 2\n\
(do not do step 3) to delete the existing index.  Then install the new\n\
document and its index.\n" "$index_title" "$indexname"


			$sys_rm /tmp/$map_file.tmp
			exit 1
		fi

		# Set the locale to that of the indexes so characters output correctly
		SetLocale

		# if regular entry: use "\n" as separator in dataline
		echo "\n\"$indexname\",\"$document_loc\",\"$index_title\"\c" >> /tmp/$map_file.tmp
	else
		# Set the locale to that of the indexes so characters output correctly
		SetLocale

		# if first entry: DO NOT USE "\n" as separator in dataline
		echo "\"$indexname\",\"$document_loc\",\"$index_title\"\c" >> /tmp/$map_file.tmp
	fi

	if [ $? -ne 0 ]
	then
		/usr/bin/dspmsg -s 1 index_config.cat 8 "Error creating entry in lookup table !"
		/usr/bin/dspmsg -s 1 index_config.cat 3 "Exiting ..."
		exit 1
	fi


	#
	# Change state to indicate:
	#	successful modification of TEMPORARY lookup table file
	#
	$sys_rm -f $state_file
	if [ $? -ne 0 ]
	then
		/usr/bin/dspmsg -s 1 index_config.cat 9 "Error removing state file!"
		/usr/bin/dspmsg -s 1 index_config.cat 3 "Exiting ..."
		exit 1
	fi


	# create work directory under /var/docsearch/indexes
	$sys_mkdir $var_index_dir/$indexdir_name/work
	if [ $? -ne 0 ]
	then
		/usr/bin/dspmsg -s 1 index_config.cat 10 "Error creating index work directory $var_index_dir/$indexdir_name/work !" "$var_index_dir" "$indexdir_name"
		/usr/bin/dspmsg -s 1 index_config.cat 3 "Exiting ..."
		exit 1
	fi


	# create data directory under /var/docsearch/indexes
	$sys_mkdir $var_index_dir/$indexdir_name/data
	if [ $? -ne 0 ]
	then
		/usr/bin/dspmsg -s 1 index_config.cat 11 "Error creating index data directory $var_index_dir/$indexdir_name/data !" "$var_index_dir" "$indexdir_name"
		/usr/bin/dspmsg -s 1 index_config.cat 3 "Exiting ..."
		exit 1
	fi


	# copy im?iq.dat file to /var/docsearch/indexes/<index>/data 
	$sys_cp $index_loc/$indexdir_name/data/im?iq.dat $var_index_dir/$indexdir_name/data
	if [ $? -ne 0 ]
	then
		/usr/bin/dspmsg -s 1 index_config.cat 12 "Error copying index files to directory $var_index_dir/$indexdir_name/data !" "$var_index_dir" "$indexdir_name"
		/usr/bin/dspmsg -s 1 index_config.cat 3 "Exiting ..."
		exit 1
	fi

	# copy im?admtb.dat file to /var/docsearch/indexes/<index>/data 
	$sys_cp $index_loc/$indexdir_name/data/im?admtb.dat $var_index_dir/$indexdir_name/data
	if [ $? -ne 0 ]
	then
		/usr/bin/dspmsg -s 1 index_config.cat 12 "Error copying index files to directory $var_index_dir/$indexdir_name/data !" "$var_index_dir" "$indexdir_name"
		/usr/bin/dspmsg -s 1 index_config.cat 3 "Exiting ..."
		exit 1
	fi


	#
	# If the index was not installed in /usr/docsearch/indexes (or /usr/docsearch/indexes/)
	#	build links from there to install location
	#
	if [ $index_loc != $usr_index_dir -a $index_loc != $usr_index_dir/ ]
	then
		# create data directory under /usr/docsearch/indexes
		$sys_mkdir $usr_index_dir/$indexdir_name/data
		if [ $? -ne 0 ]
		then
			/usr/bin/dspmsg -s 1 index_config.cat 11 "Error creating index data directory $usr_index_dir/$indexdir_name/data !" "$usr_index_dir" "$indexdir_name"
			/usr/bin/dspmsg -s 1 index_config.cat 3 "Exiting ..."
			exit 1
		fi


		# link all data files
		$sys_ln $index_loc/$indexdir_name/data/* $usr_index_dir/$indexdir_name/data
		if [ $? -ne 0 ]
		then
			/usr/bin/dspmsg -s 1 index_config.cat 13 "Error linking index data files $usr_index_dir/$indexdir_name/data/* to $var_index_dir/$indexdir_name/data !" "$usr_index_dir" "$indexdir_name" "$var_index_dir"
			/usr/bin/dspmsg -s 1 index_config.cat 12 "Error copying index files to directory !"
			/usr/bin/dspmsg -s 1 index_config.cat 3 "Exiting ..."
			exit 1
		fi
	fi

	# link /usr/docsearch/indexes/<index>/work to /var/docsearch/indexes/<index>/work
	$sys_ln $var_index_dir/$indexdir_name/work $usr_index_dir/$indexdir_name/work
	if [ $? -ne 0 ]
	then
		/usr/bin/dspmsg -s 1 index_config.cat 14 "Error linking index work directory $usr_index_dir/$indexdir_name/work to $var_index_dir/$indexdir_name/work !" "$usr_index_dir" "$indexdir_name" "$var_index_dir"
		/usr/bin/dspmsg -s 1 index_config.cat 3 "Exiting ..."
		exit 1
	fi

	# link /usr/docsearch/indexes/<index>/data/im?iq.dat to /var/docsearch/indexes/<index>/data/im?iq.dat
	# will overwrite link to index install location
	$sys_ln $var_index_dir/$indexdir_name/data/im?iq.dat $usr_index_dir/$indexdir_name/data
	if [ $? -ne 0 ]
	then
		/usr/bin/dspmsg -s 1 index_config.cat 15 "Error linking index im?iq.dat $usr_index_dir/$indexdir_name/data/im?iq.dat to $var_index_dir/$indexdir_name/data/im?iq.dat !" "$usr_index_dir" "$indexdir_name" "$var_index_dir"
		/usr/bin/dspmsg -s 1 index_config.cat 3 "Exiting ..."
		exit 1
	fi

	# link /usr/docsearch/indexes/<index>/data/im?admtb.dat to /var/docsearch/indexes/<index>/data/im?admtb.dat
	# will overwrite link to index install location
	$sys_ln $var_index_dir/$indexdir_name/data/im?admtb.dat $usr_index_dir/$indexdir_name/data
	if [ $? -ne 0 ]
	then
		/usr/bin/dspmsg -s 1 index_config.cat 16 "Error linking index im?admtb.dat $usr_index_dir/$indexdir_name/data/im?admtb.dat to $var_index_dir/$indexdir_name/data/im?admtb.dat !" "$usr_index_dir" "$indexdir_name" "$var_index_dir"
		/usr/bin/dspmsg -s 1 index_config.cat 3 "Exiting ..."
		exit 1
	fi


	# change the ownership of the /var index directories
	#       Will do nothing if IMNSearch is not installed
	#
	if [ -x $start_exe ]
	then
		# copy work file to work directory
		$sys_cp /etc/IMNSearch/imnkeep.it $var_index_dir/$indexdir_name/work
		if [ $? -ne 0 ]
		then
			/usr/bin/dspmsg -s 1 index_config.cat 17 "Error copying index work files to directory $var_index_dir/$indexdir_name/work !" "$var_index_dir" "$indexdir_name"
			/usr/bin/dspmsg -s 1 index_config.cat 3 "Exiting ..."
			exit 1
		fi

		# change the ownership of the /var index directories
		$sys_chown -Rh imnadm:imnadm $var_index_dir/$indexdir_name
		if [ $? -ne 0 ]
		then
			/usr/bin/dspmsg -s 1 index_config.cat 18 "Error changing ownership of $var_index_dir/$indexdir_name !" "$var_index_dir" "$indexdir_name"
			/usr/bin/dspmsg -s 1 index_config.cat 3 "Exiting ..."
			exit 1
		fi

		# change the permissions of the /var index data files
		$sys_chmod -R 640 $var_index_dir/$indexdir_name/data/*
		if [ $? -ne 0 ]
		then
			/usr/bin/dspmsg -s 1 index_config.cat 19 "Error changing permission of index files !"
			/usr/bin/dspmsg -s 1 index_config.cat 20 "Error changing permission of $var_index_dir/$indexdir_name/data/im*.dat !" "$var_index_dir" "$indexdir_name"
			/usr/bin/dspmsg -s 1 index_config.cat 3 "Exiting ..."
		exit 1
		fi

		# change the permissions of the /var/docsearch index work files
		$sys_chmod -R 640 $var_index_dir/$indexdir_name/work/imnkeep.it
		if [ $? -ne 0 ]
		then
			/usr/bin/dspmsg -s 1 index_config.cat 20 "Error changing permission of $var_index_dir/$indexdir_name/work/imnkeep.it !" "$var_index_dir" "$indexdir_name"
			/usr/bin/dspmsg -s 1 index_config.cat 3 "Exiting ..."
		exit 1
		fi

		# Register the index with the search engine
		if [ $index_type = "SBCS" ]
		then
			$update_mt_sbcs $indexname $usr_index_dir/$indexdir_name/data $usr_index_dir/$indexdir_name/work > /dev/null
		else
			$update_mt_dbcs -n $indexname -i $usr_index_dir/$indexdir_name/data -w $usr_index_dir/$indexdir_name/work > /dev/null
		fi
	fi

	count=`expr ${count} + 1`
done

if [ -d $var_index_dir ]
then
	# 
	$sys_cp /tmp/$map_file.tmp $var_index_dir/$map_file
	if [ $? -ne 0 ]
	then
		/usr/bin/dspmsg -s 1 index_config.cat 21 "Could not copy $var_index_dir/$map_file !" "$var_index_dir" "$map_file"
		/usr/bin/dspmsg -s 1 index_config.cat 3 "Exiting...."
		exit 1
	fi

        # Make sure lookup table is same in /var and /usr
        # Copy it over (force) /usr/docsearch/indexes/$map_file
        $sys_cp -f $var_index_dir/$map_file $usr_index_dir/$map_file
        if [ $? -ne 0 ]
        then
                /usr/bin/dspmsg -s 1 index_config.cat 5 "Could not copy $var_index_dir/$map_file over $usr_index_dir/$map_file !" "$var_index_dir" "$map_file" "$usr_index_dir"
                /usr/bin/dspmsg -s 1 index_config.cat 3 "Exiting...."
                exit 1
        fi

	if [ -x $start_exe ]
	then
		# change the ownership of the lookup table
		$sys_chown imnadm:imnadm $var_index_dir/$map_file
		if [ $? -ne 0 ]
		then
			/usr/bin/dspmsg -s 1 index_config.cat 22 "Error changing permissions on file $var_index_dir/$map_file!" "$var_index_dir" "$map_file"
			/usr/bin/dspmsg -s 1 index_config.cat 3 "Exiting...."
			exit 1
		fi
	fi
fi

#Every thing is ok, now delete tmp file
if [ -f /tmp/$map_file.tmp ]
then
	$sys_rm /tmp/$map_file.tmp
fi

# if search service is installed, start it again
if [ -x $start_exe ]
then
	# Stop the Search engine
	$start_exe -start $instance_name > /dev/null
fi
exit 0
ng ..kźģŗ öDsm        w  : 6"Iš4ųąŃ5             w      ./usr/sbin/index_unconfig.sh             m          m          #!/bin/ksh
# @(#)29	1.1  src/bos/docregister/bin/index_unconfig.sh, docregister, bos43D, 9808A_43D 2/11/98 10:00:23

##############################################################################
#
# !!! DON'T CHANGE ANYTHING FROM HERE DOWN !!!
##############################################################################
dummy()
{
return
}

system=`uname`
case "$system" in
	"AIX")	ECHO=echo
		netq_install_dir="/usr/IMNSearch"
		;;
	"HP-UX")ECHO=dummy
		netq_install_dir="/opt/IMNSearch"
		;;
	"SunOS")ECHO=dummy
		netq_install_dir="/opt/IMNSearch"
		;;
	*)	echo "Operating system not supported."
		exit 1
		;;
esac
umask 022

# directory where indexes are search by the engine
usr_index_dir="/usr/docsearch/indexes"
usr_dir="/usr/docsearch"

# directory for writeable file of the index
var_index_dir="/var/docsearch/indexes"
var_dir="/var/docsearch"

# lookup table file for all indexes
map_file="imnmap.dat"

#
# define system specific commands with full path
sys_ls="/usr/bin/ls"
sys_cp="/usr/bin/cp"
sys_rm="/usr/bin/rm"
sys_grep="/usr/bin/grep"
sys_awk="/bin/awk"

# command to delete index
del_idx_sbcs="$netq_install_dir/cli/imnixdel"
del_idx_dbcs="$netq_install_dir/cli/imqixdel"

#
# dependend on the index type, switch commands an environment
if [ $index_type = "SBCS" ]
then
	del_idx_cmd=$del_idx_sbcs
	instance_name=imnhelp
	start_exe=/usr/bin/imnss
else
	if [ $index_type = "DBCS" ]
	then
		# set the correct environment
		if [ -x $netq_install_dir/bin/imq_env ]
		then
			. $netq_install_dir/bin/imq_env
		fi
		del_idx_cmd=$del_idx_dbcs
		instance_name=dbcshelp
		start_exe=/usr/bin/imqss
	else
		/usr/bin/dspmsg -s 2 index_config.cat 1 "Either none or a wrong index_type has been specified ..."
		exit 1
	fi
fi


# Will do nothing if IMNSearch is not installed
if [ -x $start_exe ]
then
	# Start the Search engine
	$start_exe -start $instance_name > /dev/null
fi


# arrays start with offset 1	DO NOT CHANGE
count=1

while [ ! -z "`eval echo \\$indexdir_name_$count`" ]
do
	indexdir_name="`eval echo \\$indexdir_name_$count`"
	indexname=`echo $indexdir_name | tr "[:lower:]" "[:upper:]"`

	# File used to record the state of the pre-install process
	state_file="$usr_index_dir/$indexdir_name.state"

        #
        # Check state of installation:
        #       If state_file exists, index registration did not occur, so quit
        #
        if [ -e $state_file ]
	then
		$sys_rm -f $state_file
		if [ $? -ne 0 ]
		then
			/usr/bin/dspmsg -s 2 index_config.cat 2 "Error removing state file!"
			/usr/bin/dspmsg -s 2 index_config.cat 3 "Exiting ...."
			exit 1
		fi
		exit 0
	fi


	# If there is a lookup table
	if [ -f $var_index_dir/$map_file ]
	then
		if [ -f $var_index_dir/$map_file.tmp ]
		then
			# this is a cleanup of a failed installation
			$sys_cp $var_index_dir/$map_file.tmp $var_index_dir/$map_file
			$sys_rm $var_index_dir/$map_file.tmp
		fi

		# save the config file before doing any work
		$sys_cp $var_index_dir/$map_file $var_index_dir/$map_file.tmp
		if [ $? -ne 0 ]
		then
			$sys_rm $var_index_dir/$map_file.tmp
			/usr/bin/dspmsg -s 2 index_config.cat 4 "Could not create $var_index_dir/$map_file.tmp !" "$var_index_dir" "$map_file.tmp"
			/usr/bin/dspmsg -s 2 index_config.cat 3 "Exiting...."
			exit 1
		fi
	fi


	# Will do nothing if IMNSearch is not installed
	if [ -x $start_exe ]
	then
		# Deregister the index with the search engine
		$del_idx_cmd $indexname > /dev/null
	fi

	# delete created directories if they still exist
	if [ -d $var_index_dir/$indexdir_name ]
	then
		$sys_rm -rf $var_index_dir/$indexdir_name
	fi

	# remove /usr directory structure if still existing
	if [ -d $usr_index_dir/$indexdir_name ]
	then
		$sys_rm -rf $usr_index_dir/$indexdir_name
	fi

	# Is there a temporary lookup table?
	if [ -f $var_index_dir/$map_file.tmp ]
	then
		# delete the entry in the lookup table for the index
		$sys_awk -v indexname=\"$indexname\" ' \
			BEGIN	{ \
					FS=","; \
					first=1; \
					ORS=""; \
					OFS=""; \
				} \
				{ \
					if ($1 != indexname) { \
						if (first == 1) { \
							print $0; \
							first=0 \
						} else { \
							print "\n", $0 \
						} \
					} \
				} \
			' $var_index_dir/$map_file.tmp > $var_index_dir/$map_file

		if [ $? -ne 0 ]
		then
			$sys_cp $var_index_dir/$map_file.tmp $var_index_dir/$map_file
			/usr/bin/dspmsg -s 2 index_config.cat 5 "Error removing entry from mapping table file $var_index_dir/$map_file !" "$var_index_dir" "$map_file"
			/usr/bin/dspmsg -s 2 index_config.cat 6 "Kept old file. Exiting ...."
			exit 1
		fi

		# Is the lookup table now empty?  If so, delete it.
		if [ ! -s $var_index_dir/$map_file ]
		then
			$sys_rm -f $var_index_dir/$map_file
			$sys_rm -f $usr_index_dir/$map_file
		else
			# Make sure lookup table is same in /var and /usr
			# Copy it over (force) /usr/docsearch/indexes/$map_file
			$sys_cp -f $var_index_dir/$map_file $usr_index_dir/$map_file
			if [ $? -ne 0 ]
			then
				/usr/bin/dspmsg -s 2 index_config.cat 7 "Could not copy $var_index_dir/$map_file over $usr_index_dir/$map_file !" "$var_index_dir" "$map_file" "$usr_index_dir"
				/usr/bin/dspmsg -s 2 index_config.cat 3 "Exiting...."
				exit 1
			fi
		fi

		# Every thing is ok, now remove tmp file
		if [ -f $var_index_dir/$map_file.tmp ]
		then
			$sys_rm $var_index_dir/$map_file.tmp
		fi
	fi

	count=`expr ${count} + 1`
done



# Does the /var/docsearch directory exist?
if [ -d $var_dir ]
then

	# Does the /var/docsearch/indexes directory exist?
	if [ -d $var_index_dir ]
	then
		# Are we the last index to be uninstalled?
		if [ ! -f $var_index_dir/$map_file ]
		then
			/usr/bin/dspmsg -s 2 index_config.cat 8 "Deleting $var_index_dir" "$var_index_dir"
			$sys_rm -rf $var_index_dir
		fi
	fi

	if [ -z "`$sys_ls -A $var_dir`" ]
	then
		/usr/bin/dspmsg -s 2 index_config.cat 3 "Deleting $var_dir" "$var_dir"
		$sys_rm -rf $var_dir
	fi
fi


# Does the /usr/docsearch directory exist?
if [ -d $usr_dir ]
then
	# Does the /usr/docsearch/indexes directory exist?
	if [ -d $usr_index_dir ]
	then
		# Are we the last index to be uninstalled?
		# If the /usr/docsearch/indexes directory is now empty, delete it
		if [ -z "`$sys_ls -A $usr_index_dir`" ]
		then
			/usr/bin/dspmsg -s 2 index_config.cat 8 "Deleting $usr_index_dir" "$usr_index_dir"
			$sys_rm -rf $usr_index_dir
		fi
	fi

	# if the /usr/docsearch directory is now empty, delete it
	if [ -z "`$sys_ls -A $usr_dir`" ]
	then
		/usr/bin/dspmsg -s 2 index_config.cat 8 "Deleting $usr_dir" "$usr_dir"
		$sys_rm -rf $usr_dir
	fi
fi

exit 0
 kźņ¢ ÷Dsm        -  : 6¢’ž5’5             -      ./usr/sbin/resolve_links .sh             m          m          ß 5ž’¢         H   ø  	x    Ø        ¼        1L                      .text         ø                   .data             	x  ø               @.bss      	x  	x                     .loader           ę  (0                   " $|nx|#x|°+x|ų Ā  ā 1  B (9   e)-  *  @ H  `   H  ā 0H A |nxA   A |	¦Q N!A ā 89   }Ćsx}ä{x~x  H i`   ā ,  A b  H qA |      @       ¬ __start   b |¦,  !’Ą HA Ąc  A }h¦c C N !A b ,  A   c |¦C N !A b ,  A   c |¦C N !A b ,  A   c |¦C N !A b ,  A   c |¦C N !A  H8! @}¦N  8! @N         A      Ü __threads_init  , 4A   L |	¦N               ¾”’Ō|¦ā < !’`~  `  :   ;  8æPH ©A ,’’A äb D;@ " H Lā P, ?, d/ e/ v8w @A `A <A @ X[  ,  8ĄH  P  ,   @ 8X  ,  8ĄA LH  4  ,   @ Y  ,  8ĄA ,H  ; ,  8ĄA H )A 8` H EA cĆ  c¤  8æXH įA ,’’A , ?, d/ e/ v8w @K’’Lb L  ,   @tb H  ,   @d8æ`8db \H A 8b d¢ \H ńA b dH A ,  A   P8ø0` @H yA 8` H -8ß8db d¢ \H ©A b dH ÅA ,  A   P8ģ0` @H 1A 8` H å8¤8H ¹A ,   p|  @ ( P8æØ8l0` @H ńA 8` H „|  8ø¢ dH A ,’’AXb xB P" |b d8¼H ”A ,  {  8ø8æĄ@ 8z @H A 8` H E{  8ŠH iA ,  ;   8ŌA 08`  H MA ; ,  , 8ŌLB#BA 8`  K’’Ü,  A H EA |xyAMļ{8`  8ŲH A ,  8`  8ÜA dH éA H 	A |wyAMMļ{8`  8ąH ÅA ,  A 0H ŻA |vyA!Mļ{Ł  c  bä  bÅ  H ły  |  8ä¢ dH UA ,’’A b d8¼K’žÄ|  H ­A ¼  b   |š @ 8W:|3 ’ü8`   H Ż; |š `{  @  K’’čH  8č8`  H µ`{  8æģ8b dH QA b dH mA ,  A ÄĀ Pb \8(»  H %A b d8P¢ \H A b dH -A ,  »  8~ @8|A H A 8` H Mb d8ü¢ \8ßH ÉA b dH åA ,  8~ @8Ä8æ,A H QA 8` H { b \,  8(A »  K’’T8L8<H ½A ,   p|  @ ( P8æP80` @H õA 8` H ©|  8`¢ dH ”A ,’’A Ā x¢ Pb d8dH ©A ,  ~  8X8æh@ 8} @H A 8` H M~  H A ,  ~  @ H Ł~  H  e|  8x¢ dH !A ,’’b d8d@’8`  H ż x8! p}¦ŗ”’Ō8`  N         A       Ų main0 ¾!’Ä|¦} &Ā <ā D    !’p,   a H;¾ T;  ;`  ;@  A 8~ \ HH %A 8 ta HH MA ,  " y  @ 0 P8 x0` @” HH A  8! }¦»!’äN  8 Ø8~ H A ,   x  @ $ P8¾ ¬8p0` @H 9A 8` H ķa HH =A |wyAMļ{8 Ąbć  H łA ,  @  a HH  8! }¦ŗį’ÜN  :ą  8`  8 ÄH ĮA :÷ , |dy8`  LB#BA 8 ÄK’’Ü8a @H =`     c·   4 ’’ y  @ H !A ,’’`v  AąH     8   d  ,’’`v  AĄ d-  2   Lb HB |  bĆ  H õA   | @A c·  A4  | @@(bć   :÷ ,   @  b d 4 ’’ y  @ H uA , :.’’A øH     8   d  , :.’’A AÄ|Ø@@ :ū’’  w  ;{ 4 ’’H  A lAw  ;{ 4 ’’ y  @  H õA |Ø@, :  .’’H  $  8   d  |Ø@, :  .’’A’ A A4A0|Ø@A(    b dH åA   8` :H ­A b dH ńA |wyA5Mļ{  b d 4 ’’ y  @ H IA , :.’’A øH     8   d  , :.’’A A|Ø@@ :Ū’’  v  ;{ 4 ’’H  A lAlv  ;{ 4 ’’ y  @  H ÉA |Ø@, :  .’’H  $  8   d  |Ø@, :  .’’A’ A AA|Ø@Aü    b dH ¹A   8` :H A b dH ÅA |{yA	Mļ{  ø  8` >8Ą H Į,  @¤  ,   A :Ą bć  H A H  h  ,   A :Ą  bć  H aA H  HŅ  8a @bä  ce  H , `v  @ Ņ  8a @bä  ce  H er  bć  H A cc  H A   ø  8` <8Ą H |{y@ų   4 ’’ y  @ H YA `w  ,’’AĢH    8   ä  ,’’A°, A, !. aALF³A  a HH 	};` ,  ,  A øH  :   ,  ,  A ¤A ¤;@   8` <8   8Ą  H e.  @8  ø  8` >8Ą H I.  @  8` >8   8Ą  H -.  @   ø  8~ Č8Ą  H |{yN   @ ą  8~ ŌH ±A c·     4 ’’H  ŲA 4  bć  H aA c·     4 ’’ y  @ ÄH  °;@   8~ ÜH UA   ø  8` >8Ą H .  @ X  8~ äH )A   ø  8~ č8Ą  H É|{yN   @ (  8~ šH łA c·     4 ’’H   a HH łH  Xc·     4 ’’ y  @ H eA `v  H    8   Ä  ,’’A   bĆ  K’śh.  x  H 
ÉA   y  H 
¹A   @ Ō,  A “8¾ ü8b dĮ HH 	”A b dH 	½A ,  A $ P80` @” HH 	%A 8` H Ł  ,   A t8~0H 
mA   |¦8! } H  d:  K’ża HH éx  H 
A   y  H 
A   H    ,   A 8~@H 
	A   |¦8! } ŗ!’ÄN         C        ProcessFile0  æ!’ä|¦} & `    `¾  ,    !’ `Ż  .  `  ;`  " <A š   4 ’’ 8 c  @  H 
A `z  ,’’,  A |H    D  ,’’,  A d|Ų®| @@ ;{ |Ų®,   A H  lA Hce  A ,cĆ  8 L`¦  cē  H A cC  cÄ  H 
IA   ;`  H  $8` H  `cC  A cÄ  H 
!A |Ų®,   A    4 ’’ 8 K’’,,  A ,  cć  cÄ  A H 
A 8`   h d|¦8! `} »!’äN         C       l ReadTillStringæ’š|¦`      4 ’’ T~>!’°`½  `Ü  cć  8 @ H 	-A H    d  |š@,’’A ģ,  A ģæ  c¤  8 A lH  A ĢH 	A    4`’’ 8 cć  @ H ÉA |š@,’’c¤  H    d  |š@,’’c¤  @’¬A t8` H  Øcć  H  A `cć   4’’ @ $H mA |š@æ  ,’’8 @’ŠH     e  |š@æ  ,’’8 @’°A 8` H  @,  @ 8`  X8! P}¦»’šN  A ,  c¤  A H A 8`   X8! P}¦»’šN         A        ReadTillChar0 į’ü|¦|ß3y !’0a “ ø” ¼@ \ <b d0” “Į øį ¼H %A 8 @b dH A ,  A 8`   Ų8! Š}¦į’üN  8` H  “  H 	`   ,  a ø@ 4 H ń`   ,  a ¼@  H Ł`   ,  8` A l <b d0@@ H” “Į øį ¼H A 8 @b dH aA ,  A’x8`   Ų8! Š}¦į’üN  ß a “ ø” ¼K’žŁ Ų8! Š}¦į’üN         A       @ IsBookInstalled0  æĮ’ų|¦|ß3y !’ a @ D” HA H  H ł`   ,  a D@ , H į`   ,  a H@  H É`   ,  @ |8` H åA |~yAMļ{ž a @H 9A |`y~  AyMļ{a DH A |`y~ A]Mļ{a HH A |`y~ AAMļ{cĆ  H  8a @ D” H@ ß K’’  h8! `}¦cć  į’üN   h8! `}¦»Į’ųN         A       ( AddBook0  æ”’ō|¦`   !’°`  8` H ķA |}yA ”Mļ{Ż  ż c£   X8! P}¦»”’ōN         A        P 	AddLocale0|¦!’Ą H P <`e  8č0` @H ŃA  H8! @}¦N         A         8 
ParseError|¦!’Ą Hb P <8c @0 8H }A 8` H  1 H8! @}¦N         A      < 
AllocError|¦ pį’ü !’°a @d  ,  A H ]A ā <b d8|cå  H UA b dH qA  ød  ,  A H !A 8æ 8 b dH A b dH 9A  d  ,  A H éA  d  ,  A H ŃA 8æ $8Äb dH  ĶA b dH  éA a @H  A  X8! P}¦į’üN         A        ų finish     @A   L |	¦N                TA   L |	¦N                XA   L |	¦N                `A   L |	¦N                hA   L |	¦N                lA   L |	¦N                tA   L |	¦N                A   L |	¦N                A   L |	¦N                A   L |	¦N                A   L |	¦N                       b  8   q A (|¦| "+| *M  |¤+|£*0   @’ōN  p =@!k 9J}i¦|exA  Ä  ,  Å  8 M  8„ B ’čä  0„’ü|éP8})P},Pł@ 4 å }	P8})P},Pł@ ,ä  |éP8})P},PłA’Š})8ų})PyA’ÄH  })@ų})PyA’Ģ}Cx8„ tę’ Tē@>å @’ōN        @       š strcpy  A   L |	¦N                ¤A   L |	¦N                ØA   L |	¦N                ¬A   L |	¦N                °A   L |	¦N                               b  8  q A “|¦| +|ą"*A H|8@@@@ |A L  H  p|£+|ä*A $0  |8@@@|£+@ P@ D|ä*@’ä|¦,     T ųA |„0|ē0|8@H  |8@|Ę0}0@@@ L  A A 8`’’N  8` N  8`  N  8c’’8’’£ Ä ,  |0@A £ @ Ä ,  |0@K’’čA A 8`’’N  8`  N  8` N        @       strcmp “A   L |	¦N               @(#)61	1.11  src/bos/usr/ccs/lib/libc/__threads_init.c, libcthrd, bos43K, 9823A_43K 6/12/98 12:37:06      ¼  °        /tmp/resolve    /tmp/resolve_links  /tmp/resolve.html   
Out of memory!
    %*.*s   <!--:   Processing file '%s'    r   
Error reading file '%s'.
  /tmp/resolve.html   w   /tmp/resolve.html   /   /   <!--</A>--> </A>    !--<A   --> </A>    <!--</A>--> /tmp/resolve.html   
Unable to modify file '%s'!
   , modified.
    , no change.
   edv?    edv?    *   /usr/bin/lslpp -wcq '%s' > %s   /tmp/resolve    /tmp/resolve    r   /tmp/resolve    %s
 :   /tmp/resolve    /   /   /   /   /   %s
 *   /tmp/resolve    /usr/bin/lslpp -wcq '%s' >> %s  /tmp/resolve    /tmp/resolve    /tmp/resolve    r   /tmp/resolve    %s
 :   /tmp/resolve    %s
 /usr/bin/rm -f %s >/dev/null 2>&1   /usr/bin/rm -f %s >/dev/null 2>&1   /usr/bin/rm -f %s >/dev/null 2>&1   
Error parsing file parsing file '%s'
  /usr/share/man/info/%s/a_doc_lib/%s/%s/toc.htm  /usr/share/man/info/%s/a_doc_lib/%s/%s/toc.htm  
Unable to write temporary file (%s)!
  /usr/bin/cp -f %s %s >/dev/null 2>&1    
Usage: resolve_links [-e|-d|-v|-?] [Locale...]

Options:
	-e	Enable all links.
	-d	Disable all links.
	-v	Verbose output.
	-[?]	Display this message and exit.

   /usr/share/man/info/%s/a_doc_lib/*.htm  /usr/bin/lslpp -wcq '%s' >/dev/null 2>&1    
There are no documentation filesets installed.
    
Error creating list of installed AIX Documentation Library files!
You may need to increase the size of the /var filesystem.
   
Unable to open list (%s) of installed AIX Documentation Library files!
    
Unable to parse list (%s) of installed AIX Documentation Library files!
   /usr/bin/rm -f %s >/dev/null 2>&1   /usr/share/man/info/%s/a_doc_lib/*.htm  /usr/bin/lslpp -wcq '%s' >/dev/null 2>&1    
There are no documentation filesets installed for the locale '%s'.
    Error creating list (%s) of installed AIX Documentation Library files!
 
Unable to open list (%s) of installed AIX Documentation Library files!
    
Unable to parse list (%s) of installed AIX Documentation Library files!
   @(#)31  1.3  src/bos/docregister/bin/resolve_links.c, docregister, bos43K, 9837B_43K 9/14/98 16:06:30                                           ¼ Č  ¼                                          	x           h           x                        	                                                                               ¤         ,   /     p   G  errno         @              $      @       _iob          @       exit          @
       free          @
       malloc        @
       fopen         @
       fclose        @
       sprintf       @
       printf        @
       fprintf       @
       __filbuf      @
       fputc         @
       fscanf        @
       stat          @
       strtok        @
       fputs         @
       system        @
       getopt        @
       strdup        @
              <      @
       __crt0v       @       optind        @       __start   Ø !
           h        l       Ø        ¬       °        “       ą       ä       č       ģ       š       ō       ų       ü       	        	       	       	       	       	       	       	       	        	$       	(   	    	,       	0       	4       	8       	<       	@       	D   
    	H       	L       	P       	T       	X       	\       	`       	d       	h       	l       	p       	t     /usr/lib:/lib:/usr/lpp/xlC/lib    libc.a shr.o   @VPDresolve_links/5765c3403/430  _system_configuration  __mod_init  kź\³ 2RDsm         &  ; 6RŹ6Ė6              &      ./usr/bin/chdoclang inks         m          m          #!/usr/bin/ksh
# IBM_PROLOG_BEGIN_TAG 
# This is an automatically generated prolog. 
#  
# bos43K src/bos/docregister/bin/chdoclang 1.2 
#  
# Licensed Materials - Property of IBM 
#  
# Restricted Materials of IBM 
#  
# (C) COPYRIGHT International Business Machines Corp. 1998 
# All Rights Reserved 
#  
# US Government Users Restricted Rights - Use, duplication or 
# disclosure restricted by GSA ADP Schedule Contract with IBM Corp. 
#  
# IBM_PROLOG_END_TAG 
# @(#)30	1.2  src/bos/docregister/bin/chdoclang, docregister, bos43K 9/21/98 14:43:29

#
# FILE NAME: chdoclang
#
# FILE DESCRIPTION: High-level shell command for changing the documentation
# language (DOC_LANG) environment variable in the /etc/environment file or a
#   user's individual .profile file.
#
#   See Usage message for explanation of parms
#
# RETURN VALUE DESCRIPTION:
#                             0         Successful
#                             non-zero  Unsuccessful
#

################################# usage #######################################
#
# NAME: usage()
#
# DESCRIPTION: Issue "usage" message and exit.
#
# INPUT:
#        None
#
# OUTPUT:
#        Error messages (Standard Error)
#
# RETURN VALUE DESCRIPTION:
#        2    - Indicates invalid usage
#
# NOTE: This function will not return (i.e., it will exit the entire
#       script with exit status of 2).
#
##############################################################################
usage(){
	echo
	dspmsg -s 3 index_config.cat 1 \
	"Usage:\tchdoclang [-d] [-u UID|Uname] Language\n\n\
Sets the default documentation language for the system or a user.\n\n\
Options:\n\
\t-d\tRemove the default documentation language setting.\n\
\t-u\tMake modification for the specified user.\n\n\
EXAMPLE:\n\
\tchdoclang en_US\t\t# Changes default documentation language to English\n" chdoclang >&2
	echo
	exit 2                       # don't return
}

################################# del_var ###################################
#
# NAME: del_var()
#
# DESCRIPTION: Remove environment variable in /etc/environment file,
#		user's .profile file, or user's .cshrc file, depending 
#		on PROFILE variable.
#
# INPUT:
#        PROFILE   - Set to "/etc/environment","<home_dir>/.profile", or
#			"<home_dir>/.cshrc"
#        ENV_VAR   - Set to environment variable to be deleted
#
# OUTPUT:
#        none
#
# RETURN VALUE DESCRIPTION:
#        0         - Successful removal of environment variable
#        non-zero  - Error encountered in removal
#
##############################################################################
del_var(){

# Set EGREP_ARG and SED_ARG to appropriate argument value depending
# on whether we are modifying a .cshrc file, /etc/environment or something else.
if [ $cshell -eq 1 ]
then
	EGREP_ARG="^setenv[ |	]+$ENV_VAR"
	SED_ARG="/^setenv[ |	]*$ENV_VAR/d"
elif [ $PROFILE = "/etc/environment" ]
then
	EGREP_ARG="^[ 	]*$ENV_VAR="
	SED_ARG="/^[ 	]*$ENV_VAR=/d"
else
	EGREP_ARG="^[ 	]*$ENV_VAR="
	SED_ARG="/^[ 	]*$ENV_VAR=/d"
fi

# Check to see if environment variable is currently used in the file
# to be modified. If it is, then use sed to remove the environment
# variable from the file. If the environment variable is not in the
# file, and the particular variable is "NLSPATH", display a warning
# message telling the user that NLSPATH was not in the file.
if grep -E -qs "$EGREP_ARG" $PROFILE > /dev/null 2>&1 ; then
	sed "$SED_ARG" $PROFILE >/tmp/chdoclang$$ && cp /tmp/chdoclang$$ $PROFILE

	# Save the result code for the sed command
	RTNCODE=$?

	# Remove the temporary file
	rm /tmp/chdoclang$$

	# If an error occurred in deleting the environment variable, display
	# an error message and exit.
	if [ $RTNCODE -ne 0 ] ; then
		dspmsg -s 3 index_config.cat 2 "chdoclang: Could not write to $PROFILE\n\
\tCheck permissions on the file.\n" chdoclang $PROFILE
		echo
		exit $RTNCODE
	fi
fi
}

################################# chng_var ###################################
#
# NAME: chng_var()
#
# DESCRIPTION: Change or add environment variable in /etc/environment,
#		user's .profile file, or user's .cshrc file, depending 
#		on PROFILE variable.
#
# INPUT:
#        PROFILE   - Set to "/etc/environment", "<home_dir>/.profile", or
#			"<home_dir>/.cshrc
#        ENV_VAR   - Set to environment variable to be modified
#        NEW_VAL   - New value for environment variable
#
# OUTPUT:
#        none
#
# RETURN VALUE DESCRIPTION:
#        0         - Successful modification of environment variable
#        non-zero  - Error encountered in modification
#
##############################################################################
chng_var(){

# Set EGREP_ARG, SED_ARG, and ECHO_ARG to appropriate argument value depending
# on whether we are modifying a .cshrc file, /etc/environment or something else.
if [ $cshell -eq 1 ]
then
	EGREP_ARG="^setenv[ |	]+$ENV_VAR"
	SED_ARG="s!^setenv[ |	]*$ENV_VAR.*!setenv $ENV_VAR $NEW_VAL!"
	ECHO_ARG="setenv $ENV_VAR $NEW_VAL"
elif [ $PROFILE = "/etc/environment" ]
then
	EGREP_ARG="^[ 	]*$ENV_VAR="
	SED_ARG="s!^[ 	]*$ENV_VAR=.*!$ENV_VAR=$NEW_VAL!"
	ECHO_ARG="$ENV_VAR=$NEW_VAL"
else
	EGREP_ARG="^[ 	]*$ENV_VAR="
	SED_ARG="s!^[ 	]*$ENV_VAR=.*; export $ENV_VAR!$ENV_VAR=$NEW_VAL; export $ENV_VAR!"
	ECHO_ARG="$ENV_VAR=$NEW_VAL; export $ENV_VAR"
fi

# Check to see if environment variable is currently in file to be
# modified. If it is, then use sed to set it to new value. If the
# environment variable is not present, add it to the end of the file.
if grep -E -qs "$EGREP_ARG" $PROFILE > /dev/null 2>&1 ; then
	sed "$SED_ARG" $PROFILE >/tmp/chdoclang$$ \
	&& cp /tmp/chdoclang$$ $PROFILE
else
	echo "$ECHO_ARG" >> $PROFILE
fi

# Save the result code for the file modification
RTNCODE=$?

# Remove the temporary file, if it was used
rm /tmp/chdoclang$$ > /dev/null 2>&1

# If an error occurred when modifiying the file, report it and exit.
if [ $RTNCODE -ne 0 ] ; then
	dspmsg -s 3 index_config.cat 2 "chdoclang: Could not write to $PROFILE\n\
\tCheck permissions on the file.\n" chdoclang $PROFILE
	echo
	exit $RTNCODE
fi
}

############################## main ############################################
PATH=/usr/bin:/bin:/etc export PATH

# Initialize variables
uflag=0
dflag=0
cshell=0

# Get effective user id for process owner
eff_id=`id -u`

# Parse command line looking for options
set -- `getopt u:m:dM? $*`

# If invalid syntax, give usage message
if [ $? != 0 ]
then
	usage
fi

# Scan through argument list looking for options. 
while [ $1 != -- ]
do
	case $1 in
	-u)
		uflag=1
		username=$2
		shift;shift
		;;
	-d)
		dflag=1
		shift
		;;
	-?)
		usage
		;;
	esac
done
shift

# Get requested language from command line
language=$1

# Check to see if the -d flag was used on the command line. 
if [ $dflag -eq 1 ]
then
	# If -d flag was used, check to see if a language was provided
	# on the command line. If this
	# is the case, give error message, display usage, and exit.
	if [ $# -ne 0 ]
	then
		dspmsg -s 3 index_config.cat 3 "chdoclang: Cannot use -d flag with Language\n" chdoclang
		usage
	fi
else
	# If -d flag was not used, check to see if a language was provided
	# on the command line.  If a language was not specified,
	# then display usage, and exit.
	if [ $# -eq 0 ]
	then
		dspmsg -s 3 index_config.cat 4 "chdoclang: Language must be specified\n" chdoclang
		usage
	fi
fi


# if $SHELL is not defined, ensure that we have a default, so that the
# script will not fail.
if [ "${SHELL}" = "" ]
then
	SHELL=/usr/bin/sh
fi

# Check to see if root is running chdoclang. If effective ID is 0, then
# assume root is trying to modify /etc/environment file. If effective
# ID is not 0, then assume regular user is trying to modify its own
# .profile file.
if [ $eff_id -eq 0 ]
then
	PROFILE=/etc/environment
else
	login_shell=`basename $SHELL`
	if [ $login_shell = "csh" ]
	then
		cshell=1
		PROFILE=$HOME/.cshrc
	else
		PROFILE=$HOME/.profile
	fi
fi

# If user name provided on command line, do user processing
if [ $uflag -eq 1 ]
then
	# Initialize variable to indicate if user was found
	# in /etc/passwd file
	found=0

	# Get user ID of user, as if user name was entered
	userid=`id -u $username 2>/dev/null`

	# If user ID was used on command line, previous command will fail
	if [ $? != 0 ]
	then
		userid=$username
	fi
	
	# Check if non-superuser is trying to modify another user. This
	# is not allowed, so print an error message and exit.
	if [ "$username" != "$USER" -a "$userid" != "$eff_id" -a $eff_id -ne 0 ]
	then
		dspmsg -s 3 index_config.cat 5 \
			"chdoclang: Cannot modify another user\n" chdoclang
		echo
		exit 2
	fi

	# Scan through /etc/passwd for user's entry. Set home directory
	# for later use when writing user's .profile
	cat /etc/passwd | awk 'BEGIN {FS=":"} {print $1, $3, $6, $7}' |
	while read entry_name entry_id home_dir shell_path
	do
		if [ "$username" = "$entry_name" -o "$userid" = "$entry_id" ]
		then
			# Change PROFILE to make modifications to 
			# user's .profile file
			PROFILE=$home_dir/.profile
			if [ "$shell_path" = "" ]
			then
				login_shell=`basename $SHELL`
			else
				login_shell=`basename $shell_path`
			fi
			if [ $login_shell = "csh" ]
			then
				cshell=1
				PROFILE=$home_dir/.cshrc
			fi
			found=1
			break
		fi
	done
	
	# If user not found in /etc/passwd, give error message and exit
	if [ $found -eq 0 ]
	then
		dspmsg -s 3 index_config.cat 6 "chdoclang: User \"$username\""\
" not found in /etc/passwd file\n" chdoclang $username
		echo
		exit 2
	fi
fi


# If -d on command line, remove DOC_LANG from either /etc/environment
# file or user's .profile file. Otherwise, modify DOC_LANG variable in
# the particular file
ENV_VAR="DOC_LANG"
if [ $dflag -eq 1 ]
then
	del_var
else
	if [ "$language" != "" ]
	then
		NEW_VAL=$language
		chng_var
	fi
fi
kź¢./e3, $6, $7}' |
	while read entry_name entry_id home_dir shell_path
	do
		if [ "$username" = "$entry_name" -o "$userid" = "$entry_id" ]
		then
			# Change PROFILE to make modifications to 
			# user's .profile file
			PROFILE=$home_dir/.profile
			if [ "$shell_path" = "" ]
			then
				login_shell=`basename $SHELL`
			else
				login_shell=`basename $shell_path`
			fi
			if [ $login_shell = "csh" ]
			then
				cshell=1
				PROFILE=$home_dir/.cshrc
			fi
			found=1
			break
		fi
	done
	
	# If user not found in /etc/passwd, give error message and exit
	if [ $found -eq 0 ]
	then
		dspmsg -s 3 index_config.cat 6 "chdoclang: User \"$username\""\
" not found in /etc/passwd file\n" chdoclang $username
		echo
		exit 2
	fi
fi


# If -d on command line, remove DOC_LANG from either /etc/environment
# file or user's .profile fil