From b8d9886054527f041fd4ea33436afdfd2b6abcc9 Mon Sep 17 00:00:00 2001 From: Raphael Dannecker Date: Thu, 31 Oct 2024 17:28:16 +0100 Subject: [PATCH] Fix dolphin places config (user-places.xbel) Existing dolphin configs can be incorrect for two reasons: - Instead of the class identifier, a * was incorrectly entered in the home@server URL. - If the student has changed classes, the old class name is still in the home URL. lmn-patch-dolphin.sh no longer enters a * in the home@server URL. lmn-fixhome-dolphin.sh will fix existing configs. --- roles/lmn_fvs/files/lmn-dolphin.sh | 3 +++ roles/lmn_fvs/files/lmn-fixhome-dolphin.sh | 20 ++++++++++++++++++++ roles/lmn_fvs/files/lmn-patch-dolphin.sh | 5 +++-- roles/lmn_fvs/tasks/main.yml | 1 + 4 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 roles/lmn_fvs/files/lmn-fixhome-dolphin.sh diff --git a/roles/lmn_fvs/files/lmn-dolphin.sh b/roles/lmn_fvs/files/lmn-dolphin.sh index 7b5d3a3..489e9e7 100644 --- a/roles/lmn_fvs/files/lmn-dolphin.sh +++ b/roles/lmn_fvs/files/lmn-dolphin.sh @@ -1,3 +1,6 @@ if [[ "$UID" -gt 10000 ]] && [[ ! -f ~/.local/share/user-places.xbel.lmn ]] ; then (sleep 30 ; lmn-patch-dolphin.sh) & fi +if [[ "$UID" -gt 10000 ]] && [[ -f ~/.local/share/user-places.xbel ]] ; then + lmn-fixhome-dolphin.sh +fi diff --git a/roles/lmn_fvs/files/lmn-fixhome-dolphin.sh b/roles/lmn_fvs/files/lmn-fixhome-dolphin.sh new file mode 100644 index 0000000..017f949 --- /dev/null +++ b/roles/lmn_fvs/files/lmn-fixhome-dolphin.sh @@ -0,0 +1,20 @@ +#!/usr/bin/bash + +set -eu + +file="${1:-$HOME/.local/share/user-places.xbel}" + +[[ -e "$file" ]] || exit 0 + +if id | grep -q teachers; then + exit 0 +fi + +NETHOME=(/srv/samba/schools/default-school/students/*/"$USER") +[[ -d $NETHOME ]] || exit 0 + +if FOUND=$(grep -o "/srv/samba/schools/default-school/students/.*/$USER" $file); then + if [[ "$NETHOME" != "$FOUND" ]] ; then + sed -i "s|/srv/samba/schools/default-school/students/.*/$USER|$NETHOME|g" $file + fi +fi diff --git a/roles/lmn_fvs/files/lmn-patch-dolphin.sh b/roles/lmn_fvs/files/lmn-patch-dolphin.sh index ab27004..60707c8 100755 --- a/roles/lmn_fvs/files/lmn-patch-dolphin.sh +++ b/roles/lmn_fvs/files/lmn-patch-dolphin.sh @@ -16,11 +16,12 @@ fi id="$(grep ID "$file" | sed -E "s|^.+ID>([[:digit:]]+)/([[:digit:]]+)