Monthly Archives: February 2014

Linux Mint 13: LTSP, Guest Account and Epoptes Installation

Here is how I installed and configured LTSP on Linux Mint 13 32-bit. My LTSP server has two network cards, eth0 connected to internet through a router and eth1 for ltsp clients.

1. Install package “ltsp-server-standalone” using apt-get:

sudo apt-get install ltsp-server-standalone

or synaptic:

mint_ltsp_1

2. From console (terminal) execute following commands:

sudo cp -R /usr/share/ltsp/plugins/ltsp-build-client/Ubuntu /usr/share/ltsp/plugins/ltsp-build-client/LinuxMint
sudo ln -s /usr/share/debootstrap/scripts/gutsy /usr/share/debootstrap/scripts/maya
sudo sed -i 's/DIST=${DIST:-"$(lsb_release -s -c)"}/DIST=${DIST:-"precise"}/' "/usr/share/ltsp/plugins/ltsp-build-client/LinuxMint/000-basic-configuration"
sudo ln -s /usr/share/ltsp/plugins/ltsp-build-client/Debian-functions /usr/share/ltsp/plugins/ltsp-build-client/LinuxMint-functions

3. Build ltsp client:

sudo ltsp-build-client --arch i386

4. Add following entry to “/etc/network/interfaces” file:

auto eth1
iface eth1 inet static
address 192.168.0.1
netmask 255.255.255.0

5. To make sure dhcp server only response to the second ethernet card, put interface “eth1” to file “/etc/default/isc-dhcp-server”:

INTERFACES="eth1"

6. At this point LTSP server is ready, you can try it by restarting the server and boot ltsp clients from network. But we want to go on setting up guest accounts. To activate guest account, create a new lts.conf file “/var/lib/tftpboot/ltsp/i386/lts.conf” and add following lines:

[Default]
LDM_GUESTLOGIN=True
LDM_PASSWORD=secret

7. Add guest user names:

sudo adduser ltsp20
sudo adduser ltsp21

8. Now you can try to login from ltsp client using guest account.

mint_ltsp_2

9. Now we want to automatically clean up guest home directory every time guest log in. Create a new file “/opt/ltsp/i386/usr/share/ldm/rc.d/S00-guest-sessions” and put following text in it:

case "$LDM_USERNAME" in
    ltsp*)
        ssh -S "$LDM_SOCKET" "$LDM_SERVER" 'cd; rm -rf .* *; rsync -a /etc/skel/ .'
        ;;
esac

10. Save the file and run “ltsp-update-image”:

sudo ltsp-update-image

11. Install “epoptes” using apt-get:

sudo apt-get install epoptes

or synaptic:

mint_ltsp_3

12. Add user to group epoptes:

sudo gpasswd -a <username> epoptes

13. Install epoptes-client to ltsp client:

sudo chroot /opt/ltsp/i386
apt-get install epoptes-client
epoptes-client -c
exit

14. Update ltsp image:

sudo ltsp-update-image

15. Reboot the server, start clients and run epoptes.

mint_ltsp_4

16. Fix for Mate desktop manager. Save following script as “endsession”:

#!/bin/sh
###########################################################################
# Requests a logout, reboot or shutdown.
# Currently it supports Gnome, KDE, XFCE and LXDE.
# Usage: endsession --logout|--reboot|--shutdown
#
# Copyright (C) 2011 Alkis Georgopoulos <alkisg@gmail.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
# On Debian GNU/Linux systems, the complete text of the GNU General
# Public License can be found in `/usr/share/common-licenses/GPL'.
###########################################################################

die() {
    echo "$@" >&2
    exit 1
}

is_root() {
    test $(id -u) -eq 0
}

is_ltsp() {
    test -n "$LTSP_CLIENT"
}

