Subversion Repositories ALCASAR

Rev

Rev 672 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log

Rev Author Line No. Line
672 richard 1
#/bin/bash
63 franck 2
# $Id: alcasar-logout.sh 789 2012-01-10 22:05:05Z richard $
3
 
672 richard 4
# alcasar-logout.sh
5
# by Richard REY
6
# This script is distributed under the Gnu General Public License (GPL)
7
 
8
# Déconnexion d'un ou de tous les usagers
9
# One user (or all users) disconnect
10
 
789 richard 11
macallowed_file="/usr/local/etc/alcasar-macallowed"
12
radiussecret="ci0wkfI9"
597 richard 13
OLDIFS=$IFS
14
IFS=$'\n'
1 root 15
 
597 richard 16
usage="Usage: alcasar-logout.sh {user_name} | {all}"
1 root 17
nb_args=$#
18
args=$1
19
if [ $nb_args -eq 0 ]
20
then
21
	nb_args=1
22
	args="-h"
23
fi
24
case $args in
25
	-\? | -h* | --h*)
26
		echo "$usage"
27
		exit 0
28
		;;
597 richard 29
	all)
30
# on traite chaque équipements connus de chilli
31
		for system in `/usr/sbin/chilli_query list |grep -v "\.0\.0\.0"`
32
		do
33
			active_session=`echo $system |cut -d" " -f5`
34
			active_mac=`echo $system | cut -d" " -f1`
35
# on ne traite que les équipements exploitées par un usager authentifié 
36
			if [[ $(expr $active_session) -eq 1 ]]
37
			then
789 richard 38
# on ne traite pas les équipements en macallowed 
39
				mac_allowed=`cat $macallowed_file |grep $active_mac | wc -l`
40
				if [ $mac_allowed -eq 0 ]
41
				then
42
					/usr/sbin/chilli_query logout $active_mac
43
				fi
597 richard 44
			fi
45
		done
46
		;;
1 root 47
	*)
48
		echo "User-Name = $args" | /usr/bin/radclient 127.0.0.1:3799 40 $radiussecret
49
		;;
50
esac
597 richard 51
IFS=$OLDIFS
1 root 52