#!/bin/sh
#the Debian-Brother Installer
#rcrsn51 2009-06-15
#installs a Debian printer package and executes the post-install script
#usage: debbi filename.deb 

if [ $# -eq 0 ]; then
	echo Usage: debbi filename.deb
	exit
fi

if [ ! -f $1 ]; then
  echo "File not found!"
  exit
fi

EXT=${1##*.}
if [ "$EXT" != "deb" ]; then
	echo "Not a .deb file!"
	exit
fi

mkdir -p /var/spool/lpd

dpkg-deb -x $1 /
dpkg-deb -e $1
if [ -f DEBIAN/postinst ]; then
	sh DEBIAN/postinst
	echo "Post-install script completed!"
fi
rm -rf DEBIAN
echo "Done!"
