#!/bin/bash

case $1 in
	configure)
		update-rc.d fixhosts defaults 00
		#remove depricated cron from conflicted package
		rm -f /etc/cron.d/yandex-config-etc-hosts

		if [ -x /etc/init.d/fixhosts ]; then invoke-rc.d fixhosts restart; fi

		OMNI=$(dpkg -l | grep omniorb | grep nameserver | grep -v grep | wc -l)
		if [ $OMNI -ne 0 ] ; then
			echo -e '\e[41m'"\e[1m ACHTUNG \e[0m";
			echo -e '\e[41m'"\e[1m ACHTUNG \e[0m";
			echo -e '\e[41m'"\e[1m ACHTUNG \e[0m";
			echo -e '\e[41m'"\e[1m omniorb with hostname-long detected :( \e[0m";
			echo -e '\e[41m'"\e[1m try to autofix problem \e[0m";
			C=$(uname -n); 
			S=$(hostname -s); 
			P=/var/lib/omniorb4/omninames-; 
			NEW=$P$C.log; 
			OLD=$P$S.log; 
			OO=/etc/init.d/omniorb4-nameserver; 
			test -f $NEW || { $OO stop; mv $OLD $NEW; $OO start ; }
			echo "test omniorb"
			nameclt list
		fi
	;;

	abort-upgrade|abort-remove|abort-deconfigure)
	;;

	*)
		echo "postinst called with unknown argument \`$1'" >&2
	;;
esac
