mac_install_printers.sh 6.73 KB
Newer Older
testing testuser's avatar
testing testuser committed
1 2 3 4 5 6
#!/bin/sh
# This script installs the floor printers on a Macintosh computer.
# Written by Jean St-Laurent

# Check if the RICOH driver is present
# Install it it's not found
7
c4502path='/Library/Printers/PPDs/Contents/Resources/RICOH Aficio MP C4502A.gz'
testing testuser's avatar
testing testuser committed
8 9
c4502finisher=${c4502path%.gz}\ Finisher.gz
c4502unzip=${c4502finisher%.gz}
10
c4503path='/Library/Printers/PPDs/Contents/Resources/RICOH MP C4503.gz'
testing testuser's avatar
testing testuser committed
11 12
c4503finisher=${c4503path%.gz}\ Finisher.gz
c4503unzip=${c4503finisher%.gz}
13 14 15
c4504path='/Library/Printers/PPDs/Contents/Resources/SAVIN MP C4504'
c4504finisher=${c4504path}
c4504unzip=${c4504finisher}
16

17
if [ ! -f "$c4502path" ] || [ ! -f "$c4503path" ] || [ ! -f "$c4504path" ];
testing testuser's avatar
testing testuser committed
18 19
then
   # Check osx version and if Snow Leopard or less don't use dfs
20 21 22 23 24 25 26 27
   # macversion=`sw_vers -productVersion | cut -d "." -f 2`
   # if [ $macversion -gt 6 ]; then
   #    file="ricoh2.0.0.pkg"
   # else
   #    file="ricoh1.0.3.pkg"
   # fi
   # Download the printer files for Mac
   curl -o ~/ricoh.pkg https://git.ist.ac.at/support/software/raw/master/ricoh-printer-drivers.pkg > /dev/null 2>&1
28
   curl -o ~/ricoh-c4504.pkg https://git.ist.ac.at/support/software/raw/master/ricoh-c4504.pkg > /dev/null 2>&1
testing testuser's avatar
testing testuser committed
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
   # If fails it probably means that the network is not connected and send an error message to the user.
   if [ ! $? == 0 ];
   then
      echo "It seems that you are not connected to the IST network."
      echo "If you are outside the institution, make sure your vpn connection is established."
      read ok
      exit 1
   fi
fi

# Ask for the admin rights from the user and loop until he really type the good password.
sudo -p "Please enter your Mac login password:" echo
while [ $? -gt 0 ]; do
   sudo -p "Wrong password. Please enter your Mac login password:" echo
done

echo "Please be patient while the printers are being installed."

# Install RICOH drivers
if [ -f ~/ricoh.pkg ];
then
   sudo -S installer -pkg ~/ricoh.pkg -target / > /dev/null 2>&1
fi
52 53
if [ -f ~/ricoh-c4504.pkg ];
then
54
   sudo -S installer -pkg ~/ricoh-c4504.pkg -allowUntrusted -target / > /dev/null 2>&1
55
fi
56 57 58 59
# Verify that we have a special driver with the options
# finisher SR3110 (FinEUPHRATESFBK) for c4502a
# DefaultOptionTray -> 2Cassette (lower paper trays)
if [ ! -f "$c4502finisher" ];
testing testuser's avatar
testing testuser committed
60
then
61 62
   sudo cp -p "$c4502path" "$c4502finisher"
   sudo gunzip -v "$c4502finisher"
testing testuser's avatar
testing testuser committed
63 64 65
   sudo sed -i '' 's/DefaultFinisher: NotInstalled/DefaultFinisher: FinEUPHRATESFBK/g' "$c4502unzip"
   sudo sed -i '' 's/DefaultOptionTray: NotInstalled/DefaultOptionTray: 2Cassette/g' "$c4502unzip"
   sudo gzip -v "$c4502unzip"
testing testuser's avatar
testing testuser committed
66 67
fi

68 69 70 71 72 73 74
# Verify that we have a special driver with the options
# finisher SR3150 (FinAMURBK) for c4503
# DefaultOptionTray -> 2Cassette (lower paper trays)
if [ ! -f "$c4503finisher" ];
then
   sudo cp -p "$c4503path" "$c4503finisher"
   sudo gunzip -v "$c4503finisher"
testing testuser's avatar
testing testuser committed
75 76 77
   sudo sed -i '' 's/DefaultFinisher: NotInstalled/DefaultFinisher: FinAMURBK/g' "$c4503unzip"
   sudo sed -i '' 's/DefaultOptionTray: NotInstalled/DefaultOptionTray: 2Cassette/g' "$c4503unzip"
   sudo gzip -v "$c4503unzip"
78
fi
79

