#!/bin/sh

functions()
	{
		SELFTMP=$0
		ORIGPWD=`pwd`
		REALPWD=`dirname $0`
		cd "$REALPWD"
		while [ -L "$SELFTMP" ]
			do
				SELFTMP=`readlink "$SELFTMP"`
				cd `dirname "$SELFTMP"`
				REALPWD=`pwd -P`
		done

		cd "$ORIGPWD"

		if [ "$INITIALIZED" != "1" ]
			then
				source $REALPWD/inc/functions.sh
		fi
	}

functions

inituninstall()
	{
		INITRUNLEVEL=`cat /etc/inittab  |grep -v "^#" |grep initdefault |cut -d":" -f2`
		good ""
		good "Default runlevel seems to be ${HILITE}$INITRUNLEVEL${NORMAL}"
		good ""
		getconfirm "Remove Merak Mail Server from runlevel ${HILITE}$INITRUNLEVEL${NORMAL}?" && (
			`which rm` "/etc/rc${INITRUNLEVEL}.d/S90merak" && good "Initscript removed" || bad "Initscript removal problem, check permissions"
		) || warn "User cancelled"
		return 0
	}
	
inituninstall