diff options
| -rwxr-xr-x | etc/mklocaluser.d/60-itzks-systems-roamingworkstation_smb-bookmarks | 53 | 
1 files changed, 40 insertions, 13 deletions
| diff --git a/etc/mklocaluser.d/60-itzks-systems-roamingworkstation_smb-bookmarks b/etc/mklocaluser.d/60-itzks-systems-roamingworkstation_smb-bookmarks index dc850e0..a545530 100755 --- a/etc/mklocaluser.d/60-itzks-systems-roamingworkstation_smb-bookmarks +++ b/etc/mklocaluser.d/60-itzks-systems-roamingworkstation_smb-bookmarks @@ -18,25 +18,52 @@ add_gtk3_place() {  case "$ORIGHOMEDIR" in  	/*/*/*) -		homepath="$(ldapsearch -LLL -x "(&(uid=$USER)(sambaHomePath=*))" sambaHomePath | awk '/sambaHomePath: / { print $2 }')" -		if [ "$homepath" ] ; then -			sambaSID="$(ldapsearch -LLL -x "(&(uid=$USER)(sambaSID=*))" sambaSID | awk '/sambaSID: / { print $2 }')" -			if [ "$sambaSID" ]; then -				sambaDomainSID=$(echo $sambaSID | cut -d"-" -f1-7) -				SMBDOMAIN="$(ldapsearch -LLL -x "(&(sambaDomainName=*)(sambaSID=$sambaSID))" sambaDomainName | awk '/sambaDomainName: / { print $2 }');" -			fi +		# Extract FQDN from home directory path (we assume a /skole/<server>/homeX/<user> pattern here) +		SERVER="$(getent hosts $(echo $ORIGHOMEDIR | cut -d/ -f3) | head -n1 | awk '{print $2}')" + +		SMBDOMAIN="" +		sambaSID="$(ldapsearch -LLL -x "(&(uid=$USER)(sambaSID=*))" sambaSID 2>/dev/null | head -n1 | awk '/sambaSID: / { print $2 }' || true)" +		if [ "$sambaSID" ]; then +			sambaDomainSID=$(echo $sambaSID | cut -d"-" -f1-7) +			SMBDOMAIN="$(ldapsearch -LLL -x "(&(sambaDomainName=*)(sambaSID=$sambaSID))" sambaDomainName 2>/dev/null | head -n1 | awk '/sambaDomainName: / { print $2 }' || true);" +		fi + +		if [ "$SMBDOMAIN" ]; then + +			# looks like we (still) have a Samba Domain in LDAP, so let's use it + +			homepath="$(ldapsearch -LLL -x "(&(uid=$USER)(sambaHomePath=*))" sambaHomePath 2>/dev/null | head -n1 | awk '/sambaHomePath: / { print $2 }' || true)" +			if [ "$homepath" ] ; then + +				SMBPATH=$(echo "smb:$homepath" | sed -e "s|\\\\|//|" -e "s|\\\\|/|" | sed -e "s|smb://|smb://$SMBDOMAIN$USER@|") + +				# Update server name from homepath (via SMBPATH) +				SERVER="$(echo $SMBPATH | cut -d "@" -f2 | cut -d/ -f1)" + +			else -			SMBPATH=$(echo "smb:$homepath" | sed -e "s|\\\\|//|" -e "s|\\\\|/|" | sed -e "s|smb://|smb://$SMBDOMAIN$USER@|") -			SERVER="$(echo $SMBPATH | cut -d "@" -f2 | cut -d/ -f1)" +				# no sambaHomePath given per user; let's guess it... +				SMBPATH="smb://$SMBDOMAIN$USER@$SERVER/$USER" + +				# and use sever as detected above from ORIGHOMEDIR... + +			fi  		else -			# Extract FQDN from home directory path -			SERVER="$(getent hosts $(echo $ORIGHOMEDIR | cut -d/ -f3) | awk '{print $2}')" + +			# probably no Samba Domain in LDAP (anymore)  			# get the SMBDOMAIN fallback from smb.conf first, but try LDAP later on -			if [ -e /etc/samba/smb.conf ] && grep -q -i "\s*workgroup\s*=\s*" /etc/samba/smb.conf; then -				SMBDOMAIN="$(grep -i -E '\s*workgroup\s*=' /etc/samba/smb.conf | sed -re 's/\s*workgroup\s*=\s*(.*)\s*$/\1/' -e "s/\s+//g");" +			if [ -e /etc/debian-edu/itzks.school ]; then + +				# fallback / cosmetic fix, use school tag as domain +				SMBDOMAIN="$(cat /etc/debian-edu/itzks.school | head -n1);" + +			else + +				SMBDOMAIN="SCHULE;" +  			fi  			SMBPATH="smb://$SMBDOMAIN$USER@$SERVER/$USER" | 
