Mojave Upgrade Broke SMB Automount

Kmartin
New Contributor III

Recently we started upgrading our users to 10.14.3 and what I have noticed is that the script that was in place to auto-mount some SMB shares at logon does not fully function anymore. It will mount the AD home share. but the other 3 shares are not mounted. This worked previous on 10.13.6 without issues.

#!/bin/bash
# 2017 Version Samuel Look
# All care no responsibility
# Mounts the requested share if it doesn't already exist if left blank it will attempt to mount AD SMBhome
# Accepts shares in the form smb://server/share or smb://server/student%20share
#                                                       No spaces allowed!
# Intended to be run as a Login policy from Casper on AD bound machines only and has only been tested in this context.
# 2018 Version Hamish Ward
#       log file
#       share paths accepted from all script parameters

Current_User=$(id -un)

logfile="/var/log/ShareMount.log"
exec >$logfile
exec 2> >(tee -a $logfile >&2)

##### Start seperate process #####
(

##### SUBROUTINES #####

Share_Path_Valid() {
if [[ -z "$Share_Path" ]]; then
Machine_Domain=$(dscl /Active Directory/ -read . SubNodes | awk '{print $2}')
Share_Path="$(dscl "/Active Directory/$Machine_Domain/All Domains" -read /Users/$Current_User SMBHome | awk '!/is not valid/' | sed -e 's/SMBHome: /smb:/g' -e 's/\///g')"
fi
if [[ "$Share_Path" ]]; then
logger "Sharemount:$Share_Name Path check PASS $Share_Path"
return 0
else
logger "Sharemount:$Share_Name Path check FAIL"
return 1
fi
}

#####

User_Ready() {
Loop_End=$((SECONDS + 60))
Current_User=$(stat -f%Su /dev/console | awk '!/root/')
while [[ -z "$Current_User" ]] && [[ $SECONDS -lt $Loop_End ]]; do
sleep 10
Current_User=$(stat -f%Su /dev/console | awk '!/root/')
done
if [[ "$Current_User" ]]; then
logger "Sharemount:$Share_Name User check PASS $Current_User"
return 0
else
logger "Sharemount:$Share_Name User check FAIL"
return 1
fi
}

#####

Finder_Ready() {
Loop_End=$((SECONDS + 60))
while [[ -z "$(ps -c -u $Current_User | awk /CoreServicesUIAgent/)" ]] && [[ $SECONDS -lt $Loop_End ]]; do
sleep 10
done
if [[ "$(ps -c -u $Current_User | awk /Finder/)" ]]; then
logger "Sharemount:$Share_Name Finder check PASS"
return 0
else
logger "Sharemount:$Share_Name Finder check FAIL"
return 1
fi
}

#####

Not_Mounted() {
if [[ -z "$(mount | awk '/'$Current_User'/ && //'$Share_Name' /')" ]]; then
logger "Sharemount:$Share_Name Mount check PASS $Share_Name"
return 0
else
logger "Sharemount:$Share_Name Mount check FAIL already mounted"
return 1
fi
}

#####

Mount_Drive() {
True_Path=$(echo $Share_Path | sed 's//////'$Current_User'@/g')
logger "Sharemount:$Share_Name Attempting to mount $True_Path"
sudo -u $Current_User osascript -e 'mount volume "'$True_Path'"'
}

##### START #####

# escape parameter values in curly braces, else double digit parameters (10-11) be ignored!
if [ "${4}" != "" ]; then
    Share_Path="${4}"
        Share_Name="$(echo $Share_Path | awk -F"/" '{print $NF}')"
        if User_Ready && Finder_Ready && Share_Path_Valid && Not_Mounted; then
        sleep 4
        Mount_Drive
        else
        logger "Sharemount:$Share_Name Conditions not met to attempt drive mounting $Share_Path"
        fi
fi

if [ "${5}" != "" ]; then
    Share_Path="${5}"
        Share_Name="$(echo $Share_Path | awk -F"/" '{print $NF}')"
        if User_Ready && Finder_Ready && Share_Path_Valid && Not_Mounted; then
        sleep 4
        Mount_Drive
        else
        logger "Sharemount:$Share_Name Conditions not met to attempt drive mounting $Share_Path"
        fi
fi

if [ "${6}" != "" ]; then
    Share_Path="${6}"
        Share_Name="$(echo $Share_Path | awk -F"/" '{print $NF}')"
        if User_Ready && Finder_Ready && Share_Path_Valid && Not_Mounted; then
        sleep 4
        Mount_Drive
        else
        logger "Sharemount:$Share_Name Conditions not met to attempt drive mounting $Share_Path"
        fi
fi

if [ "${7}" != "" ]; then
    Share_Path="${7}"
        Share_Name="$(echo $Share_Path | awk -F"/" '{print $NF}')"
        if User_Ready && Finder_Ready && Share_Path_Valid && Not_Mounted; then
        sleep 4
        Mount_Drive
        else
        logger "Sharemount:$Share_Name Conditions not met to attempt drive mounting $Share_Path"
        fi
fi

if [ "${8}" != "" ]; then
    Share_Path="${8}"
        Share_Name="$(echo $Share_Path | awk -F"/" '{print $NF}')"
        if User_Ready && Finder_Ready && Share_Path_Valid && Not_Mounted; then
        sleep 4
        Mount_Drive
        else
        logger "Sharemount:$Share_Name Conditions not met to attempt drive mounting $Share_Path"
        fi
fi

if [ "${9}" != "" ]; then
    Share_Path="${9}"
        Share_Name="$(echo $Share_Path | awk -F"/" '{print $NF}')"
        if User_Ready && Finder_Ready && Share_Path_Valid && Not_Mounted; then
        sleep 4
        Mount_Drive
        else
        logger "Sharemount:$Share_Name Conditions not met to attempt drive mounting $Share_Path"
        fi
fi

if [ "${10}" != "" ]; then
    Share_Path="${10}"
        Share_Name="$(echo $Share_Path | awk -F"/" '{print $NF}')"
        if User_Ready && Finder_Ready && Share_Path_Valid && Not_Mounted; then
        sleep 4
        Mount_Drive
        else
        logger "Sharemount:$Share_Name Conditions not met to attempt drive mounting $Share_Path"
        fi
fi

if [ "${11}" != "" ]; then
    Share_Path="${11}"
        Share_Name="$(echo $Share_Path | awk -F"/" '{print $NF}')"
        if User_Ready && Finder_Ready && Share_Path_Valid && Not_Mounted; then
        sleep 4
        Mount_Drive
        else
        logger "Sharemount:$Share_Name Conditions not met to attempt drive mounting $Share_Path"
        fi
fi


##### End seperate process #####
) &

##### FIN #####
0 REPLIES 0