#!/bin/sh -
#
# @(#)mk-afs-odmfix-infod	1.2 (ASSC) 10/31/96
# /afs/hursley.ibm.com/common/src/afs/@cell/rs_aix32/usr/local/sbin/mk-afs-odmfix-infod/SCCS/s.mk-afs-odmfix-infod
#
# NAME		mk-afs-odmfix-infod
# AUTHOR	Paul Blackburn <mpb@acm.org>
# PURPOSE	Script to change AIX ODM SRCsubsys so that infod invocation
#		is replaced by wrapper program that gets AFS authentication
#		then starts infod.
#
#		Default wrapper is:
#			${afs_install_base /usr/local/sbin/mk-afs-wrap-infod
#		or you
#		can supply the name of the wrapper file on the command line:
#		mk-afs-odmfix wrapper_file_name
#
#		Once the ODM change is made, you can stop and start the
#		AFS authenticating infod by using normal srcmstr commands.
#		eg: stopsrc -s infod
#		    startsrc -s infod
#
# NB            You have to reboot for the change in ODM to take effect
#
# USAGE		This program is run once to set up AFS authenticated
#		infod printer daemon.
#
# DEINSTALL	To recover the ODM to its default state run:
#		mk-afs-odmfix-infod /usr/lpp/info/bin/infod
#
# CAUTION	Do not attempt to use the mk-afs-wrap-infod wrapper program
#		unless you have:
#		a) a working reauth installed (eg: /usr/etc/mk-afs-reauth)
#		b) configured mk-afs-infod to authenticate as an AFS ID
#		   (eg infod) authorised to update  files in $HOME/info
#		c) Set an ACL on $HOME/info to allow infod update access
#		   (eg: fs sa $HOME infod rl; fs sa $HOME/info write)
#
#		See: ftp://grand.central.org:/pub/afs-contrib/tools/reauth

CMD=`basename ${0}`

ODMDIR=/etc/objrepos; export ODMDIR
old=/tmp/${CMD}.$$

if [ -z "${1}" ]; then
	wrapper=${afs_install_base}/usr/local/sbin/mk-afs-wrap-infod
else
	wrapper=${1}
	if [ ! -f ${wrapper} ]; then
		echo "no such file: ${wrapper}" >&2
		exit 1
	else
		if [ ! -x ${wrapper} ]; then
			echo "${wrapper} not executable" >&2
			exit 1
		fi
	fi
fi

odmget -q "subsysname = infod" SRCsubsys > ${old}

ed - ${old} <<%
/path =
d
i
	path = "${wrapper}"
.
w
q
%

odmdelete -o SRCsubsys -q "subsysname = infod"
odmadd ${old}
odmget -q "subsysname = infod" SRCsubsys
