#!/bin/sh set -e . /usr/share/debconf/confmodule # Read the package default, need to match the code in sitesummary-client [ -f /usr/share/sitesummary/sitesummary-client.conf ] && \ . /usr/share/sitesummary/sitesummary-client.conf for confdir in \ /usr/share/sitesummary/config.d \ /etc/sitesummary/config.d do [ -d $confdir ] || continue for config in $confdir/* ; do [ -f $config ] && . $config done done db_get sitesummary-client/collector_url URL="$RET" # Only update the URLs if it is different from the current value if [ "$URL" != "$serverurls" ] ; then if [ -f /etc/sitesummary/config.d/00debconf ] ; then if grep -q '^serverurls=' /etc/sitesummary/config.d/00debconf ; then sed "s%^serverurls=.*\$%serverurls=\"$URL\"%" < /etc/sitesummary/config.d/00debconf > /etc/sitesummary/config.d/00debconf.new && mv /etc/sitesummary/config.d/00debconf.new /etc/sitesummary/config.d/00debconf else echo "serverurls=\"$URL\"/" >> /etc/sitesummary/config.d/00debconf fi else mkdir -p /etc/sitesummary/config.d echo "serverurls=\"$URL\"" > /etc/sitesummary/config.d/00debconf fi fi db_get sitesummary-client/site SITE="$RET" # Only replace the site file if the content changed if [ -f /etc/sitesummary/site ] ; then OLDSITE="`cat /etc/sitesummary/site`" if [ "$SITE" != "$OLDSITE" ] ; then echo "$SITE" > /etc/sitesummary/site fi else echo "$SITE" > /etc/sitesummary/site fi db_get sitesummary-client/sitegroup SITEGROUP="$RET" # Only replace the sitegroup file if the content changed if [ -f /etc/sitesummary/sitegroup ] ; then OLDSITEGROUP="`cat /etc/sitesummary/sitegroup`" if [ "$SITEGROUP" != "$OLDSITEGROUP" ] ; then echo "$SITEGROUP" > /etc/sitesummary/sitegroup fi else echo "$SITEGROUP" > /etc/sitesummary/sitegroup fi db_get sitesummary-client/hostclass HOSTCLASS="$RET" # Only replace the hostclass file if the content changed if [ -f /etc/sitesummary/hostclass ] ; then OLDHOSTCLASS="`cat /etc/sitesummary/hostclass`" if [ "$HOSTCLASS" != "$OLDHOSTCLASS" ] ; then echo "$HOSTCLASS" > /etc/sitesummary/hostclass fi else echo "$HOSTCLASS" > /etc/sitesummary/hostclass fi db_stop #DEBHELPER#