do_logout() {
    # Reset the xprop in case the user asks for a reboot, cancels it
    # (e.g. unsaved work), and then he asks for a logout instead.
    if [ $action = "logout" ] && is_ltsp; then
        # LTSP_LOGOUT_ACTION might not exist, but we don't care
        xprop -root -remove LTSP_LOGOUT_ACTION 2>/dev/null
    fi

    # Gnome
    dbus-send --session --type=method_call --print-reply --reply-timeout=2000 \
      --dest=org.gnome.SessionManager /org/gnome/SessionManager \
      org.gnome.SessionManager.Logout uint32:1 2>&1 && return

    # KDE
    dbus-send --session --type=method_call --print-reply --reply-timeout=2000 \
      --dest=org.kde.ksmserver /KSMServer org.kde.KSMServerInterface.logout \
      int32:0 int32:0 int32:0 2>&1 && return

    # Mate
    dbus-send --session --type=method_call --print-reply --reply-timeout=2000 \
       --dest=org.mate.SessionManager /org/mate/SessionManager \
       org.mate.SessionManager.Logout uint32:1 2>&1 && return

    # XFCE
    xfce4-session-logout --logout 2>&1 && return

    # LXDE
    test -n "$_LXSESSION_PID" && kill "$_LXSESSION_PID" && return

    die "I don't know how to logout in this environment"
}

do_reboot() {
    if is_root; then
        reboot && return
    elif is_ltsp; then
        # Notify ldm that we want to reboot after logoff
        xprop -root -f LTSP_LOGOUT_ACTION 8s -set LTSP_LOGOUT_ACTION REBOOT
        do_logout && return
    fi

    # Gnome
    dbus-send --session --type=method_call --print-reply --reply-timeout=2000 \
      --dest=org.gnome.SessionManager /org/gnome/SessionManager \
      org.gnome.SessionManager.RequestReboot 2>&1 && return

    # KDE
    dbus-send --session --type=method_call --print-reply --reply-timeout=2000 \
      --dest=org.kde.ksmserver /KSMServer org.kde.KSMServerInterface.logout \
      int32:0 int32:1 int32:0 2>&1 && return

    # Mate
    dbus-send --session --type=method_call --print-reply --reply-timeout=2000 \
      --dest=org.mate.SessionManager /org/mate/SessionManager \
      org.mate.SessionManager.RequestReboot 2>&1 && return

    # XFCE and LXDE 
    dbus-send --session --type=method_call --print-reply --reply-timeout=2000 \
      --dest=org.freedesktop.PowerManagement /org/freedesktop/PowerManagement \
      org.freedesktop.PowerManagement.Reboot 2>&1 && return

    # ConsoleKit is the last resort since it doesn't allow inhibiting
    dbus-send --system --type=method_call --print-reply --reply-timeout=2000 \
      --dest=org.freedesktop.ConsoleKit /org/freedesktop/ConsoleKit/Manager \
      org.freedesktop.ConsoleKit.Manager.Restart 2>&1 && return

    die "I don't know how to reboot in this environment"
}

do_shutdown() {
    if is_root; then
        poweroff && return
    elif is_ltsp; then
        # Notify ldm that we want to poweroff after logoff
        xprop -root -f LTSP_LOGOUT_ACTION 8s -set LTSP_LOGOUT_ACTION HALT
        do_logout && return
    fi

    # Gnome
    dbus-send --session --type=method_call --print-reply --reply-timeout=2000 \
      --dest=org.gnome.SessionManager /org/gnome/SessionManager \
      org.gnome.SessionManager.RequestShutdown 2>&1 && return

    # KDE
    dbus-send --session --type=method_call --print-reply --reply-timeout=2000 \
      --dest=org.kde.ksmserver /KSMServer org.kde.KSMServerInterface.logout \
      int32:0 int32:2 int32:0 2>&1 && return

    # Mate
    dbus-send --session --type=method_call --print-reply --reply-timeout=2000 \
      --dest=org.mate.SessionManager /org/mate/SessionManager \
      org.mate.SessionManager.RequestShutdown 2>&1 && return

    # XFCE and LXDE 
    dbus-send --session --type=method_call --print-reply --reply-timeout=2000 \
      --dest=org.freedesktop.PowerManagement /org/freedesktop/PowerManagement \
      org.freedesktop.PowerManagement.Shutdown && return

    # ConsoleKit is the last resort since it doesn't allow inhibiting
    dbus-send --system --type=method_call --print-reply --reply-timeout=2000 \
      --dest=org.freedesktop.ConsoleKit /org/freedesktop/ConsoleKit/Manager \
      org.freedesktop.ConsoleKit.Manager.Stop 2>&1 && return

    die "I don't know how to shutdown in this environment"
}

