@@ -9,6 +9,7 @@ if ! /usr/bin/groups | /usr/bin/grep -qE '(student|piscine)'; then
99 exit 0
1010fi
1111
12+ FACE_PATH=" $HOME /.face"
1213TMP_WALLPAPER_PATH=" /tmp/codam-web-greeter-user-wallpaper"
1314TMP_AVATAR_PATH=" /tmp/codam-web-greeter-user-avatar"
1415
4546 /usr/bin/echo " Wallpaper $WALLPAPER is not a local file"
4647fi
4748
49+ # Get the data-server-url variable from the config file, remove /config/ from the url
50+ DATA_SERVER_URL=$( /usr/bin/grep -Po ' (?<=data-server-url=).*' /usr/share/web-greeter/themes/codam/settings.ini | /usr/bin/sed ' s/^"\(.*\)"$/\1/' | /usr/bin/sed ' s/\/config//' )
51+
52+ # Download the user's profile picture from Intra if no .face file exists in the home directory
53+ if [ ! -f " $FACE_PATH " ]; then
54+ /usr/bin/echo " No user image found in $FACE_PATH , attempting download from the clusterdata server"
55+
56+ # Get the user's login
57+ LOGIN=$( /usr/bin/whoami)
58+
59+ # Get the user's profile picture from Intra through the clusterdata server
60+ IMAGE_URL=" ${DATA_SERVER_URL} user/${LOGIN} /.face"
61+ /usr/bin/echo " Downloading user image from $IMAGE_URL to $FACE_PATH "
62+ /usr/bin/curl -L -s " $IMAGE_URL " -o " $FACE_PATH " || true # Prevent curl from erroring out if the download fails
63+ else
64+ /usr/bin/echo " Existing user image found at $FACE_PATH , not overwriting it with a freshly downloaded copy"
65+ fi
66+
4867# Remove existing user image in /tmp
4968/usr/bin/rm -f " $TMP_AVATAR_PATH "
5069
5170# Copy user's .face file to /tmp
52- if [ -f " $HOME /.face " ]; then
53- /usr/bin/cp " $HOME /.face " " $TMP_AVATAR_PATH "
71+ if [ -f " $FACE_PATH " ]; then
72+ /usr/bin/cp " $FACE_PATH " " $TMP_AVATAR_PATH "
5473 /usr/bin/chmod 666 " $TMP_AVATAR_PATH " # Allow all users to delete the file
55- /usr/bin/echo " Copied user image $HOME /.face to $TMP_AVATAR_PATH "
74+ /usr/bin/echo " Copied user image $FACE_PATH to $TMP_AVATAR_PATH "
75+ else
76+ /usr/bin/echo " No user image found at $FACE_PATH , not copying"
5677fi
0 commit comments