#!/bin/bash #################################################################### ## This script was created by Kevin Carter and BK Integration ## ## This script is for use under GPLv2 and you should feel free to ## ## Modify it as you see fit, all I ask is that you give me credit ## ## for some of it... I hope these files help, Drop me a line and ## ## let me know. http://rackerua.com ## #################################################################### #################################################################### ############################ Change Log ############################ ## -------------------------------------------------------------- ## ## 18.10.11 Added Printer IP address to the host Make ## ## 18.10.11 Added to the script for installation by default ## ## 31.10.11 Added If to installer in CUPS setup for Ubuntu >10 ## ## 30.01.12 Added more robust Logging / Better OS Detection ## ## -------------------------------------------------------------- ## clear echo "Version 4.5 - Universal" USER=$(whoami) ARCH=$(uname -m) DATE=$(date +-%Y-%m-%d-%H%M) if [ `which lsb_release` ];then CODENAME=$(lsb_release -d) else CODENAME=$(head -1 /etc/issue | awk '{print $1,$2,$3}') fi echo "" echo "This Script will install several pieces of software and make a" echo "few adjustments to various pieces of your Operating System to " echo "install the access to the Printer on your Machine " echo '' if [ "$(id -u)" != "0" ]; then echo "This script must be run as ROOT" echo "You have attempted to run this as $USER" echo "use su -c "" or sudo or change to root and try again." exit 0 fi echo '' echo 'This Installer has been tested on Ubuntu 10.xx - 11.04 & Debian 5 - 6' echo "" echo 'Current User =' "$USER" echo 'Operating System =' "$CODENAME" echo 'System Architecture =' "$ARCH" echo "" sleep 3 read -p "Press [ Enter ] to Continue or Press [ CTRL-C ] to quit" EXITERROR(){ echo ' Please contact Kevin at info@bkintegration.com to see if there is an update for this Installation.' echo " Creating Log file for the installation of the Drivers. This Log is in your Home Folder" su -c "mv /tmp/canon-printing_Install.log /canon-install.log/canon-printing-Install-${DATE}.txt" > /dev/null 2>&1 su -c 'chmod -R 777 /canon-install.log' > /dev/null 2>&1 read -p "Press [ Enter ] to Exit" exit 0 } echo " Purging the old installation file should there be any" echo ' ---------------------- Purging OLD Packages ---------------------- ' > /tmp/canon-printing_Install.log 2>&1 2>&1 CHECK1=$(dpkg -l | grep cnijfilter | cut -d " " -f 3) if [ "$CHECK1" ] > /dev/null 2>&1;then echo 'Directory Warnings for this package are normal. If you see one please Ignore' su -c 'dpkg -l | grep cnijfilter | cut -d " " -f 3 | xargs dpkg -P' >> /tmp/canon-printing_Install.log 2>&1 fi CHECK2=$(dpkg -l | grep scangear | cut -d " " -f 3) if [ "$CHECK2" ] > /dev/null 2>&1;then su -c 'dpkg -l | grep scangear | cut -d " " -f 3 | xargs dpkg -P' >> /tmp/canon-printing_Install.log 2>&1 fi CHECK3=$(dpkg -l | grep libcupsys2 | cut -d " " -f 3) if [ "$CHECK3" ] > /dev/null 2>&1;then su -c 'dpkg -l | grep libcupsys2 | cut -d " " -f 3 | xargs dpkg -P' >> /tmp/canon-printing_Install.log 2>&1 fi CHECK4=$(grep 'Printer IP Address' /etc/hosts) if [ "$CHECK4" ] > /dev/null 2>&1;then echo "Printer is being removed from the Hostfile." su -c 'sed -i "/Printer IP Address/,+1 d" /etc/hosts' >> /tmp/canon-printing_Install.log 2>&1 fi if [ ! /lib32/libpng.so.3 ]; then su -c 'rm /lib32/libpng.so.3' >> /tmp/canon-printing_Install.log 2>&1 fi if [ ! /usr/lib32/libpng.so.3 ]; then su -c 'rm /lib32/libpng.so.3' >> /tmp/canon-printing_Install.log 2>&1 fi if [ ! /usr/lib32/libtiff.so.3 ]; then su -c 'rm /lib32/libpng.so.3' >> /tmp/canon-printing_Install.log 2>&1 fi if [ ! /lib/libpng.so.3 ]; then su -c 'rm /lib32/libpng.so.3' >> /tmp/canon-printing_Install.log 2>&1 fi if [ ! /usr/lib/libtiff.so.3 ]; then su -c 'rm /lib32/libpng.so.3' >> /tmp/canon-printing_Install.log 2>&1 fi if [ ! /usr/lib/libpng.so.3 ]; then su -c 'rm /lib32/libpng.so.3' >> /tmp/canon-printing_Install.log 2>&1 fi if [ -f /usr/share/ppd/canonmp620-630_Universal.ppd ]; then su -c 'rm /usr/share/ppd/canonmp*' fi if [ -f /usr/share/ppd/canonip1800_Universal.ppd ]; then su -c 'rm /usr/share/ppd/canonip*' fi echo ' ---------------------- Purge Complete ---------------------- ' >> /tmp/canon-printing_Install.log 2>&1 if [ ! -d /canon-install.log ]; then echo ' Creating The Log Location' su -c 'mkdir /canon-install.log/' >> /tmp/canon-printing_Install.log 2>&1 fi cd /tmp echo " Updating Packages" su -c 'apt-get update' > /dev/null 2>&1 echo " Downloading and Expanding files and folders" su -c 'apt-get -y install unzip' >> /tmp/canon-printing_Install.log 2>&1 if [ -f /tmp/canon-printing.univ.tar.gz ]; then su -c 'rm /tmp/canon-printing.univ.tar.gz' fi wget http://downloads.bkintegration.com/canon/canon-printing.univ.tar.gz >> /tmp/canon-printing_Install.log 2>&1 tar xvzf canon-printing.univ.tar.gz >> /tmp/canon-printing_Install.log 2>&1 echo " Changing files to root ownership" su -c 'chown root:root -R ./Build' >> /tmp/canon-printing_Install.log 2>&1 echo " Switching to Build Directory" cd Build su -c 'chmod +x configure' >> /tmp/canon-printing_Install.log 2>&1 echo " Installing any and all dependencies for Printing and Scanning" su -c 'apt-get -y install libcupsys2-dev libc6 libgcc1 libstdc++6 libatk1.0-0 libc6 libcairo2 libfontconfig1 libgimp2.0 libglib2.0-0 libgtk2.0-0 libpango1.0-0 libpng12-0 libstdc++6 libusb-0.1-4 libx11-6 libxcursor1 libxext6 libxfixes3 libxi6 libxinerama1 libxrandr2 libxrender1 zlib1g cups cups-client make' >> /tmp/canon-printing_Install.log 2>&1 if [ `uname -m` = "x86_64" ]; then su -c 'apt-get -y install ia32-libs' >> /tmp/canon-printing_Install.log 2>&1 if [ $? -ne 0 ] ; then echo ' I am sorry though you are using a x64 system and the apt-get package management system failed to install ia32-libs.' echo 'The package ia32-libs is needed to continue...' EXITERROR fi if [ -e /lib32/libpng12.so.[0-9].* ]; then echo 'Creating a Symbolic Link to libpng12 /lib32/libpng.so.3' ln -sf /lib32/libpng12.so.[0-9].* /lib32/libpng.so.3 >> /tmp/canon-printing_Install.log 2>&1 fi if [ -e /usr/lib32/libpng12.so.[0-9].* ]; then echo 'Creating a Symbolic Link to libpng12 /usr/lib32/libpng.so.3' ln -sf /usr/lib32/libpng12.so.[0-9].* /usr/lib32/libpng.so.3 >> /tmp/canon-printing_Install.log 2>&1 fi if [ -e /usr/lib32/libtiff.so.[0-9].* ]; then echo 'Creating a Symbolic Link to libtiff /usr/lib32/libtiff.so.3' ln -sf /usr/lib32/libtiff.so.[0-9].* /usr/lib32/libtiff.so.3 >> /tmp/canon-printing_Install.log 2>&1 fi elif [ `uname -m` = i686 ] ; then if [ -e /lib/libpng12.so.[0-9].* ] ; then echo 'Creating a Symbolic Link to libpng12 /lib/libpng.so.3' ln -sf /lib/libpng12.so.[0-9].* /lib/libpng.so.3 >> /tmp/canon-printing_Install.log 2>&1 fi if [ -e /usr/lib/libpng12.so.[0-9].* ] ; then echo 'Creating a Symbolic Link to libpng12 /usr/lib/libpng.so.3' ln -sf /usr/lib/libpng12.so.[0-9].* /usr/lib/libpng.so.3 >> /tmp/canon-printing_Install.log 2>&1 fi if [ -e /usr/lib/libtiff.so.[0-9].* ] ; then echo 'Creating a Symbolic Link to libtiff /usr/lib/libtiff.so.3' ln -sf /usr/lib/libtiff.so.[0-9].* /usr/lib/libtiff.so.3 >> /tmp/canon-printing_Install.log 2>&1 fi else ARCHITE=$(uname -m) echo " I apologize though at this time I have not devised a way to support your architecture" echo "Your system is running $ARCHITE" EXITERROR fi if [ ! `echo $CODENAME | grep -i "ubuntu" | awk '{print $3}' | awk -F '.' '$1>10'` ];then echo "Configuring CUPS"; su -c 'dpkg -i libcupsys2_1.3.9-17ubuntu3.9_all.deb' >> /tmp/canon-printing_Install.log 2>&1 fi echo " Building BNJ Networking" su -c './configure && make && make install' >> /tmp/canon-printing_Install.log 2>&1 echo " Installing Printer Packages" su -c 'dpkg -i cnijfilter-common_3.00-1_all.deb' >> /tmp/canon-printing_Install.log 2>&1 su -c 'dpkg -i cnijfilter-ip1800series_2.70-universal.deb' >> /tmp/canon-printing_Install.log 2>&1 su -c 'dpkg -i cnijfilter-mp630series_3.00-1_all.deb' >> /tmp/canon-printing_Install.log 2>&1 echo " Installing Scanner Packages" su -c 'dpkg -i scangearmp-common_1.20-1_all.deb' >> /tmp/canon-printing_Install.log 2>&1 su -c 'dpkg -i scangearmp-mp630series_1.20-1_all.deb' >> /tmp/canon-printing_Install.log 2>&1 echo " Restarting CUPS" if [ -f /etc/init.d/cups ];then su -c '/etc/init.d/cups restart' >> /tmp/canon-printing_Install.log 2>&1 fi su -c 'service cups restart' >> /tmp/canon-printing_Install.log 2>&1 echo " Moving Universal PPD file into place for Use" su -c 'cp canonmp620-630_Universal.ppd /usr/share/ppd/canonmp620-630_Universal.ppd' su -c 'cp canonip1800_Universal.ppd /usr/share/ppd/canonip1800_Universal.ppd' echo '' echo " Creating Log file for the installation of the Drivers. This Log is in the /canon-install.log/ Folder" su -c "mv /tmp/canon-printing_Install.log /canon-install.log/canon-printing-Install-${DATE}.txt" > /dev/null 2>&1 su -c 'chmod -R 777 /canon-install.log' clear echo " Enter the IP address for the printer. If you do not know it, or if you are using a dynamic IP address leave it Blank. This entry has been shown to improve the speed of the scanner. ( Thank you Pierre Chauveau http://free.fr )" echo "After your entry press [ Enter ] to continue." read -p "IP Address : " PRINTERIP echo "# *** # Printer IP Address # *** # ${PRINTERIP}" >> /etc/hosts clear echo "" echo '********* READ THIS AND PAY ATTENTION *********' sleep 3 echo 'The Printer configuration and Setup window will now Open' echo '' echo 'Once it opens click add' echo '' echo 'The Canon Printers that you have installed should show up as Printers now.' echo 'Select the printer that has been found and click Next' echo 'The Printer configuration should recognize the Printer' echo 'Drivers should be automatically found and guild you through the install.' echo 'Once you have finished the setup from the Printer window close the window.' echo 'This will conclude the installer.' echo '' echo '********* READ THIS AND PAY ATTENTION *********' read -p "Press [ Enter ] to Continue" system-config-printer > /dev/null 2>&1 clear echo '' echo "" echo "A log file has been placed in the directory /canon-install.log/" echo "Please refer to this LOG file for any Installation Errors" echo "" echo 'This script was created by Kevin Carter For More information' echo 'Or if you have questions or comments on this installation' echo 'Please let me know, I want to here from you...' echo '' echo 'Goto http://rackerua.com' echo '' exit 0