# main
# Hide all dbus output unless DEBUG is set.
test -z "$DEBUG" && exec >/dev/null

case "$1" in
    -l|--logout)
        action=logout
        ;;
    -r|--reboot)
        action=reboot
        ;;
    -s|--shutdown)
        action=shutdown
        ;;
    *)
        die "Usage: endsession --logout|--reboot|--shutdown"
        ;;
esac

do_$action

17. Copy file “endsession” into directories “/usr/share/epoptes-client” and “/opt/ltsp/i386/usr/share/epoptes-client”:

sudo cp endsession /usr/share/epoptes-client
sudo cp endsession /opt/ltsp/i386/usr/share/epoptes-client

18. Update ltsp image:

sudo ltsp-update-image

19. As I want to use this server for demonstration purpose, I want to clear up dhcp lease every time the server boots. To do that just add these two lines into file “/etc/rc.local” above line “exit 0”:

rm /var/lib/dhcp/*
service isc-dhcp-server restart

20. That’s it. Enjoy your new LTSP system!

 

Debian: swap hardware name eth0 to eth1 and vice versa

On one of my computer I have two network cards, one for internet connection and the other one for local network. After a new Debian installation, the hardware names changed. Here is what I have done to swap them back:

1. Edit file “/etc/udev/rules.d/70-persistent-net.rules” using your favorite editor:

$ sudo nano /etc/udev/rules.d/70-persistent-net.rules

2. Change entry NAME=”eth0″ to NAME=”eth1″ and NAME=”eth1″ to NAME=”eth0″. My file then looks like this:

# This file was automatically generated by the /lib/udev/write_net_rules
# program, run by the persistent-net-generator.rules rules file.
#
# You can modify it, as long as you keep each rule on a single
# line, and change only the value of the NAME= key.

# PCI device 0x14e4:0x1677 (tg3)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:30:05:c5:73:e0", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

# PCI device 0x10ec:0x8169 (r8169)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:e0:52:ae:b2:95", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"

3. Edit file “/etc/network/interfaces” and change all “eth1” to “eth0”. My file then looks like this:

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
allow-hotplug eth0
iface eth0 inet dhcp

4. Reboot your computer.

5. That’s it!

An easy way to install real Firefox on Debian

After couple of times installing Firefox on Debian the hard way by compiling it from source code, I found a very easy way to install it. Here is the page I’m talking about and this is what I have done:

1. Remove IceWeasel if it’s installed:

$ sudo apt-get remove iceweasel

2. Add the following line into “/etc/apt/source.list” file:

deb http://packages.linuxmint.com debian import

3. Add PGP-key:

$ sudo gpg --keyserver pgp.mit.edu --recv-keys 3EE67F3D0FF405B2
$ sudo gpg --export 3EE67F3D0FF405B2 > 3EE67F3D0FF405B2.gpg
$ sudo apt-key add ./3EE67F3D0FF405B2.gpg
$ sudo rm ./3EE67F3D0FF405B2.gpg
4. Update apt:
$ sudo apt-get update
5. Install Firefox and its language pack:
$ sudo apt-get install firefox firefox-l10n-de
6. Enjoy!