#!/bin/sh

SSHPORT=`grep "^Port " /etc/ssh/sshd_config|cut -f2 -d" "`
if [ -z $SSHPORT ]; then 
  SSHPORT=22
fi

SESS=$1
COMMAND=$2

NBSESS=`/bin/ls $SESS|wc -l` 
. /etc/profile.d/10lang.sh

if [ $NBSESS -gt 0 ];then
  if [ $NBSESS -gt 1 ];then PLUR="s";else PLUR="";fi
 /usr/bin/zenity --warning --warning-text "Vous avez dj $NBSESS autre$PLUR session$PLUR ouverte$PLUR.
Voulez-vous continuer? 
ATTENTION! Ceci terminera toutes vos sessions antrieures."

  if [ $? -eq 1 ]; then
    kill $PPID
  else
    for file in `ls -1 $SESS`; do
      XSESS=0
      . $SESS/$file
      if [ $XSESS -ne 0 ]; then
        kill $XSESS 
        #ssh -p $SSHPORT -i $HOME/.ssh/xtermkey $USER@$XHOST "kill $XSESS"
      fi
      rm $SESS/$file    
    done   
  fi
fi

