#!/bin/sh -
#
# @(#)mk-afs-odmfix-qdaemon	1.4 (hursley) 10/31/96
# /afs/hursley.ibm.com/common/src/afs/@cell/rs_aix32/usr/local/sbin/mk-afs-odmfix-qdaemon/SCCS/s.mk-afs-odmfix-qdaemon
#
# NAME		mk-afs-odmfix-qdaemon
# AUTHOR	Paul Blackburn <mpb@acm.org>
# PURPOSE	Script to change AIX ODM SRCsubsys so that qdaemon invocation
#		is replaced by wrapper program that gets AFS authentication
#		then starts qdaemon.
#
#		Default wrapper is:
#			${afs_install_base}/usr/local/sbin/mk-afs-wrap-qdaemon
#		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 qdaemon by using normal srcmstr commands.
#		eg: stopsrc -s qdaemon
#		    startsrc -s qdaemon
#
# NB            You have to reboot for the change in ODM to take effect
#
# USAGE		This program is run once to set up AFS authenticated
#		qdaemon printer daemon.
#
# DEINSTALL	To recover the ODM to its default state run:
#		mk-afs-odmfix-qdaemon /etc/qdaemon
#
# CAUTION	Do not attempt to use the mk-afs-wrap-qdaemon wrapper program
#		unless you have:
#		a) a working reauth installed (eg: /usr/etc/mk-afs-reauth)
#		b) configured mk-afs-qdaemon to authenticate as an AFS ID
#		   (eg qdaemon) authorised to read files in $HOMEs
#		c) Set an ACL on $HOMEs to allow qdaemon read access
#		   (eg: fs sa $HOME qdaemon rl)
#
#		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-qdaemon
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 = qdaemon" SRCsubsys > ${old}

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

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