#!/bin/bash


ACTION="$1"

shift

PACKAGE_LIST=$@

case $ACTION in

	remove)
		countError=0
		for ix in $PACKAGE_LIST
		do
			apt purge -y $ix
			TEST=$( dpkg-query -s $ix 2> /dev/null| grep Status | cut -d " " -f 4 )
			if [ "$TEST" == 'installed' ];then
				let countError=countError+1
			fi
		done

		if [ $countError -ne 0 ];then
			exit 1
		fi
				
	;;	
esac
exit 0