Subversion Repositories ALCASAR

Rev

Rev 1056 | Rev 2223 | 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 1827 2016-04-19 09:47:29Z raphael.pion $
3
 
672 richard 4
# alcasar-logout.sh
790 richard 5
# by Rexy
672 richard 6
# This script is distributed under the Gnu General Public License (GPL)
7
 
8
# Déconnexion d'un ou de tous les usagers
840 richard 9
# Logout one user (or all users)
672 richard 10
 
790 richard 11
radiussecret=""
597 richard 12
OLDIFS=$IFS
13
IFS=$'\n'
1 root 14
 
597 richard 15
usage="Usage: alcasar-logout.sh {user_name} | {all}"
1 root 16
nb_args=$#
17
args=$1
18
if [ $nb_args -eq 0 ]
19
then
20
	nb_args=1
21
	args="-h"
22
fi
23
case $args in
24
	-\? | -h* | --h*)
25
		echo "$usage"
26
		exit 0
27
		;;
597 richard 28
	all)
840 richard 29
# Compute each equipments known by chilli
597 richard 30
		for system in `/usr/sbin/chilli_query list |grep -v "\.0\.0\.0"`
31
		do
840 richard 32
			logout_users=""
597 richard 33
			active_session=`echo $system |cut -d" " -f5`
840 richard 34
			active_user=`echo $system|cut -d" " -f6`
597 richard 35
			active_mac=`echo $system | cut -d" " -f1`
840 richard 36
# Logout only authenticated users 
597 richard 37
			if [[ $(expr $active_session) -eq 1 ]]
38
			then
840 richard 39
# Don't logout MAC authenticated 
40
				if [ "$active_mac" != "$active_user" ]
789 richard 41
				then
840 richard 42
					logout_users=$logout_users" $active_user"
789 richard 43
					/usr/sbin/chilli_query logout $active_mac
44
				fi
597 richard 45
			fi
46
		done
840 richard 47
		echo "All users are now logout : ($logout_users)"
597 richard 48
		;;
1 root 49
	*)
50
		echo "User-Name = $args" | /usr/bin/radclient 127.0.0.1:3799 40 $radiussecret
51
		;;
52
esac
597 richard 53
IFS=$OLDIFS
1 root 54