#! /bin/sh # Copyright 2008-2010 Mir Calculate Ltd. http://www.calculate-linux.org # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # set background color xsetroot -solid rgb:5F/75/83 if [[ -n $(env | grep RUNNING_UNDER_GDM=true) ]] then python /usr/share/calculate/xdm/gtkbg BG_PID=$(ps ax | sed -nr "s/^\s*([0-9]+)\s.*gtkbg$/\1/p") fi xmes() { xmessage -buttons OK:0 -default OK "`echo \"$1: $2\" | iconv -f utf8 -t koi8-r - `" } if [[ "`ps axeo command | grep xdm/logout | grep -v grep | \ sed -n -r 's/.* USER=([^ ]+) .*/\1/p'`" == "$USER" ]]; then xmessage -buttons "" "Please wait to ending previous session" & while [[ "`ps axeo command | grep xdm/logout | grep -v grep | \ sed -n -r 's/.* USER=([^ ]+) .*/\1/p'`" == "$USER" ]] do sleep 1 done kill -9 `ps ax | sed -n -r '/grep/!{s/([0-9]+) .*xmessage -buttons Please.*/\1/p}'` &>/dev/null fi env-update source /etc/profile PATH_LOG='/var/log/calculate' FILE_LOG="${PATH_LOG}/cl_login-error.log" if [ ! -e $PATH_LOG ]; then # Создадим директорию логов mkdir $PATH_LOG fi # если права на файл не ровны if [[ "`stat /var/log/calculate | sed -n -r '/Access: \(/ {s/.*\([0-9]([^/]+).*/\1/;p}'`" != "755" ]]; then chmod 755 $PATH_LOG fi # Очистим лог ошибок echo -n "" > $FILE_LOG if [ -e '/usr/bin/cl-sync' ]; then ERRORLOG=`/usr/bin/cl-sync --progress --color=never --login $USER 2>&1` # при неудачном выполнении, сгенерируем ошибку if [ "$?" -gt "0" ]; then echo "$ERRORLOG" >> $FILE_LOG xmes cl-sync "$ERRORLOG" [[ -n $BG_PID ]] && kill $BG_PID exit 1 fi fi if [ -e '/usr/bin/cl-createhome' ]; then ERRORLOG=`/usr/bin/cl-createhome --progress --color=never $USER 2>&1` # при неудачном выполнении, сгенерируем ошибку if [ "$?" -gt "0" ]; then echo "$ERRORLOG" >> $FILE_LOG ERRORLOG2=`/usr/bin/cl-sync --color=never --logout --nosync $USER 2>&1` if [ "$?" -gt "0" ]; then xmes cl-sync "$ERRORLOG2" fi xmes cl-createhome "$ERRORLOG" [[ -n $BG_PID ]] && kill $BG_PID exit 1 fi fi #очистим кэш /bin/rm -rf /var/tmp/kdecache-$USER [[ -n $BG_PID ]] && kill $BG_PID exit 0