#!/bin/sh
#  This script simply adds descriptions into the CD1.1 daemon configuration
#  files. Previously, they were only stored in the ".ctl.local" file.

# Only run once
[ -n "${POST_UPGRADE_CACHE}" ] && touch "${POST_UPGRADE_CACHE}/`basename $0`"

for CTL in /etc/data-out-cd11/*.ctl.local /etc/data-in-cd11/*.ctl.local /etc/gdi2cd11/*.ctl.local /etc/data-mux-cd11/*.ctl.local
do
	[ -e "${CTL}" ] || continue
	CF="`echo "${CTL}" | sed -e 's/\.ctl\.local$/.local/'`"
	[ -e "${CF}" ] || continue

	DESC="`gcs_rwvar "gcs_get_varcf2" "application_description" "${CF}" ""`"
	if [ -z "${DESC}" ]
	then
		DESC="`gcs_rwvar "gcs_get_varf" "DESC" "${CTL}"`"
		echo " * ${CF}: changing description to \"${DESC}\""
		gcs_rwvar "gcs_set_varcf2" "application_description" "${CF}" "${DESC}" ""
	fi
done

exit 0
