You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
calculate-utils-3-client/bin/logout

51 lines
1.5 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

# Calculate chmod=0755
#!/bin/bash
source /lib/rc/sh/functions.sh
variable_value()
{
local varname=$1
/usr/sbin/cl-core-variables-show --only-value $varname
}
ONLINE_USERS="`variable_value desktop.cl_desktop_online_user`"
# если есть пользователи в сеансе или выполняется выход
if [[ -n $ONLINE_USERS ]] || pgrep -f 'xdm/xdm --logout' &>/dev/null
then
# есть пользователи в сеансе
if [[ -n $ONLINE_USERS ]]
then
ebegin "Logout users"
# переменная online_data возвращает строки пользователь,дисплей
for user_disp in $(variable_value desktop.cl_desktop_online_data | sed -r "s/;/ /g")
do
user=$(echo $user_disp | cut -d: -f1)
disp=$(echo $user_disp | cut -d: -f2)
# завершаем сессию пользователя
/usr/sbin/cl-core --method desktop_logout $user &>/dev/null
# удаляем запить о пользователе
/usr/bin/sessreg -d -l :$disp $user &>/dev/null
# выполняем принудительный выход из сеанса
USER="$user" /usr/share/calculate/xdm/xdm --logout &>/dev/null &
done
eend 0
fi
# ожидаение завершения процесса выхода пользователя из сеанса
if pgrep -f 'xdm/xdm --logout' &>/dev/null
then
ebegin "Please wait for complete logout"
for i in {1..500}
do
if pgrep -f 'xdm/xdm --logout' &>/dev/null
then
sleep 1
else
break
fi
done
eend 0
fi
fi