#!/bin/bash

. ${TOOLKIT}-functions.sh

case $DISTRIB_RELEASE in
  9.*)	file="cupsd.conf.9.04" ;;
  10.*)	file="cupsd.conf.10.04" ;;
  *)	file="cupsd.conf" ;;
esac

file=`filepath $file`	|| exit 1
out="cupsd.conf.tmp"
cp $file $out	|| exit $?

for perm in browse admin
do
	allowed=`jtconf cups.${perm}_allow` || exit_missing_define "cups.${perm}_allow"

	string=
	for allow in $allowed
	do
		case $perm in
		  browse)	string="$string	BrowseAllow from $allow\n" ;;
		  admin)	string="$string	Allow from $allow\n" ;;
		esac
	done

	sed -e "s#-ku-temp-tag-for-inserting-${perm}-allow-ku-#$string#" \
		$out > $out.1.tmp || exit $?
	mv $out.1.tmp $out
done

exit 0