80 81 82
# Verify that we have a special driver with the options
# finisher SR3150 (FinAMURBK) for c4504
# DefaultOptionTray -> 2Cassette (lower paper trays)
83
# NOT YET WORKING
84 85 86 87 88 89 90 91 92 93
if [ ! -f "$c4504finisher" ];
then
   sudo cp -p "$c4504path" "$c4504finisher"
   sudo gunzip -v "$c4504finisher"
   sudo sed -i '' 's/DefaultFinisher: NotInstalled/DefaultFinisher: FinAMURBK/g' "$c4504unzip"
   sudo sed -i '' 's/DefaultOptionTray: NotInstalled/DefaultOptionTray: 2Cassette/g' "$c4504unzip"
   sudo gzip -v "$c4504unzip"
fi


testing testuser's avatar
testing testuser committed
94
# Add the printers to the MAC. Should we loop through a file? Maybe... let's see
95 96 97 98 99 100 101 102
sudo lpadmin -p printer-I01-1st -D "Central Building 1st floor" -L "Central Building 1st floor" -E -v socket://p0117101.ista.local:9100 -P "$c4502finisher" -o printer-is-shared=false
sudo lpadmin -p printer-I01-2nd -D "Central Building 2nd floor" -L "Central Building 2nd floor" -E -v socket://p0117102.ista.local:9100 -P "$c4502finisher" -o printer-is-shared=false
sudo lpadmin -p printer-I01-3rd -D "Central Building 3rd floor" -L "Central Building 3rd floor" -E -v socket://p0117103.ista.local:9100 -P "$c4502finisher" -o printer-is-shared=false
sudo lpadmin -p printer-I04-1st -D "Bertalanffy Building 1st floor" -L "Bertalanffy Building 1st floor" -E -v socket://p0417101.ista.local:9100 -P "$c4502finisher" -o printer-is-shared=false
sudo lpadmin -p printer-I04-2nd -D "Bertalanffy Building 2nd floor" -L "Bertalanffy Building 2nd floor" -E -v socket://p0417102.ista.local:9100 -P "$c4502finisher" -o printer-is-shared=false
sudo lpadmin -p printer-I04-3rd -D "Bertalanffy Building 3rd floor" -L "Bertalanffy Building 3rd floor" -E -v socket://p0417103.ista.local:9100 -P "$c4502finisher" -o printer-is-shared=false
sudo lpadmin -p printer-I03-gf -D "Admin Building ground floor" -L "Admin Building ground floor" -E -v socket://p0317100.ista.local:9100 -P "$c4502finisher" -o printer-is-shared=false
sudo lpadmin -p printer-I03-1st -D "Admin Building 1st floor" -L "Admin Building 1st floor" -E -v socket://p0317101.ista.local:9100 -P "$c4502finisher" -o printer-is-shared=false
103
sudo lpadmin -p printer-I06-gf -D "Lab Building East ground floor" -L "Lab Building East ground floor" -E -v socket://p0617100.ista.local:9100 -P "$c4504finisher" -o printer-is-shared=false
104
sudo lpadmin -p printer-I06-1st -D "Lab Building East 1st floor" -L "Lab Building East 1st floor" -E -v socket://p0617101.ista.local:9100 -P "$c4502finisher" -o printer-is-shared=false
105 106 107 108 109 110 111
sudo lpadmin -p printer-I06-2nd -D "Lab Building East 2nd floor" -L "Lab Building East 2nd floor" -E -v socket://p0617102.ista.local:9100 -P "$c4502finisher" -o printer-is-shared=false
sudo lpadmin -p printer-I06-3rd -D "Lab Building East 3rd floor" -L "Lab Building East 3rd floor" -E -v socket://p0617103.ista.local:9100 -P "$c4502finisher" -o printer-is-shared=false
sudo lpadmin -p printer-I21-gf -D "Office Building West ground floor" -L "Office Building West ground floor" -E -v socket://p2117100.ista.local:9100 -P "$c4504finisher" -o printer-is-shared=false
sudo lpadmin -p printer-I21-o1 -D "Office Building West 1st floor" -L "Office Building West 1st floor" -E -v socket://p2117101.ista.local:9100 -P "$c4503finisher" -o printer-is-shared=false
sudo lpadmin -p printer-I21-o2 -D "Office Building West 2nd floor" -L "Office Building West 2nd floor" -E -v socket://p2117102.ista.local:9100 -P "$c4503finisher" -o printer-is-shared=false
sudo lpadmin -p printer-I21-o3 -D "Office Building West 3rd floor" -L "Office Building West 3rd floor" -E -v socket://p2117102.ista.local:9100 -P "$c4503finisher" -o printer-is-shared=false
sudo lpadmin -p printer-I21-bt2-o2 -D "Lab Building West 2nd floor" -L "Lab Building West 2nd floor" -E -v socket://p2117102.ista.local:9100 -P "$c4503finisher" -o printer-is-shared=false
testing testuser's avatar
testing testuser committed
112 113

rm -f ~/ricoh.pkg
114
rm -f ~/ricoh-c4504.pkg