Subversion Repositories ALCASAR

Rev

Rev 790 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log

Rev 790 Rev 840
Line 1... Line 1...
1
#/bin/bash
1
#/bin/bash
2
# $Id: alcasar-logout.sh 790 2012-01-12 23:23:59Z richard $
2
# $Id: alcasar-logout.sh 840 2012-03-16 14:15:41Z richard $
3
 
3
 
4
# alcasar-logout.sh
4
# alcasar-logout.sh
5
# by Rexy
5
# by Rexy
6
# This script is distributed under the Gnu General Public License (GPL)
6
# This script is distributed under the Gnu General Public License (GPL)
7
 
7
 
8
# Déconnexion d'un ou de tous les usagers
8
# Déconnexion d'un ou de tous les usagers
9
# One user (or all users) disconnect
9
# Logout one user (or all users)
10
 
10
 
11
macallowed_file="/usr/local/etc/alcasar-macallowed"
-
 
12
radiussecret=""
11
radiussecret=""
13
OLDIFS=$IFS
12
OLDIFS=$IFS
14
IFS=$'\n'
13
IFS=$'\n'
15
 
14
 
16
usage="Usage: alcasar-logout.sh {user_name} | {all}"
15
usage="Usage: alcasar-logout.sh {user_name} | {all}"
Line 25... Line 24...
25
	-\? | -h* | --h*)
24
	-\? | -h* | --h*)
26
		echo "$usage"
25
		echo "$usage"
27
		exit 0
26
		exit 0
28
		;;
27
		;;
29
	all)
28
	all)
30
# on traite chaque équipements connus de chilli
29
# Compute each equipments known by chilli
31
		for system in `/usr/sbin/chilli_query list |grep -v "\.0\.0\.0"`
30
		for system in `/usr/sbin/chilli_query list |grep -v "\.0\.0\.0"`
32
		do
31
		do
-
 
32
			logout_users=""
33
			active_session=`echo $system |cut -d" " -f5`
33
			active_session=`echo $system |cut -d" " -f5`
-
 
34
			active_user=`echo $system|cut -d" " -f6`
34
			active_mac=`echo $system | cut -d" " -f1`
35
			active_mac=`echo $system | cut -d" " -f1`
35
# on ne traite que les équipements exploitées par un usager authentifié 
36
# Logout only authenticated users 
36
			if [[ $(expr $active_session) -eq 1 ]]
37
			if [[ $(expr $active_session) -eq 1 ]]
37
			then
38
			then
38
# on ne traite pas les équipements en macallowed 
39
# Don't logout MAC authenticated 
39
				mac_allowed=`cat $macallowed_file |grep $active_mac | wc -l`
-
 
40
				if [ $mac_allowed -eq 0 ]
40
				if [ "$active_mac" != "$active_user" ]
41
				then
41
				then
-
 
42
					logout_users=$logout_users" $active_user"
42
					/usr/sbin/chilli_query logout $active_mac
43
					/usr/sbin/chilli_query logout $active_mac
43
				fi
44
				fi
44
			fi
45
			fi
45
		done
46
		done
-
 
47
		echo "All users are now logout : ($logout_users)"
46
		;;
48
		;;
47
	*)
49
	*)
48
		echo "User-Name = $args" | /usr/bin/radclient 127.0.0.1:3799 40 $radiussecret
50
		echo "User-Name = $args" | /usr/bin/radclient 127.0.0.1:3799 40 $radiussecret
49
		;;
51
		;;
50
esac
52
esac