The script below will install a CAPS printer for people who are not logging in to the Linux and OSX computers with their UPI. It is often useful for visitors to the university who have their laptops with accounts not using their UPI as the login to their computer even though they may have a UPI provided by the university. The script requires root access to run so will not be useable if the user does not have admin rights. Originally written by Mat Carr.
To implement the script just copy and paste the provided script into a suitably named file such as “installprinter.sh” . In this example the nano editor is used in a terminal window to create a file installprinter.sh, copy the script contents into the file then change the file to being executable and finally run.
nano installprinter.sh # This command in a terminal starts the nano editor and creates a file installprinter.sh #Copy in contents of the script below into the installprinter.sh chmod +x installprinter.sh # This command in the terminal and same directory as installprinter.sh makes the file you have pasted the script into executable, otherwise you cannot run the file. sudo ./installprinter.sh # This command in the terminal and same directory as installprinter.sh runs the script contained in the file and installs the printer.
The shell script below (e.g. place in an executable file such as installprinter.sh) should be run as root in bash (ie. $ sudo path/to/script.sh).
The script has been tested in OS X 10.8, 10.9 and Ubuntu 12.04LTS.
The Ubuntu environment does not understand the default duplex setting, but double siding is certainly a user accessible option through the printing interface.
#!/bin/bash LIBRARY=/Library MANAGEMENT=$LIBRARY/Management PPDHOME=$MANAGEMENT/ppd IAM=`whoami` WHICH=`uname` echo $WHICH if [[ $WHICH == "Darwin" ]]; then # MacOS X (probably) WGETCURL=curl -o WGETSHORT=curl -o - else # Probably linux WGETCURL=wget -O WGETSHORT=wget -q -O - fi if [ "$IAM" = "root" ]; then # bwa ha ha # check for existing directores # and create any missing ones # Ubuntu 12.x needed this check if [ ! -e /etc/cups/interfaces ]; then mkdir /etc/cups/interfaces chmod 755 /etc/cups/interfaces fi # Check for and fill out # SIT management folders if [ ! -e $LIBRARY ]; then mkdir $LIBRARY chmod -R 775 $LIBRARY fi if [ ! -e $MANAGEMENT ]; then mkdir $MANAGEMENT chmod -R 775 $MANAGEMENT fi if [ ! -e $PPDHOME ]; then mkdir $PPDHOME chmod -R 775 $PPDHOME fi # grab a copy of the PS PPD # and the generic variant # from our WWW server # Ubuntu has wget, MacOS X has curl $WGETCURL $PPDHOME/ricuoaps.ppd https://www.sit.auckland.ac.nz/delivery/valuables/foscolourlaser/ppd/300/ricuoaps.ppd $WGETCURL $PPDHOME/ricbw2up.ppd https://www.sit.auckland.ac.nz/delivery/valuables/foscolourlaser/ppd/300/ricbw2up.ppd # People need access chmod 644 $PPDHOME/*.ppd # which of the many spoolers should be used? SPOOLER=`$WGETSHORT https://www.sit.auckland.ac.nz/sso/tools/spooler/` if [ "$SPOOLER" = "" ]; then SPOOLER=uoaprnp01 fi # build the printers lpadmin -p caps-colour -E -L Everywhere -D CAPS Colour/simplex -P $PPDHOME/ricuoaps.ppd -v lpd://$SPOOLER.uoa.auckland.ac.nz/lp lpadmin -p caps-bandw -E -L Everywhere -D CAPS Grey/duplex -P $PPDHOME/ricbw2up.ppd -v lpd://$SPOOLER.uoa.auckland.ac.nz/lp else # duh echo "you need to run this as root, try sudo $0" exit 1 fi exit 0