X-Git-Url: https://git.slaskete.net/einar-bin/blobdiff_plain/141d0834054cb6edcfdb23a6905d71628d395205..906b740710a160ed1e95dcd001c1c658fa7b0347:/addfollowmeprint.sh?ds=inline diff --git a/addfollowmeprint.sh b/addfollowmeprint.sh index 1c710b3..23edde8 100755 --- a/addfollowmeprint.sh +++ b/addfollowmeprint.sh @@ -209,7 +209,6 @@ stty "${Settings}" echo "" # Some further tests for Linux systems -# TODO: Add similar tests for macOS if [ "${Uname}" = "linux" ]; then echo -e "\nNOTE: Your credentials will be stored in plaintext in /etc/cups/printers.conf.\nThis file us usually not readable for normal users, but still:\nDo not use this script on multi user systems!" # Test for valid username and password if on Linux @@ -228,6 +227,20 @@ if [ "${Uname}" = "linux" ]; then fi fi +# Similar tests for OSX +if [ "${Uname}" = "darwin" ]; then + smbutil view -A "//${Workgroup};${Username}:${Password}@${PrintServer}" > /dev/null 2>&1 + if [ $? -ne 0 ]; then + printerror "User name or password incorrect, or no contact with the print server ${PrintServer}." + exit 1 + fi + ShareFound=$(smbutil view "//${Workgroup};${Username}:${Password}@${PrintServer}" 2>/dev/null | grep ${PrintShare} | cut -d " " -f 1) + if [ "${ShareFound}" != "${PrintShare}" ]; then + printerror "Could not find printer share called ${PrintShare} on the server" + printerror "This script must be broken or outdated. Please contact orakel@ntnu.no for further assistance." + exit 1 + fi + # Finally we can add the printer # The Linux way