Rev 789 | Rev 840 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log
#/bin/bash
# $Id: alcasar-logout.sh 790 2012-01-12 23:23:59Z richard $
# alcasar-logout.sh
# by Rexy
# This script is distributed under the Gnu General Public License (GPL)
# Déconnexion d'un ou de tous les usagers
# One user (or all users) disconnect
macallowed_file="/usr/local/etc/alcasar-macallowed"
radiussecret=""
OLDIFS=$IFS
IFS=$'\n'
usage="Usage: alcasar-logout.sh {user_name} | {all}"
nb_args=$#
args=$1
if [ $nb_args -eq 0 ]
then
nb_args=1
args="-h"
fi
case $args in
-\? | -h* | --h*)
echo "$usage"
exit 0
;;
all)
# on traite chaque équipements connus de chilli
for system in `/usr/sbin/chilli_query list |grep -v "\.0\.0\.0"`
do
active_session=`echo $system |cut -d" " -f5`
active_mac=`echo $system | cut -d" " -f1`
# on ne traite que les équipements exploitées par un usager authentifié
if [[ $(expr $active_session) -eq 1 ]]
then
# on ne traite pas les équipements en macallowed
mac_allowed=`cat $macallowed_file |grep $active_mac | wc -l`
if [ $mac_allowed -eq 0 ]
then
/usr/sbin/chilli_query logout $active_mac
fi
fi
done
;;
*)
echo "User-Name = $args" | /usr/bin/radclient 127.0.0.1:3799 40 $radiussecret
;;
esac
IFS=$OLDIFS