#!/bin/bash # # The following is a script to set up local apps support on LTSP through LDM # home_linker(){ AUX_LANG=$LANG if [ ! -z "$LDM_LANGUAGE" ]; then AUX_LANG="$LDM_LANGUAGE" fi date >> /tmp/home_linker.log # From this file get $LANG { [ -r "$LDM_HOME/.pam_environment" ] && . "$LDM_HOME/.pam_environment" ;} || { [ -r "/etc/default/locale" ] && . "/etc/default/locale" ;} || true # Get Usernames GRP_USER="$(id -ng $LDM_USERNAME)" # Source for user-dirs if it exists USER_DIRS="$LDM_HOME/.config/user-dirs.dirs" [ ! -r $USER_DIRS ] || . $USER_DIRS # Source the token file if it exists LAST_LOGIN_DIRECTORIES="$LDM_HOME/.config/user-dirs.created" [ ! -r "$LAST_LOGIN_DIRECTORIES" ] || . "$LAST_LOGIN_DIRECTORIES" #Temp file with new user-dirs [ -d "$LDM_HOME" ] || { mkdir -p "$LDM_HOME" ; chown $LDM_USERNAME:$GRP_USER "$LDM_HOME" ;} [ -d "$LDM_HOME/.config" ] || { mkdir -p "$LDM_HOME/.config" ; chown $LDM_USERNAME:$GRP_USER "$LDM_HOME/.config" ;} TEMP_NEW_USER_DIRS="$LDM_HOME/.config/aux-user-dirs.create" :> $TEMP_NEW_USER_DIRS get_acl_from_server "$LDM_HOME" "$GRP_USER" "$LDM_USERNAME" echo "El idioma es $AUX_LANG" >> /tmp/home_linker.log # Download directory actions DOWNLOADS_LOCALE="$(/usr/bin/xdg_translator "$AUX_LANG" "Downloads")" DESKTOP_LOCALE="$(/usr/bin/xdg_translator "$AUX_LANG" "Desktop")" DOCUMENTS_LOCALE="$(/usr/bin/xdg_translator "$AUX_LANG" "Documents")" SHARE_LOCALE="$(/usr/bin/xdg_translator "$AUX_LANG" "Share")" SHARETEACHERS_LOCALE="$(/usr/bin/xdg_translator "$AUX_LANG" "Teachers_Share")" GROUPSSHARE_LOCALE="$(/usr/bin/xdg_translator "$AUX_LANG" "Groups_Share")" [ ! -z $DESKTOP_LOCALE ] || DESKTOP_LOCALE="Desktop" [ ! -z $DOWNLOADS_LOCALE ] || DOWNLOADS_LOCALE="Downloads" [ ! -z $DOCUMENTS_LOCALE ] || DOCUMENTS_LOCALE="Documents" [ ! -z $SHARE_LOCALE ] || SHARE_LOCALE="Share" [ ! -z $SHARETEACHERS_LOCALE ] || SHARETEACHERS_LOCALE="Teachers_Share" [ ! -z $GROUPSSHARE_LOCALE ] || GROUPSSHARE_LOCALE="Groups_Share" # Umount directories mounted previously if [ -e $LDM_HOME/${DESKTOP_LOCALE} ]; then rm -rf $LDM_HOME/${DESKTOP_LOCALE} if [ "$TOKEN_DESKTOP" != "" -a -e "$LDM_HOME/$TOKEN_DESKTOP" ]; then rm -rf $LDM_HOME/$TOKEN_DESKTOP fi fi echo "TOKEN_DESKTOP=\"$DESKTOP_LOCALE\"" >> $TEMP_NEW_USER_DIRS if [ -e $LDM_HOME/${DOCUMENTS_LOCALE} ]; then rm -rf $LDM_HOME/${DOCUMENTS_LOCALE} if [ "$TOKEN_DOCUMENTS" != "" -a -e "$LDM_HOME/$TOKEN_DOCUMENTS" ]; then rm -rf $LDM_HOME/$TOKEN_DOCUMENTS fi fi echo "TOKEN_DOCUMENTS=\"$DOCUMENTS_LOCALE\"" >> $TEMP_NEW_USER_DIRS if [ "${TOKEN_DOWNLOADS}" != "" -a -e $LDM_HOME/${TOKEN_DOWNLOADS} ]; then mv $LDM_HOME/${TOKEN_DOWNLOADS} $LDM_HOME/${DOWNLOADS_LOCALE} fi if [ ! -e $LDM_HOME/${DOCUMENTS_LOCALE} ]; then mkdir $LDM_HOME/${DOWNLOADS_LOCALE} chown $LDM_USERNAME:$GRP_USER $LDM_HOME/${DOWNLOADS_LOCALE} chmod 755 $LDM_HOME/${DOWNLOADS_LOCALE} fi echo "TOKEN_DOWNLOADS=\"$DOWNLOADS_LOCALE\"" >> $TEMP_NEW_USER_DIRS if [ -e $LDM_HOME/${SHARE_LOCALE} ]; then rm -rf $LDM_HOME/${SHARE_LOCALE} if [ ! -z "$TOKEN_SHARE" -a -e $LDM_HOME/${TOKEN_SHARE} ]; then rm -rf $LDM_HOME/${TOKEN_SHARE} fi fi echo "TOKEN_SHARE=\"$SHARE_LOCALE\"" >> $TEMP_NEW_USER_DIRS if [ -e $LDM_HOME/${SHARETEACHERS_LOCALE} ]; then rm -rf $LDM_HOME/${SHARETEACHERS_LOCALE} if [ ! -z "$SHARETEACHERS_TOKEN" -a -e $LDM_HOME/${SHARETEACHERS_TOKEN} ]; then rm -rf $LDM_HOME/${SHARETEACHERS_TOKEN} fi fi echo "TOKEN_SHARETEACHERS=\"$SHARETEACHERS_LOCALE\"" >> $TEMP_NEW_USER_DIRS if [ -e $LDM_HOME/"$GROUPSSHARE_LOCALE" ]; then rm -rf $LDM_HOME/"$GROUPSSHARE_LOCALE" if [ ! -z "$TOKEN_GROUPSSHARE" -a -e $LDM_HOME/${TOKEN_GROUPSSHARE} ]; then rm -rf $LDM_HOME/${TOKEN_GROUPSSHARE} fi fi chown $USER:$GRP_USER ~/${GROUPSSHARE_LOCALE} echo "TOKEN_GROUPSSHARE=\"$GROUPSSHARE_LOCALE\"" >> $TEMP_NEW_USER_DIRS if [ -d "/net/server-sync/home/$GRP_USER/$LDM_USERNAME/Desktop" ]; then { ln -s /net/server-sync/home/$GRP_USER/$LDM_USERNAME/Desktop $LDM_HOME/${DESKTOP_LOCALE} ; echo "Creando enlace del desktop" >> /tmp/home_linker.log ;} || true echo "Ok enlace del desktop" >> /tmp/home_linker.log else echo "No existe el directorio Desktop" >> /tmp/home_linker.log fi if [ -d "/net/server-sync/home/$GRP_USER/$LDM_USERNAME/Documents" ]; then { ln -s /net/server-sync/home/$GRP_USER/$LDM_USERNAME/Documents $LDM_HOME/${DOCUMENTS_LOCALE} ; echo "creando enlace de documents" >> /tmp/home_linker.log ;} || true echo "Ok enlace de documents" >> /tmp/home_linker.log else echo "No existe el directorio Documents" >> /tmp/home_linker.log fi if [ -d "/net/server-sync/share" ] ; then { ln -s /net/server-sync/share $LDM_HOME/${SHARE_LOCALE} ; echo "Creando enlace de share" >> /tmp/home_linker.log ;} || true echo "Ok enlace de share" >> /tmp/home_linker.log else echo "No existe el directorio Share" >> /tmp/home_linker.log fi if [ -d "/net/server-sync/groups_share" ] ; then { ln -s /net/server-sync/groups_share $LDM_HOME/${GROUPSSHARE_LOCALE} ; echo "Creando enlace de group_share" >> /tmp/home_linker.log ;} || true echo "Ok enlace de share" >> /tmp/home_linker.log else echo "No existe el directorio Share" >> /tmp/home_linker.log fi if [ "$GRP_USER" = "teachers" ]; then if [ -d /net/server-sync/teachers_share ]; then { ln -s /net/server-sync/teachers_share $LDM_HOME/${SHARETEACHERS_LOCALE} ; echo "Creando enlace de share_teachers" >> /tmp/home_linker.log ;} || true echo "Ok enlace de share_teachers" >> /tmp/home_linker.log else echo "No existe el directorio Share_teachers" >> /tmp/home_linker.log fi if [ -d /net/server-sync/home/students/ ]; then { ln -s /net/server-sync/home/students/ $LDM_HOME/alum ; echo "Creando enlace de alum" >> /tmp/home_linker.log ;} || true echo "OK enlace de alum" >> /tmp/home_linker.log else echo "No existe el directorio students" >> /tmp/home_linker.log fi fi mv ${TEMP_NEW_USER_DIRS} ${LAST_LOGIN_DIRECTORIES} cat > $USER_DIRS << EOF # This file is written by xdg-user-dirs-update # If you want to change or add directories, just edit the line you're # interested in. All local changes will be retained on the next run # Format is XDG_xxx_DIR="\$HOME/yyy", where yyy is a shell-escaped # homedir-relative path, or XDG_xxx_DIR="/yyy", where /yyy is an # absolute path. No other format is supported. # XDG_DESKTOP_DIR="\$HOME/$DESKTOP_LOCALE" XDG_DOWNLOAD_DIR="\$HOME/$DOWNLOADS_LOCALE" XDG_DOCUMENTS_DIR="\$HOME/$DOCUMENTS_LOCALE" EOF chmod 600 $USER_DIRS chown $LDM_USERNAME:$GRP_USER $USER_DIRS } if ! boolean_is_true "$LTSP_FATCLIENT"; then ssh -S ${LDM_SOCKET} ${LDM_SERVER} sudo /etc/lightdm/PreSession.d/home-linker ${LDM_USERNAME} else home_linker echo "" >> /tmp/home_linker.log echo "AFTER HOME LINKER" >> /tmp/home_linker.log tree $LDM_HOME >> /tmp/home_linker.log echo "" >> /tmp/home_linker.log cat $LDM_HOME/.config/user-dirs.created >> /tmp/home_linker.log echo "" >> /tmp/home_linker.log cat $LDM_HOME/.config/user-dirs.dirs >> /tmp/home_linker.log echo "" >> /tmp/home_linker.log echo "END X98Home Linker" >> /tmp/home_linker.log fi