X-Git-Url: https://git.slaskete.net/einar-bin/blobdiff_plain/141d0834054cb6edcfdb23a6905d71628d395205..6f15241f600e83ff7ebfaede5a398baf454bb097:/addfollowmeprint.sh?ds=sidebyside diff --git a/addfollowmeprint.sh b/addfollowmeprint.sh index 1c710b3..d435289 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,21 @@ 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 +fi + # Finally we can add the printer # The Linux way @@ -254,7 +268,7 @@ if [ "${Uname}" = "darwin" ]; then # Add credentials to the keychain if they are missing # Shamelessly stolen from https://github.com/Orakeltjenesten/scripts/blob/33abfb353524f449f0bbdee27adb2f1f0a9756a2/print/ntnuprint-mac.sh if ! security find-internet-password -s ${PrintServer} >/dev/null 2>&1; then - security -v add-internet-password -a "${WorkGroup}\\${Username}" -s ${PrintServer} \ + security -v add-internet-password -a "${Workgroup}\\${Username}" -s ${PrintServer} \ -w "${Password}" -D "Network Password" -r "smb " -l "${QueueName}" \ -T /System/Library/CoreServices/NetAuthAgent.app -T 'group://NetAuth' \ -T /System/Library/CoreServices/NetAuthAgent.app/Contents/MacOS/NetAuthSysAgent >/dev/null 2>&1