Snippets
Kevin Klement Script to install drivers and configure UMass philosophy Toshiba printer on Linux and Mac
Revised by
Kevin Klement
192adec
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 | #!/bin/bash # function for exiting midway function rage_quit { cat > /dev/stderr << EOF Unfortunately, the script encountered an error. You may need to ask for help. EOF exit 1 } # check if we're running linux if [[ "$(uname)" =~ "Linux" ]] ; then LINUX="yes" DRIVERLOC="/usr/share/cups/model/Toshiba/TOSHIBA_MonoMFP_CUPS.gz" else LINUX="no" DRIVERLOC="/Library/Printers/PPDs/Contents/Resources/TOSHIBA_MonoMFP_X7.gz" fi cat << EOF Welcome to the philosophy printer install script. First I need some info from you. EOF echo -n "What is your UMass NetID? " read NETID # ensure cups folder exists mkdir -p $HOME/.cups > /dev/null 2>&1 # check if username already in cups folder; if not, add it if [[ ! -e "$HOME/.cups/client.conf" ]] || ! grep -q "User $NETID" $HOME/.cups/client.conf ; then echo "User $NETID" >> $HOME/.cups/client.conf fi # check if CUPS username already loaded by .bash_profile; if not edit it if [[ ! -e "$HOME/.bash_profile" ]] || ! grep -q "export CUPS_USER=$NETID" $HOME/.bash_profile ; then echo "export CUPS_USER=$NETID" >> $HOME/.bash_profile fi cat << EOF I need your accounting codes. If you have more than one please separate them with commas, e.g.: 1234,5678 If you want to set one as default, list it first. EOF DEFAULTSET="no" echo -n "Your codes? " # the IFS variable sets delimiters between array generated by read -a (comma and space) IFS=", " read -a CODES # Time to fetch and install the driver package from Toshiba # checks if driver is already in place; skip this section if it is if [[ ! -e "$DRIVERLOC" ]] ; then if [[ "$LINUX" == "yes" ]] ; then cat << EOF The driver is about to be downloaded and installed. You may need to enter your password (for sudo on the local machine). EOF sudo bash << EOF cd / && curl -O http://business.toshiba.com/downloads/KB/f1Ulds/16770/TOSHIBA_MonoMFP_CUPS.tar && tar xf TOSHIBA_MonoMFP_CUPS.tar EOF else cat << EOF An installer for the driver is about to download and open. If you need help, consult pages 90-93 of this PDF (starting from step 6, and ending at step 13; do not move on to pages 94 or later...) https://www.toshiba-business.com.au/-/media/Sharepoint/Guides/MFD-Guides/Software-Installation-Guide-eBN2.pdf When you are done, return to the terminal, and finish using this script. You need to do so to set things up to use your accounting codes. Press any key to start the installation or Ctrl-C to quit. EOF read -s -n 1 whateva cd /tmp echo Downloading driver... curl --silent -O "http://business.toshiba.com/downloads/KB/f1Ulds/17022/TOSHIBA_MonoMFP.dmg.gz" || rage_quit echo Unzipping driver package... gunzip TOSHIBA_MonoMFP.dmg.gz || rage_quit echo Mounting driver image... hdiutil attach TOSHIBA_MonoMFP.dmg > /dev/null 2>&1 || rage_quit echo Opening installer... open /Volumes/TOSHIBA\ MonoMFP/TOSHIBA\ MonoMFP.pkg > /dev/null 2>&1 || rage_quit cat <<EOF Press a key when you are done with the graphical installer. EOF read -s -n 1 whateva echo Unmounting driver image... hdiutil detach /Volumes/TOSHIBA\ MonoMFP fi fi for CODE in ${CODES[@]} ; do cat <<EOF Setting up printer option: Philosophy-Toshiba-$CODE" The script may ask you for a password. This is the password used for installing software on your computer, NOT your UMass password. EOF sudo lpadmin -p "Philosophy-Toshiba-$CODE" -E -v lpd://$NETID@128.119.194.18 -o printer_is_shared=false -o auth-info-required=username,password -o media=letter -o password=$CODE -o user=$NETID -o Pedestal=Drawer12L -o Finisher=Saddle2+1 -P $DRIVERLOC > /dev/null 2>&1 || rage_quit if [[ $DEFAULTSET == "no" ]] ; then echo making default sudo lpadmin -d "Philosophy-Toshiba-$CODE" || rage_quit DEFAULTSET="yes" fi echo Enabling jobs... sudo cupsenable -U "$NETID" Philosophy-Toshiba-$CODE echo Accepting jobs... sudo cupsaccept -U "$NETID" Philosophy-Toshiba-$CODE echo "Printer option Philosophy-Toshiba-$CODE set up" done cat << EOF You should be all set. Select the printer name that includes the code as part of the name, as listed above. Your computer may create a duplicate printer without the code included in its name. That one probably won't work. Also your printer may ask for your username and password the first time. Use your UMass netid and the account code as the password, though I'm not sure this prompt actually does anything, hence the need to provide the code during this setup process. You probably need to reboot and/or restart your individual applications before they work completely. Press Ctrl-D or type "exit" to close this terminal window. EOF exit 0 |
You can clone a snippet to your computer for local editing. Learn more.