#!/bin/bash function main { if [ $(uname -s) == "Darwin" ]; then echo "Identified client variant as Macintosh" elif [ $(uname -s) == "Linux" ]; then echo "Identified client variant as Linux" if [[ -f /etc/redhat-release ]]; then linux_redhat_packages elif [[ -f /etc/lsb-release ]]; then linux_debian_packages fi fi remove_older_queues install_smb_uos_secure_print } function linux_redhat_packages { echo "Checking for samab-client and cups installation" if ! yum info samba-client | grep -q installed ; then yum install -y samba-client fi if ! yum info cups | grep -q installed ; then yum install -y cups service cups restart fi } function linux_debian_packages { echo "Checking for smbclient and cups installation" if apt-cache policy smbclient | grep -q "Installed: (none)" ; then apt-get install -y -qq smbclient fi if apt-cache policy cups | grep -q "Installed: (none)" ; then apt-get install -y -qq cups service cups restart fi } function remove_older_queues { old_usp_uri="lpd://anuosprt03.uosprinting.com/uos_secure_print" old_mfdo="MFD_OFFICE" if lpstat -t | grep -q $old_usp_uri ; then echo "Found LPD instance of UoS_Secure_Print, this will be removed" lpadmin -x UoS_Secure_Print fi if lpstat -t | grep -q $old_mfdo ; then echo "Found older print service at MFD_OFFICE, this will be removed" lpadmin -x MFD_OFFICE fi } function install_smb_uos_secure_print { # Printer relevant vars q_name=UoS_Secure_Print q_url="smb://anuosprt03.uosprinting.com/$(echo $q_name | tr '[:upper:]' '[:lower:]')" prntr_opts="-o option19=One -o option17=DF770 -o option22=True -o option21=True -o option18=HardDisk" # PPD relevant vars ppd=Kyocera_TASKalfa_6052ci.PPD ppd_loc="http://www.sussex.ac.uk/its/downloads/$ppd" ppd_dir="/tmp" ppd_dest=$ppd_dir/$ppd # Download the PPD for the printer if [[ ! -f $ppd_dest ]]; then echo "Downlaoding PPD for $q_name" curl -s -o $ppd_dest $ppd_loc fi # Installing printer if [[ -f $ppd_dest ]]; then if ! lpstat -p | grep -q $q_name; then echo "Installing $q_name" lpadmin -p $q_name -E -v $q_url -P $ppd_dest $prntr_opts if lpstat -t | grep -q $q_url ; then echo "UoS_Secure_Print installed successfully" else printf "Something went wrong, UoS_Secure_Print could not be installed.\n Please contact IT Services for assistance." exit 1 fi exit 0 else echo "UoS_Secure_Print already installed correctly" exit 0 fi else echo "ERROR: Cannot locate downloaded PPD, not installing printer" exit 1 fi } main # Last Line