summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Gabriel <mike.gabriel@das-netzwerkteam.de>2020-02-08 12:09:05 +0100
committerMike Gabriel <mike.gabriel@das-netzwerkteam.de>2020-02-08 12:09:05 +0100
commitc0b3233a61a894de42471b04f7a924ea6701de90 (patch)
tree25c27892fc010e61735579a7c24df83b64d67632
parent144df81d96c6e6ef5904916966c7aaa12a379209 (diff)
downloaditzks-systems-c0b3233a61a894de42471b04f7a924ea6701de90.tar.gz
itzks-systems-c0b3233a61a894de42471b04f7a924ea6701de90.tar.bz2
itzks-systems-c0b3233a61a894de42471b04f7a924ea6701de90.zip
etc/mklocaluser.d/60-itzks-systems-roamingworkstation_smb-bookmarks: Add CIFS/SMB home share to 'Places' area for GTK-3 based file browsers.
-rwxr-xr-xetc/mklocaluser.d/60-itzks-systems-roamingworkstation_smb-bookmarks36
1 files changed, 36 insertions, 0 deletions
diff --git a/etc/mklocaluser.d/60-itzks-systems-roamingworkstation_smb-bookmarks b/etc/mklocaluser.d/60-itzks-systems-roamingworkstation_smb-bookmarks
new file mode 100755
index 0000000..d7b79f9
--- /dev/null
+++ b/etc/mklocaluser.d/60-itzks-systems-roamingworkstation_smb-bookmarks
@@ -0,0 +1,36 @@
+#!/bin/sh
+
+set -e
+
+# Create GTK/Gnome places bookmark for easy access.
+add_gtk3_place() {
+ SERVER="$1"
+ USER="$2"
+ GROUP="$3"
+ TITLE="$4"
+ SMBPATH="$5"
+ if [ ! grep -q "$SMBPATH $TITLE" "/home/$USER/.config/gtk-3.0/bookmarks" ]; then
+ echo "$SMBPATH $TITLE" >> /home/$USER/.config/gtk-3.0/bookmarks
+ chown $USER:$GROUP /home/$USER/.config/gtk-3.0/bookmarks
+ fi
+}
+
+# FIXME Would be nice if the same bookmark file could be used for both
+# KDE and Gnome
+case "$ORIGHOMEDIR" in
+ /*/*/*)
+ homepath="$(ldapsearch -LLL -x '(&(uid=$USER)(sambaHomePath=*))' sambaHomePath | awk '/sambaHomePath: / { print $2 }')"
+ if [ "$homepath" ] ; then
+ SMBPATH=$(echo "smb:$homepath" | tr '\' /)
+ SERVER="$(echo $SMBPATH | cut -d/ -f3)"
+ else
+ # Extract FQDN from home directory path
+ SERVER="$(getent hosts $(echo $ORIGHOMEDIR | cut -d/ -f3) | awk '{print $2}')"
+ SMBPATH="smb://$SERVER/$USER/"
+ fi
+
+ GROUP="$(id -ng $USER)"
+ TITLE="$USER on $SERVER via SMB"
+ add_gtk3_place "$SERVER" "$USER" "$GROUP" "$TITLE" "$SMBPATH"
+ ;;
+esac