#!/bin/sh 

echo "Reverting changes to /etc/cups/cupsd.conf..." >&2
conffile="/etc/cups/cupsd.conf"

mv "$conffile" "$conffile.bak"
touch "$conffile"
sed '/# Begin configurations for gutenbach/,/# End configurations for gutenbach/ d' < "$conffile.bak" > "$conffile"

mv "$conffile" "$conffile.bak"
touch "$conffile"
while read line; do
    listen_localhost=$(echo "$line" | grep '^#GUTENBACH' || true)
    if [ -n "$listen_localhost" ]; then
	echo "$(echo $line | sed s/#GUTENBACH//)" >> "$conffile"
    else
	echo "$line" >> "$conffile"
    fi
done < "$conffile.bak"

rm "$conffile.bak"
