#!/bin/sh
#
# Copyright (c) 2011 Avira Operations GmbH & Co. KG and its Licensors
#

HOME_DIR="/usr/lib/AntiVir"
OS=`uname | env LANG=C LC_ALL=C LC_CTYPE=C tr '[:upper:]' '[:lower:]'`

case "${OS}" in
	sunos)
		PSAX="ps -Af"
		;;
	freebsd)
		PSAX="ps ax"
		;;
	darwin)
		PSAX="ps ax"
		;;
	*)
		PSAX="ps ax"
		;;
esac

if [ -f $HOME_DIR/ium/avium ]
then
	if [ -f /var/run/start_avium ]
	then
		rm /var/run/start_avium > /dev/null 2>&1
	fi

	$PSAX | grep "$HOME_DIR/ium/ium" | grep -v grep > /dev/null 2>&1
	ERR="$?"
	if [ $ERR -eq 0 -o -f /etc/init.d/avium -o -f /etc/rc?.d/avium -o -f /etc/rc.d/rc?.d/avium ]
	then
		touch /var/run/start_avium
	fi

	$HOME_DIR/ium/avium stop > /dev/null 2>&1
	ERR=$?
	if [ $ERR -eq 0 ]
	then
		exit 0

	elif [ $ERR -eq 7 ]
	then
		exit 0

	elif [ $ERR -ne 0 -a $ERR -ne 7 ]
	then
		echo ""
		echo "It was not possible to stop Avira IUM"
		exit 1
	fi
else
	echo ""
	echo "$HOME_DIR/ium/avium not found."
	exit 1
fi

# AVCS4F3A4200C37O030000000203000002A4010000000000000000000000000303000000650300000200P000000000000000049914F2EAD2627150CE73AAFCCCEB87C335ED41968BCEBEFD60499276FD5265264FC44330641D82EAF8B2DE402473E0D9EC3EBAB3EF11A70A9BF20D6FE184FDFA850DF3F8973811867CE301888024BA47CB2468117B8C4D2586EEC0796804AB6A809C539921D9352A4E516DD2398AFFE22507A703F7C9D2861E116A8B5A8F65A6EB03BC1DF6637F15717F08D699699CC60EADE45FCE559190BAD4F16FA6E610BC3410EAA893F5ADC170FC64A405A52C24D6815E3D1598C1116F14E736A014AC00C441F1808D4C08E470639D1B95351117EF1DBBEB2B784085636BDC400E77BBD7D233E030338F3870DDE54FAB02E6DE285AD4E5E11C3812688ADFD4FA6A7E13400000000000000000000000000000292030000000003T62F3AB0132FAVCSE