source: lmd-client/trunk/fuentes/install/usr/share/ldm/rc.d/X94-home-linker @ 512

Last change on this file since 512 was 512, checked in by mabarracus, 3 years ago

copy trusty code

File size: 7.1 KB
Line 
1#!/bin/bash
2#
3# The following is a script to set up local apps support on LTSP through LDM
4#
5
6
7home_linker(){
8        AUX_LANG=$LANG
9        if [ ! -z "$LDM_LANGUAGE" ]; then
10                AUX_LANG="$LDM_LANGUAGE"       
11        fi
12        date >> /tmp/home_linker.log
13        # From this file get $LANG
14        { [ -r "$LDM_HOME/.pam_environment" ] && . "$LDM_HOME/.pam_environment" ;} || { [ -r "/etc/default/locale" ] && . "/etc/default/locale" ;} || true 
15        # Get Usernames
16        GRP_USER="$(id -ng $LDM_USERNAME)"
17        # Source for user-dirs if it exists
18        USER_DIRS="$LDM_HOME/.config/user-dirs.dirs"
19        [ ! -r $USER_DIRS ] || . $USER_DIRS
20        # Source the token file if it exists
21        LAST_LOGIN_DIRECTORIES="$LDM_HOME/.config/user-dirs.created"
22        [ ! -r "$LAST_LOGIN_DIRECTORIES" ] || . "$LAST_LOGIN_DIRECTORIES"
23        #Temp file with new user-dirs
24        [ -d "$LDM_HOME" ] || { mkdir -p "$LDM_HOME" ; chown $LDM_USERNAME:$GRP_USER "$LDM_HOME" ;}
25        [ -d "$LDM_HOME/.config" ] || { mkdir -p "$LDM_HOME/.config" ; chown $LDM_USERNAME:$GRP_USER "$LDM_HOME/.config" ;}
26        TEMP_NEW_USER_DIRS="$LDM_HOME/.config/aux-user-dirs.create"
27        :> $TEMP_NEW_USER_DIRS
28
29        get_acl_from_server "$LDM_HOME" "$GRP_USER" "$LDM_USERNAME"
30       
31        echo "El idioma es $AUX_LANG" >> /tmp/home_linker.log
32        # Download directory actions
33        DOWNLOADS_LOCALE="$(/usr/bin/xdg_translator "$AUX_LANG" "Downloads")"
34        DESKTOP_LOCALE="$(/usr/bin/xdg_translator "$AUX_LANG"  "Desktop")"
35        DOCUMENTS_LOCALE="$(/usr/bin/xdg_translator "$AUX_LANG"  "Documents")"
36        SHARE_LOCALE="$(/usr/bin/xdg_translator "$AUX_LANG"  "Share")"
37        SHARETEACHERS_LOCALE="$(/usr/bin/xdg_translator "$AUX_LANG"  "Teachers_Share")"
38        GROUPSSHARE_LOCALE="$(/usr/bin/xdg_translator "$AUX_LANG"  "Groups_Share")"
39
40        [ ! -z $DESKTOP_LOCALE ] || DESKTOP_LOCALE="Desktop"
41        [ ! -z $DOWNLOADS_LOCALE ] || DOWNLOADS_LOCALE="Downloads"
42        [ ! -z $DOCUMENTS_LOCALE ] || DOCUMENTS_LOCALE="Documents"
43        [ ! -z $SHARE_LOCALE ] || SHARE_LOCALE="Share"
44        [ ! -z $SHARETEACHERS_LOCALE ] || SHARETEACHERS_LOCALE="Teachers_Share"
45        [ ! -z $GROUPSSHARE_LOCALE ] || GROUPSSHARE_LOCALE="Groups_Share"
46        # Umount directories mounted previously
47       
48
49        if [ -e $LDM_HOME/${DESKTOP_LOCALE} ]; then
50                rm -rf $LDM_HOME/${DESKTOP_LOCALE}
51                if [ "$TOKEN_DESKTOP" != "" -a -e "$LDM_HOME/$TOKEN_DESKTOP" ]; then
52                        rm -rf $LDM_HOME/$TOKEN_DESKTOP
53                fi
54        fi
55        echo "TOKEN_DESKTOP=\"$DESKTOP_LOCALE\"" >> $TEMP_NEW_USER_DIRS
56
57        if [ -e $LDM_HOME/${DOCUMENTS_LOCALE} ]; then
58                rm -rf $LDM_HOME/${DOCUMENTS_LOCALE}
59                if [ "$TOKEN_DOCUMENTS" != "" -a -e "$LDM_HOME/$TOKEN_DOCUMENTS" ]; then
60                        rm -rf $LDM_HOME/$TOKEN_DOCUMENTS
61                fi
62        fi
63        echo "TOKEN_DOCUMENTS=\"$DOCUMENTS_LOCALE\"" >> $TEMP_NEW_USER_DIRS
64
65
66        if [ "${TOKEN_DOWNLOADS}" != "" -a -e $LDM_HOME/${TOKEN_DOWNLOADS} ]; then
67                mv $LDM_HOME/${TOKEN_DOWNLOADS} $LDM_HOME/${DOWNLOADS_LOCALE}
68        fi
69        if [ ! -e $LDM_HOME/${DOCUMENTS_LOCALE} ]; then
70                mkdir $LDM_HOME/${DOWNLOADS_LOCALE}
71                chown $LDM_USERNAME:$GRP_USER $LDM_HOME/${DOWNLOADS_LOCALE}
72                chmod 755 $LDM_HOME/${DOWNLOADS_LOCALE}
73        fi
74        echo "TOKEN_DOWNLOADS=\"$DOWNLOADS_LOCALE\"" >> $TEMP_NEW_USER_DIRS
75
76
77        if [ -e $LDM_HOME/${SHARE_LOCALE} ]; then
78                rm -rf $LDM_HOME/${SHARE_LOCALE}
79                if [ ! -z "$TOKEN_SHARE" -a -e $LDM_HOME/${TOKEN_SHARE} ]; then
80                        rm -rf $LDM_HOME/${TOKEN_SHARE}
81                fi
82        fi
83        echo "TOKEN_SHARE=\"$SHARE_LOCALE\"" >> $TEMP_NEW_USER_DIRS
84       
85        if [ -e $LDM_HOME/${SHARETEACHERS_LOCALE} ]; then
86                rm -rf $LDM_HOME/${SHARETEACHERS_LOCALE}
87                if [ ! -z "$SHARETEACHERS_TOKEN" -a -e $LDM_HOME/${SHARETEACHERS_TOKEN} ]; then
88                        rm -rf $LDM_HOME/${SHARETEACHERS_TOKEN} 
89                fi
90        fi
91        echo "TOKEN_SHARETEACHERS=\"$SHARETEACHERS_LOCALE\"" >> $TEMP_NEW_USER_DIRS
92       
93        if [ -e $LDM_HOME/"$GROUPSSHARE_LOCALE" ]; then
94                rm -rf  $LDM_HOME/"$GROUPSSHARE_LOCALE"
95                    if [ ! -z "$TOKEN_GROUPSSHARE" -a -e $LDM_HOME/${TOKEN_GROUPSSHARE} ]; then
96                        rm -rf $LDM_HOME/${TOKEN_GROUPSSHARE}
97                    fi
98        fi
99
100        chown $USER:$GRP_USER ~/${GROUPSSHARE_LOCALE}
101        echo "TOKEN_GROUPSSHARE=\"$GROUPSSHARE_LOCALE\"" >> $TEMP_NEW_USER_DIRS
102       
103
104       
105        if [ -d "/net/server-sync/home/$GRP_USER/$LDM_USERNAME/Desktop" ]; then
106            { 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
107                echo "Ok enlace del desktop" >> /tmp/home_linker.log
108        else
109                echo "No existe el directorio Desktop" >> /tmp/home_linker.log
110        fi
111
112        if [ -d "/net/server-sync/home/$GRP_USER/$LDM_USERNAME/Documents" ]; then
113            { 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
114                echo "Ok enlace de documents" >> /tmp/home_linker.log
115        else
116                echo "No existe el directorio Documents" >> /tmp/home_linker.log
117        fi
118
119        if [ -d "/net/server-sync/share" ] ; then
120            { ln -s /net/server-sync/share $LDM_HOME/${SHARE_LOCALE} ; echo "Creando enlace de share" >> /tmp/home_linker.log ;} || true
121                echo "Ok enlace de share" >> /tmp/home_linker.log
122        else
123                echo "No existe el directorio Share" >> /tmp/home_linker.log
124        fi
125       
126        if [ -d "/net/server-sync/groups_share" ] ; then
127            { ln -s /net/server-sync/groups_share $LDM_HOME/${GROUPSSHARE_LOCALE} ; echo "Creando enlace de group_share" >> /tmp/home_linker.log ;} || true
128                echo "Ok enlace de share" >> /tmp/home_linker.log
129        else
130                echo "No existe el directorio Share" >> /tmp/home_linker.log
131        fi
132
133       
134        if [ "$GRP_USER" = "teachers" ]; then
135                if [ -d /net/server-sync/teachers_share ]; then
136                        { ln -s /net/server-sync/teachers_share $LDM_HOME/${SHARETEACHERS_LOCALE} ; echo "Creando enlace de share_teachers" >> /tmp/home_linker.log ;} || true
137                        echo "Ok enlace de share_teachers"  >> /tmp/home_linker.log
138                else
139                        echo "No existe el directorio Share_teachers" >> /tmp/home_linker.log
140                fi
141                if [ -d /net/server-sync/home/students/ ]; then
142                        { ln -s /net/server-sync/home/students/ $LDM_HOME/alum ; echo "Creando enlace de alum" >> /tmp/home_linker.log ;} || true
143                        echo "OK enlace de alum" >> /tmp/home_linker.log
144                else
145                        echo "No existe el directorio students" >> /tmp/home_linker.log
146                fi
147        fi
148        mv ${TEMP_NEW_USER_DIRS} ${LAST_LOGIN_DIRECTORIES}
149
150
151        cat > $USER_DIRS << EOF
152# This file is written by xdg-user-dirs-update
153# If you want to change or add directories, just edit the line you're
154# interested in. All local changes will be retained on the next run
155# Format is XDG_xxx_DIR="\$HOME/yyy", where yyy is a shell-escaped
156# homedir-relative path, or XDG_xxx_DIR="/yyy", where /yyy is an
157# absolute path. No other format is supported.
158#
159XDG_DESKTOP_DIR="\$HOME/$DESKTOP_LOCALE"
160XDG_DOWNLOAD_DIR="\$HOME/$DOWNLOADS_LOCALE"
161XDG_DOCUMENTS_DIR="\$HOME/$DOCUMENTS_LOCALE"
162EOF
163        chmod 600 $USER_DIRS
164        chown $LDM_USERNAME:$GRP_USER $USER_DIRS
165}
166
167
168if ! boolean_is_true "$LTSP_FATCLIENT"; then
169        ssh -S ${LDM_SOCKET} ${LDM_SERVER} sudo /etc/lightdm/Session.d/home-linker ${LDM_USERNAME}
170else
171
172        home_linker
173
174        echo "" >> /tmp/home_linker.log
175        echo "AFTER HOME LINKER" >> /tmp/home_linker.log
176        tree $LDM_HOME >> /tmp/home_linker.log
177        echo "" >> /tmp/home_linker.log
178        cat $LDM_HOME/.config/user-dirs.created >> /tmp/home_linker.log
179        echo "" >> /tmp/home_linker.log
180        cat $LDM_HOME/.config/user-dirs.dirs >> /tmp/home_linker.log
181        echo "" >> /tmp/home_linker.log
182        echo "END X98Home Linker" >> /tmp/home_linker.log
183
184fi
Note: See TracBrowser for help on using the repository browser.