LTSPClientShutdownReboot

Some people desire to be able to shut down the Thin Client directly from their session instead of logging out and using the shutdown command ldm provides, below is a way to set up a communication layer through the ldm ssh socket to do that. Note that these scripts have no error checking or validation that the user actually only can call halt or shutdown, they surely need improvement in that area, they are thought as proof of concept only, dont use them in production without enhancing them (every command you execute through the tunnel runs as root on the client)

On the Client

Create a file called:

/opt/ltsp/i386/sbin/ldm_listener

HOME=$(ssh -S ${1} ${2} env|grep HOME|cut -d'=' -f2)
sh -c $(ssh -S ${1} ${2} cat ${HOME}/.ltsp_client_socket) &

Create an ldm rc.d script as:

/opt/ltsp/i386/usr/share/ldm/rc.d/S15-control-socket

# Script to fire up a listener on a user fifo for commands 
# from the session
#

/sbin/ldm_listener $LDM_SOCKET $LDM_SERVER

On the Server

Create an Xsession.d script to create/remove the fifo:

/etc/X11/Xsession.d/85_ltsp-client-socket

if [ -n "$LTSP_CLIENT" ]; then
        if [ ! -p "${HOME}/.ltsp_client_socket" ]; then
            mkfifo --mode=0600 "${HOME}/.ltsp_client_socket"
        fi
else
        if [ -p "${HOME}/.ltsp_client_socket" ]; then
            rm "${HOME}/.ltsp_client_socket"
        fi
fi

now run: sudo ltsp-update-image to make sure the new scripts are in the filesystem image

In the users session

Now you can issue the following command in a users session in a terminal:

echo "/sbin/halt">.ltsp_client_socket

and the Client will shut down magically

A small script using this feature

i wrote a small zenity script you can use in your users sessions from a custom launcher instead of the logout panelicon to shut down the clients:

ACTION=$(zenity --width=90 --height=200 --list --radiolist --text="Select logout action" --title="Logout" --column "Choice" --column "Action" TRUE Reboot FALSE Shutdown FALSE Logout)

if [ -n "${ACTION}" ];then
    case $ACTION in
        Reboot)
            VAL="reboot"
            ;;
        Shutdown)
            VAL="halt"
            ;;
        Logout)
            VAL="logout"
            ;;
        esac

    if [ $VAL != "logout" ];then
        echo "/sbin/${VAL}">${HOME}.ltsp_client_socket
    fi
    gnome-session-save --kill --silent
fi

LTSPClientShutdownReboot (last edited 2008-08-06 17:01:44 by localhost)