From aca30643c0cf2511411f52bf09ef6a7e3c37a4c2 Mon Sep 17 00:00:00 2001 From: Mike Khiretskiy Date: Tue, 31 Mar 2015 13:34:41 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=B5=D1=80=D0=B5=D0=BF=D0=B8=D1=81?= =?UTF-8?q?=D0=B0=D0=BD=D1=8B=20xdm=20=D1=81=D0=BA=D1=80=D0=B8=D0=BF=D1=82?= =?UTF-8?q?=D1=8B=20=D0=B4=D0=BB=D1=8F=20fastlogin?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Добавлен 05fastlogin --- data/functions | 10 +++++++ data/login.d/00init | 56 ++++++++++++++++++++------------------- data/login.d/05fast_login | 29 ++++++++++++++++++++ data/login.d/20desktop | 37 +++++++++++--------------- data/login.d/99final | 11 ++++---- data/logout.d/00init | 30 +++++++++++---------- data/logout.d/95syncface | 37 +++++++++++++++++--------- data/logout.d/98umount | 21 ++++++++++++--- data/xdm | 12 ++++++--- setup.py | 1 + 10 files changed, 159 insertions(+), 85 deletions(-) create mode 100644 data/login.d/05fast_login diff --git a/data/functions b/data/functions index 8ac070e..30b43d8 100644 --- a/data/functions +++ b/data/functions @@ -26,3 +26,13 @@ desktop_variable_value() local varname=$1 /usr/sbin/cl-core-variables-show --only-value $varname } + +# get user domain set +get_ur_domain_set() { + if rc-update show default | grep client &>/dev/null + then + desktop_variable_value desktop.ur_domain_set + else + echo "off" + fi +} diff --git a/data/login.d/00init b/data/login.d/00init index 08e6339..2e29e88 100644 --- a/data/login.d/00init +++ b/data/login.d/00init @@ -1,5 +1,5 @@ #! /bin/sh -# Copyright 2010 Calculate Ltd. http://www.calculate-linux.org +# Copyright 2010-2015 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. @@ -13,31 +13,33 @@ # See the License for the specific language governing permissions and # limitations under the License. -# set background color -if [[ -f /usr/share/wallpapers/dm-background.png ]] -then - feh --no-fehbg --bg-scale /usr/share/wallpapers/dm-background.png -else - if ls /var/db/pkg/media-gfx/cld[-gx]*themes-12* &>/dev/null - then - xsetroot -solid rgb:73/a3/63 - else - xsetroot -solid rgb:30/64/8b - fi -fi +run_script() { + # set background color + if [[ -f /usr/share/wallpapers/dm-background.png ]] + then + feh --no-fehbg --bg-scale /usr/share/wallpapers/dm-background.png + else + if ls /var/db/pkg/media-gfx/cld[-gx]*themes-12* &>/dev/null + then + xsetroot -solid rgb:73/a3/63 + else + xsetroot -solid rgb:30/64/8b + fi + fi -/sbin/modprobe ecryptfs + /sbin/modprobe ecryptfs -if [[ "`ps axeo command | grep 'xdm/xdm --logout' | grep -v grep | \ - sed -n -r 's/.* USER=([^ ]+) .*/\1/p'`" == "$USER" ]]; -then - xmessage -buttons "" "Please wait to ending previous session" & - XMESPID=$! - while [[ "`ps axeo command | grep 'xdm/xdm --logout' | grep -v grep | \ - sed -n -r 's/.* USER=([^ ]+) .*/\1/p'`" == "$USER" ]] - do - sleep 1 - done - kill -9 $XMESPID &>/dev/null -fi -exit 0 + if [[ "`ps axeo command | grep 'xdm/xdm --logout' | grep -v grep | \ + sed -n -r 's/.* USER=([^ ]+) .*/\1/p'`" == "$USER" ]]; + then + xmessage -buttons "" "Please wait to ending previous session" & + XMESPID=$! + while [[ "`ps axeo command | grep 'xdm/xdm --logout' | grep -v grep | \ + sed -n -r 's/.* USER=([^ ]+) .*/\1/p'`" == "$USER" ]] + do + sleep 1 + done + kill -9 $XMESPID &>/dev/null + fi + return 0 +} diff --git a/data/login.d/05fast_login b/data/login.d/05fast_login new file mode 100644 index 0000000..e4cb0ea --- /dev/null +++ b/data/login.d/05fast_login @@ -0,0 +1,29 @@ +#! /bin/sh +# Copyright 2015 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. + +run_script() { + # skip cl-desktop and other scripts: user profile is configured already + if [[ "${DOMAIN_USER}" == "off" ]] && + [[ -d ${HOME_DIR} ]] && + [[ -f /var/lib/calculate/calculate-desktop/fastlogin/${USER} ]] + then + # break as success xdm --login + return 2 + else + /usr/sbin/env-update + source /etc/profile + return 0 + fi +} diff --git a/data/login.d/20desktop b/data/login.d/20desktop index 8ec8ace..daf8e69 100644 --- a/data/login.d/20desktop +++ b/data/login.d/20desktop @@ -1,5 +1,5 @@ #! /bin/sh -# Copyright 2010-2012 Calculate Ltd. http://www.calculate-linux.org +# Copyright 2010-2015 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. @@ -13,23 +13,18 @@ # See the License for the specific language governing permissions and # limitations under the License. -/usr/sbin/env-update -source /etc/profile -source /usr/share/calculate/xdm/functions - -if [ -e '/usr/sbin/cl-desktop' ]; -then - # skip desktop configure if user not domain and it already has home dir - # with not /etc/skel contents - userHome=`getent passwd $USER | awk -F: '{ print( $6 ); }'` - ERRORLOG=`/usr/sbin/cl-desktop --gui-progress $USER 2>&1` - # raise xmessage error if cl-desktop failed - if [ "$?" -gt "0" ]; - then - # write error message to logfile - echo "$ERRORLOG" >> $FILE_LOG - # display error by xmessage - exit 1 - fi -fi -exit 0 +run_script() { + if [ -e '/usr/sbin/cl-desktop' ]; + then + ERRORLOG=`/usr/sbin/cl-desktop --gui-progress $USER 2>&1` + # raise xmessage error if cl-desktop failed + if [ "$?" -gt "0" ]; + then + # write error message to logfile + echo "$ERRORLOG" >> $FILE_LOG + # display error by xmessage + return 1 + fi + fi + return 0 +} diff --git a/data/login.d/99final b/data/login.d/99final index c263d4b..b0eab58 100644 --- a/data/login.d/99final +++ b/data/login.d/99final @@ -1,5 +1,5 @@ #! /bin/sh -# Copyright 2008-2012 Calculate Ltd. http://www.calculate-linux.org +# Copyright 2008-2015 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. @@ -13,7 +13,8 @@ # See the License for the specific language governing permissions and # limitations under the License. - -# clear kde cache -/bin/rm -rf /var/tmp/kdecache-$USER -exit 0 +run_script() { + # clear kde cache + /bin/rm -rf /var/tmp/kdecache-$USER + return 0 +} diff --git a/data/logout.d/00init b/data/logout.d/00init index deaa12b..39551e5 100644 --- a/data/logout.d/00init +++ b/data/logout.d/00init @@ -1,5 +1,5 @@ #! /bin/sh -# Copyright 2010 Calculate Ltd. http://www.calculate-linux.org +# Copyright 2010-2015 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. @@ -13,16 +13,18 @@ # See the License for the specific language governing permissions and # limitations under the License. -# set background color -if [[ -f /usr/share/wallpapers/dm-background.png ]] -then - feh --no-fehbg --bg-scale /usr/share/wallpapers/dm-background.png -else - if ls /var/db/pkg/media-gfx/cld[-gx]*themes-12* &>/dev/null - then - xsetroot -solid rgb:73/a3/63 - else - xsetroot -solid rgb:30/64/8b - fi -fi -exit 0 +run_script() { + # set background color + if [[ -f /usr/share/wallpapers/dm-background.png ]] + then + feh --no-fehbg --bg-scale /usr/share/wallpapers/dm-background.png + else + if ls /var/db/pkg/media-gfx/cld[-gx]*themes-12* &>/dev/null + then + xsetroot -solid rgb:73/a3/63 + else + xsetroot -solid rgb:30/64/8b + fi + fi + return 0 +} diff --git a/data/logout.d/95syncface b/data/logout.d/95syncface index 10f57f4..964796c 100644 --- a/data/logout.d/95syncface +++ b/data/logout.d/95syncface @@ -1,20 +1,33 @@ #!/bin/bash # # Syncronize icon face from local user to kdm -# (c) 2013 Calculate Ltd. http://www.calculate-linux.org +# Copyright 2013-2015 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. # get icon face directory from kdm config get_icon_face_dir() { - local config_file=/usr/share/config/kdm/kdmrc - [[ -f $config_file ]] && sed -rn 's/^FaceDir=(.*)/\1/p' $config_file + local config_file=/usr/share/config/kdm/kdmrc + [[ -f $config_file ]] && sed -rn 's/^FaceDir=(.*)/\1/p' $config_file } -# copy .face.icon from user home directory to kdm face directory -if [[ $DOMAIN_USER == "off" ]] && [[ -f $HOME_DIR/.face.icon ]]; then - FACE_DIR=$(get_icon_face_dir) - if [[ -n $FACE_DIR ]] && [[ -d $FACE_DIR ]];then - cp $HOME_DIR/.face.icon $FACE_DIR/${USER}.face - fi -fi - -exit 0 +run_script() { + # copy .face.icon from user home directory to kdm face directory + if [[ $DOMAIN_USER == "off" ]] && [[ -f $HOME_DIR/.face.icon ]]; then + FACE_DIR=$(get_icon_face_dir) + if [[ -n $FACE_DIR ]] && [[ -d $FACE_DIR ]];then + cp $HOME_DIR/.face.icon $FACE_DIR/${USER}.face + fi + fi + return 0 +} diff --git a/data/logout.d/98umount b/data/logout.d/98umount index f388464..71c2030 100644 --- a/data/logout.d/98umount +++ b/data/logout.d/98umount @@ -1,5 +1,20 @@ #!/bin/bash +# Copyright 2013-2015 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. -keyctl unlink $( keyctl request user $USER ) -umount -l /home/$USER -exit 0 +run_script() { + keyctl unlink $( keyctl request user $USER ) + umount -l /home/$USER + return 0 +} diff --git a/data/xdm b/data/xdm index b5b346d..54ad937 100755 --- a/data/xdm +++ b/data/xdm @@ -139,18 +139,24 @@ if [[ $EXECDIR == /usr/share/calculate/xdm ]]; then die "must specify option" fi - [[ -e ${EXECDIR} ]] || die "${EXECDIR} is not exists" FILELIST=$(find ${EXECDIR} -type f | sort) [[ $FILELIST ]] || warning "${EXECDIR} hasn't scripts" gtk_background -DOMAIN_USER="`desktop_variable_value desktop.ur_domain_set`" +DOMAIN_USER="`get_ur_domain_set`" HOME_DIR=`getent passwd $USER | awk -F: '{ print( $6 ); }'` + for script in $FILELIST do - FILE_LOG=$FILE_LOG HOME_DIR=$HOME_DIR USER=$USER DOMAIN_USER=$DOMAIN_USER /bin/bash $script || die_xmes "failed on execute $script" + source $script && run_script + res=$? + case $res in + 0) continue ;; + 1) die_xmes "failed on execute $script" ;; + 2) break ;; + esac done sleep_kill() diff --git a/setup.py b/setup.py index 2c78b98..d19f554 100755 --- a/setup.py +++ b/setup.py @@ -73,6 +73,7 @@ data_files = [('/usr/share/calculate/xdm', [('data/cmd_login', 0755), ('data/setbg', 0755)]), ('/usr/share/calculate/xdm/login.d', ['data/login.d/00init', + 'data/login.d/05fast_login', 'data/login.d/20desktop', 'data/login.d/99final']), ('/usr/share/calculate/xdm/logout.d',