Subversion Repositories ALCASAR

Rev

Rev 2075 | Rev 2107 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log

Rev 2075 Rev 2106
Line 1... Line 1...
1
#!/bin/bash
1
#!/bin/bash
2
# $Id: alcasar-watchdog.sh 2075 2016-11-28 17:46:32Z richard $
2
# $Id: alcasar-watchdog.sh 2106 2017-01-05 18:35:29Z richard $
3
 
3
 
4
# alcasar-watchdog.sh
4
# alcasar-watchdog.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
# Ce script prévient les usagers de l'indisponibilité de l'accès Internet
7
# Ce script prévient les usagers de l'indisponibilité de l'accès Internet
Line 129... Line 129...
129
#				rm $tmp_users_file
129
#				rm $tmp_users_file
130
#			fi
130
#			fi
131
 
131
 
132
		fi
132
		fi
133
 
133
 
134
		#this temporary file contains every 'user IP address' which are connected to ALCASAR (status.php still open)
134
		# this temporary file contains every 'user IP address' which are connected to ALCASAR (status.php still open)
135
		if [ -e $tmp_users_file ]; then 
135
		if [ -e $tmp_users_file ]; then 
136
 
-
 
137
			for ip_user in $(cat $tmp_users_file)
136
			for ip_user in $(cat $tmp_users_file)
138
			do
137
			do
139
				#Check if user is still connected
138
				# Check if thses users are also connected for chilli
140
				data_user=$(/usr/sbin/chilli_query list | grep -v "\.0\.0\.0" | awk '$5 == 1' | grep $ip_user)
139
				data_user=$(/usr/sbin/chilli_query list | grep -v "\.0\.0\.0" | awk '$5 == 1' | grep $ip_user)
141
				if [ $(echo $data_users | wc -l) -eq 0 ] #if user not in the file $tmp_users_file  (it means that status.php has been closed)
140
				if [ $(echo $data_users | wc -l) -eq 0 ] #if user not in the file $tmp_users_file  (it means that status.php has been closed)
142
				then
141
				then
143
					#save info in tmp_file
142
					#save info in tmp_file
144
					active_ip=`echo $data_user |cut -d" " -f2`
143
					active_ip=`echo $data_user |cut -d" " -f2`
145
		                        active_mac=`echo $data_user | cut -d" " -f1`
144
		                        active_mac=`echo $data_user | cut -d" " -f1`
146
		                        active_user=`echo $data_user |cut -d" " -f6`
145
		                        active_user=`echo $data_user |cut -d" " -f6`
147
					
-
 
148
					echo "$active_ip $active_mac $active_user" >> $tmp_file #save info for next time, user will be disconnected.
146
					echo "$active_ip $active_mac $active_user" >> $tmp_file #save info for next time, user will be disconnected.
149
				fi
147
				fi
150
			done
148
			done
151
			rm $tmp_users_file
149
			rm $tmp_users_file
152
		else
150
		else