#!/bin/sh
#the Canon-Debian Installer
#rcrsn51 2014-05-17
#installs a Debian printer/scanner package and executes the post-install script

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

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

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

dpkg-deb -x $1 /
dpkg-deb -e $1
[ -e DEBIAN/postinst ] && sh DEBIAN/postinst
rm -rf DEBIAN

cd /usr/lib64
for L in libcn*; do
  chmod 755 $L
  LL=${L%.so*}
  [ -e $LL.so ] || ln -s $L $LL.so
done

rm -f /usr/lib64/cups/backend/cnijusb   #use the CUPS USB backend instead
cancel -a
/etc/init.d/70-cups restart

echo "Done!"
