aboutsummarylogtreecommitdiffstats
diff options
context:
space:
mode:
authordjsavvy2017-04-13 08:24:51 -0400
committerdjsavvy2017-04-13 08:24:51 -0400
commit102bc0ac2f1386a59186d28b51be3e1a1cefeead (patch)
treebcafac54128a3056e13c09e48d21c893bebe072e
parent25693c63b60b9a8f31c5003b6979917d8ba6199b (diff)
downloadaur-102bc0ac2f1386a59186d28b51be3e1a1cefeead.tar.gz
Updated script to be more error-resistant; made README more detailed.
-rw-r--r--README.md6
-rw-r--r--harvard-linux-printer.log0
-rwxr-xr-xharvard-linux-printer.sh41
3 files changed, 38 insertions, 9 deletions
diff --git a/README.md b/README.md
index ec60b93fa2ab..beee501c25f1 100644
--- a/README.md
+++ b/README.md
@@ -19,11 +19,13 @@ sudo ./harvard-linux-printer.sh
Note that you need to know your PaperCut username and password, which can be different from your my.harvard login information.
-The printer connections are preserved across restarts (unlike with the Windows setup), so you can delete the script after it has been run.
+The printer connections are preserved across restarts (unlike with the Windows setup), so you can delete the script after it has been run. Also, running the script multiple times will not create duplicate printer entries, but rather overwrite existing printers with the same names.
## Known Issues
-If your PaperCut username or password contains a colon or percent sign, then the script might fail.
+- If your PaperCut username or password contains a colon or percent sign, then the script will fail to authenticate.
+- If printing from Chrome, it is recommended to use the system print dialog (`Ctrl + Shift + P`) rather than Chrome's built-in one. In particular, printing to a color printer from within Chrome results in a black-and-white image.
+- Duplex printing is not available on all printers.
Please report any bugs [here](https://github.com/djsavvy/harvard-linux-printer/issues). \ No newline at end of file
diff --git a/harvard-linux-printer.log b/harvard-linux-printer.log
new file mode 100644
index 000000000000..e69de29bb2d1
--- /dev/null
+++ b/harvard-linux-printer.log
diff --git a/harvard-linux-printer.sh b/harvard-linux-printer.sh
index 5d7fd3a6c691..62aab77a1d8b 100755
--- a/harvard-linux-printer.sh
+++ b/harvard-linux-printer.sh
@@ -1,6 +1,6 @@
#!/bin/bash
-echo "Installing dependencies..."
+sudo echo "Installing dependencies..."
sudo apt-get update > /dev/null
sudo apt-get install cups-client cups-server-common smbclient > /dev/null
@@ -17,21 +17,48 @@ printf "\n"
read -p "Enter your PaperCut username: " papercut_username
read -sp "Enter your PaperCut password: " papercut_password
+while [[ $papercut_username != ${papercut_username/ /} || $papercut_password != ${papercut_password/ /} ]]; do
+ echo "Username and password cannot contain spaces. Please try again."
+ printf "\n"
+ read -p "Enter your PaperCut username: " papercut_username
+ read -sp "Enter your PaperCut password: " papercut_password
+done
+
+
sudo sed -i '/syslog/d' /etc/samba/smb.conf
# sudo echo "logging = syslog@0 file" >> /etc/samba/smb.conf
{
IFS=$'\n'
- print1_array=$(smbclient -L //HUIT-PPC-Print1.fas.harvard.edu -U FAS_DOMAIN/$papercut_username"%"$papercut_password | awk '!/\$/ && !/faculty/ && !/NetBIOS/ && !/Connection/ && !/Sharename/ && !/\-\-/ {print $1}')
-} &> /dev/null
+ print1_array=$(smbclient -L //HUIT-PPC-Print1.fas.harvard.edu -U FAS_DOMAIN/$papercut_username"%"$papercut_password | awk '!/\$/ && !/faculty/ && !/NetBIOS/ && !/session/ && !/Connection/ && !/Sharename/ && !/\-\-/ {print $1}')
+} &> ./harvard-linux-printer.log
printf "\n"
+worked=false
+
+# echo $print1_array
+
+for x in $print1_array; do
+ if [ $x ];
+ then
+ worked=true
+ fi
+done
+
+if [ "$worked" = false ];
+ then
+ echo "Authentication error. Please make sure you entered your credentials correctly. Note that at this time passwords containing % or : cannot successfully authenticate."
+ echo "If you suspect there is a bug, please submit a bug report at https://github.com/djsavvy/harvard-linux-printer/issues and upload the file harvard-linux-printer.log."
+ exit 1
+fi
+
+
echo "Connected to HUIT-PPC-Print1."
{
for x in $print1_array; do
- if [ $x ]
+ if [ $x ];
then
sudo lpadmin -p $x -E -v smb://$papercut_username:$papercut_password@FAS_DOMAIN/HUIT-PPC-Print1.fas.harvard.edu/$x
fi
@@ -40,18 +67,18 @@ echo "Connected to HUIT-PPC-Print1."
echo "Added printers from HUIT-PPC-Print1."
-printf "\n"
+# printf "\n"
{
IFS=$'\n'
- print2_array=$(smbclient -L //HUIT-PPC-Print2.fas.harvard.edu -U FAS_DOMAIN/$papercut_username"%"$papercut_password | awk '!/\$/ && !/faculty/ && !/NetBIOS/ && !/Connection/ && !/Sharename/ && !/\-\-/ {print $1}')
+ print2_array=$(smbclient -L //HUIT-PPC-Print2.fas.harvard.edu -U FAS_DOMAIN/$papercut_username"%"$papercut_password | awk '!/\$/ && !/faculty/ && !/NetBIOS/ && !/session/ && !/Connection/ && !/Sharename/ && !/\-\-/ {print $1}')
} &> /dev/null
echo "Connected to HUIT-PPC-Print2."
{
for x in $print2_array; do
- if [ $x ]
+ if [ $x ];
then
sudo lpadmin -p $x -E -v smb://$papercut_username:$papercut_password@FAS_DOMAIN/HUIT-PPC-Print2.fas.harvard.edu/$x
fi