SCORE BLOG

Sustainable Computing Research Laboratory


* Set user permition to mount and unmount:
sudoedit /etc/sudoers
<username> ALL=(root) NOPASSWD: /bin/mount
<username> ALL=(root) NOPASSWD: /bin/umount

*Enable password less ssh access

1. Generate ssh keypair with empty passphrases for users account at server
ssh-keygen

2. Add public key to of the thin-client (running Linux)
/home/<username>/.ssh/authorized_keys

* Use hosts.deny and hosts.allow to allow access to a specific set of users.

edit /etc/hosts.allow

ALL: 192.248.48.223 kumari
ALL: 192.248.48.224 manori

edit /etc/hosts.deny

ALL:ALL

In hosts.allow I have added the user name followed by users IP. This is useful for the auto-mounting script.

If you run this script once, all your pen drives will be mounted and when you run it twice it will unmount all the pen drives.

Auto mounting script:


#!/bin/bash
HOST=$(cat /etc/hosts.allow | grep '^ALL' | grep $USER | awk '{print $2}')
LOGIN="user@$HOST"
SHELL="ssh $LOGIN"
CONFIG="/tmp/thin_pen.$USER"
ZENITY_OPTS="--progress --auto-close --auto-kill --percentage=0"

#Mounting all remote USB disks to Remotely and then locally
function thin_mount(){
echo “#Mounting all USB pen drives…”
echo “10″
DISKS=($($SHELL /sbin/fdisk -l 2>/dev/null | grep ‘dev/sd[ab][0-9]‘ | awk ‘{print $1}’))
MOUNTS=($($SHELL mount 2>/dev/null| grep ‘dev/sd[ab][0-9]‘ | awk ‘{print $1″:”$3}’))

if [[ $DISKS == '' ]]
then
zenity –error –text=”No USB pen drives found please Insert/Reinsert your USB pen drive”
exit 0
fi

#Mounting all remote USB disks to Remotely and then locally
MOUNT_PT_NO=0
for DISK in “${DISKS[@]}”
do
#Checking whether the disk is remotely mounted
RMOUNTED=false
for MOUNT in “${MOUNTS[@]}”
do
if [[ $( echo $MOUNT | grep $DISK ) != '' ]]
then
RMOUNTED=true
break
fi
done

MOUNT_PT=$(echo $MOUNT | awk -F: ‘{print $2}’)
#If the disk is not remotely mountd, mounting the disk
if ! $RMOUNTED
then
MOUNT_PT=”/media/usb$MOUNT_PT_NO”
#$SHELL sudo mount $DISK $MOUNT_PT -o errors=remount-ro
$SHELL sudo mount $DISK $MOUNT_PT -o rw,umask=0000
MOUNT_PT_NO=$( expr $MOUNT_PT_NO + 1 )
fi

LOCAL_MOUNT=”$HOME/.thin_mount/$(basename $MOUNT_PT)”
echo $LOCAL_MOUNT >> $CONFIG

if [[ -e $LOCAL_MOUNT ]]
then
sshfs $LOGIN:$MOUNT_PT $LOCAL_MOUNT
else
mkdir -p $LOCAL_MOUNT
sshfs $LOGIN:$MOUNT_PT $LOCAL_MOUNT
fi
done

echo “50″
sleep 1
echo “100″
}

#Unmountin locally and remotely
function thin_umount(){
echo “#Unmounting all USB pen drives…”
echo “10″
for MOUNT in $( cat $CONFIG )
do
fusermount -u $MOUNT
$SHELL sudo umount /media/$(basename $MOUNT) 2>/dev/null
rm -fr $MOUNT
done
rm $CONFIG
echo “50″
sleep 1
echo “100″
}

if [[ -e $CONFIG ]]
then
thin_umount | zenity $ZENITY_OPTS –title=”Unmounting pen drives”
zenity –info –text=”Its safe to remove your USB pen drives now.”
else
thin_mount | zenity $ZENITY_OPTS –title=”Mounting USB pen drives”
zenity –info –text=”Your pen drives are mounted check in ‘Places’ or on the Desktop. \n\n*Don’t forget to unmount by clicking the same icon before removing the pen drive”
fi

Menu entry:


#!/usr/bin/env xdg-open
[Desktop Entry]
Encoding=UTF-8
Version=1.0
Type=Application
Terminal=false
Icon[en_US]=/usr/share/pixmaps/usb.png
Name[en_US]=Thin USB Mount/Unmount
Exec=/opt/thin_pen_mount.sh
Comment[en_US]=Thin USB Mount/Unmount
Name=Thin USB Mount/Unmount
Comment=Thin USB Mount/Unmount
Icon=/usr/share/pixmaps/usb.png

A web based control panel for PokuruPC is on the way…

It is equipped with these facilities:

  1. Enabling disabling multi-terminal mode
  2. Check available hardware
  3. Assign hardware to terminals
  4. Configuring advanced X configurations
  5. Add/remove users
  6. Monitor users and their statistics