#!/bin/bash
#
# batch file to setup
#


################################################################################
#
# echo informations
#

echo
echo "    start <ZMIN Printer Driver> install......"

################################################################################
#
# check and execute uninstall shell script
#

if test -f /usr/share/cups/model/zmin/uninstall
then
  echo "find"
  echo "    execute uninstall shell script now......"
  if !(/usr/share/cups/model/zmin/uninstall)
  then
    echo "    uninstall old <ZMIN Printer Driver> failed"
    echo "    install driver failed"
    echo
    exit 1
  fi
else
  echo "no find"
fi


################################################################################
#
# echo informations
#

echo "    start copy files......"

################################################################################
#
# set own, grp and permissions
#
chown -R root:root ./*
chmod 644  ./ppd/*.ppd
chmod 755  ./uninstall

################################################################################
#
# make install dir
#
mkdir -p /usr/share/cups/model/zmin/
chown -R root:root /usr/share/cups/model/zmin/
chmod -R 755 /usr/share/cups/model/zmin/


################################################################################
#
# copy files
#

cp ./ppd/*.ppd /usr/share/cups/model/zmin/
cp ./uninstall /usr/share/cups/model/zmin/


echo "    restart spooler - CUPS"
################################################################################
#
# restart 
#
if test -f /etc/init.d/cups
then
  /etc/init.d/cups restart
else
  if test -f /etc/init.d/cupsys
  then
    /etc/init.d/cupsys restart
  fi
fi

################################################################################
#
# echo informations
#

echo "    install driver completed"
echo

exit 0

