Subversion Repositories ALCASAR

Compare Revisions

No changes between revisions

Ignore whitespace Rev 596 → Rev 597

/alcasar.sh
60,7 → 60,7
DOMAIN="localdomain" # domaine local
EXTIF="eth0" # ETH0 est l'interface connectée à Internet (Box FAI)
INTIF="eth1" # ETH1 est l'interface connectée au réseau local de consultation
DEFAULT_PRIVATE_NETWORK_MASK="192.168.182.0/24" # adresse du réseau de consultation proposée par défaut
DEFAULT_PRIVATE_IP_MASK="192.168.182.1/24" # adresse d'ALCASAR (+masque) proposée par défaut sur le réseau de consultation
# ****** Paths - chemin des commandes *******
SED="/bin/sed -i"
# ****************** End of global parameters *********************
193,13 → 193,14
if [ "$mode" != "update" ]
then
# On affecte le nom d'organisme
header_install
ORGANISME=!
PTN='^[a-zA-Z0-9-]*$'
until [[ $(expr $ORGANISME : $PTN) -gt 0 ]]
do
if [ $Lang == "fr" ]
then echo "Entrez le nom de votre organisme : "
else echo -n "Enter the name of your organisation : "
then echo -n "Entrez le nom de votre organisme : "
else echo -n "Enter the name of your organism : "
fi
read ORGANISME
if [ "$ORGANISME" = "" ]
244,7 → 245,7
cat <<EOF > $FIC_PARAM
################################################
## ##
## ALCASAR Paramèters ##
## ALCASAR Parameters ##
## ##
################################################
 
268,8 → 269,8
{
header_install
if [ $Lang == "fr" ]
then echo "Par défaut, le plan d'adressage IP du réseau de consultation est : $DEFAULT_PRIVATE_NETWORK_MASK"
else echo "The default consultation network IP address is : $DEFAULT_PRIVATE_NETWORK_MASK"
then echo "Par défaut, l'adresse IP d'ALCASAR sur le réseau de consultation est : $DEFAULT_PRIVATE_IP_MASK"
else echo "The default ALCASAR IP address on consultation network is : $DEFAULT_PRIVATE_IP_MASK"
fi
response=0
PTN='^[oOyYnN]$'
283,53 → 284,63
done
if [ "$response" = "n" ] || [ "$response" = "N" ]
then
PRIVATE_NETWORK_MASK="0"
PRIVATE_IP_MASK="0"
PTN='^\([01]\?[[:digit:]][[:digit:]]\?\|2[0-4][[:digit:]]\|25[0-5]\).\([01]\?[[:digit:]][[:digit:]]\?\|2[0-4][[:digit:]]\|25[0-5]\).\([01]\?[[:digit:]][[:digit:]]\?\|2[0-4][[:digit:]]\|25[0-5]\).\([01]\?[[:digit:]][[:digit:]]\?\|2[0-4][[:digit:]]\|25[0-5]\)/[012]\?[[:digit:]]$'
until [[ $(expr $PRIVATE_NETWORK_MASK : $PTN) -gt 0 ]]
until [[ $(expr $PRIVATE_IP_MASK : $PTN) -gt 0 ]]
do
if [ $Lang == "fr" ]
then echo -n "Entrez un plan d'adressage IP au format CIDR (a.b.c.d/xx) : "
else echo -n "Enter a network IP address in CIDR format (a.b.c.d/xx) : "
then echo -n "Entrez l'adresse IP d'ALCASAR au format CIDR (a.b.c.d/xx) : "
else echo -n "Enter ALCASAR IP address in CIDR format (a.b.c.d/xx) : "
fi
read PRIVATE_NETWORK_MASK
read PRIVATE_IP_MASK
 
done
else
PRIVATE_NETWORK_MASK=$DEFAULT_PRIVATE_NETWORK_MASK
PRIVATE_IP_MASK=$DEFAULT_PRIVATE_IP_MASK
fi
# Définition de la config réseau côté "LAN de consultation"
hostname $HOSTNAME
echo "- Hostname : $HOSTNAME" >> $FIC_PARAM
PRIVATE_NETWORK=`/bin/ipcalc -n $DEFAULT_PRIVATE_NETWORK_MASK | cut -d"=" -f2` # @ réseau de consultation (ex.: 192.168.182.0)
PRIVATE_PREFIX=`/bin/ipcalc -p $DEFAULT_PRIVATE_NETWORK_MASK |cut -d"=" -f2` # prefixe du réseau (ex. 24)
PRIVATE_NETWORK_MASK=$PRIVATE_NETWORK/$PRIVATE_PREFIX # @ réseau + masque (x.0.0.0/8 ou x.y.0.0/16 ou x.y.z.0/24)
classe=$((PRIVATE_PREFIX/8)); # classe de réseau (ex.: 2=classe B, 3=classe C)
PRIVATE_NETWORK=`/bin/ipcalc -n $PRIVATE_IP_MASK | cut -d"=" -f2` # @ réseau de consultation (ex.: 192.168.182.0)
private_prefix=`/bin/ipcalc -p $PRIVATE_IP_MASK |cut -d"=" -f2` # prefixe du réseau (ex. 24)
PRIVATE_NETWORK_MASK=$PRIVATE_NETWORK/$private_prefix # @ + masque du réseau de consult (192.168.182.0/24)
classe=$((private_prefix/8)); # classe de réseau (ex.: 2=classe B, 3=classe C)
classe_sup=`expr $classe + 1`
private_network_ending=`echo $PRIVATE_NETWORK | cut -d"." -f$classe_sup`
private_network_ending=`echo $PRIVATE_NETWORK | cut -d"." -f$classe_sup` # dernier octet de l'@ de réseau
PRIVATE_NETWORK_SHORT=`echo $PRIVATE_NETWORK | cut -d"." -f1-$classe`. # @ compatible hosts.allow et hosts.deny (ex.: 192.168.182.)
PRIVATE_MASK=`/bin/ipcalc -m $PRIVATE_NETWORK_MASK | cut -d"=" -f2` # masque réseau de consultation (ex.: 255.255.255.0)
PRIVATE_BROADCAST=`/bin/ipcalc -b $PRIVATE_NETWORK_MASK | cut -d"=" -f2` # @ broadcast réseau de consultation (ex.: 192.168.182.255)
PRIVATE_IP=`echo $PRIVATE_NETWORK | cut -d"." -f1-3`"."`expr $private_network_ending + 1` # @ip du portail (côté réseau de consultation)
PRIVATE_DYN_FIRST_IP=`echo $PRIVATE_IP | cut -d"." -f1-3`"."`expr $private_network_ending + 1` # @ip du portail (côté réseau de consultation)
PRIVATE_DYN_LAST_IP=`echo $PRIVATE_BROADCAST | cut -d"." -f1-3`"."`expr $private_network_ending - 1` # @ip du portail (côté réseau de consultation)
PRIVATE_MASK=`/bin/ipcalc -m $PRIVATE_IP_MASK | cut -d"=" -f2` # masque réseau de consultation (ex.: 255.255.255.0)
PRIVATE_BROADCAST=`/bin/ipcalc -b $PRIVATE_IP_MASK | cut -d"=" -f2` # @ broadcast réseau de consultation (ex.: 192.168.182.255)
private_broadcast_ending=`echo $PRIVATE_BROADCAST | cut -d"." -f$classe_sup` # dernier octet de l'@ de broadcast
PRIVATE_IP=`echo $PRIVATE_IP_MASK | cut -d"/" -f1` # @ip du portail (côté réseau de consultation)
PRIVATE_DYN_FIRST_IP=`echo $PRIVATE_NETWORK | cut -d"." -f1-3`"."`expr $private_network_ending + 2` # @ip du portail (côté réseau de consultation)
PRIVATE_DYN_LAST_IP=`echo $PRIVATE_BROADCAST | cut -d"." -f1-3`"."`expr $private_broadcast_ending - 1` # @ip du portail (côté réseau de consultation)
# Récupération de la config réseau côté "Internet"
[ -e /etc/sysconfig/network-scripts/default-ifcfg-$EXTIF ] || cp /etc/sysconfig/network-scripts/ifcfg-$EXTIF /etc/sysconfig/network-scripts/default-ifcfg-$EXTIF
EXT_IP=`grep IPADDR /etc/sysconfig/network-scripts/default-ifcfg-$EXTIF|cut -d"=" -f2` # @ip du portail (côté Internet)
[ -e /etc/sysconfig/network.default ] || cp /etc/sysconfig/network /etc/sysconfig/network.default
PUBLIC_IP=`grep IPADDR /etc/sysconfig/network-scripts/default-ifcfg-$EXTIF|cut -d"=" -f2` # @ip du portail (côté Internet)
DNS1=`grep DNS1 /etc/sysconfig/network-scripts/default-ifcfg-$EXTIF|cut -d"=" -f2` # @ip 1er DNS
DNS2=`grep DNS2 /etc/sysconfig/network-scripts/default-ifcfg-$EXTIF|cut -d"=" -f2` # @ip 2ème DNS
DNS1=${DNS1:=208.67.220.220}
DNS2=${DNS2:=208.67.222.222}
EXT_NETMASK=`grep NETMASK /etc/sysconfig/network-scripts/default-ifcfg-$EXTIF|cut -d"=" -f2`
EXT_GATEWAY=`grep GATEWAY /etc/sysconfig/network-scripts/default-ifcfg-$EXTIF|cut -d"=" -f2`
echo "- IP address 'Internet side' ($EXTIF) : $EXT_IP / $EXT_NETMASK" >> $FIC_PARAM
echo "- Gateway : $EXT_GATEWAY" >> $FIC_PARAM
echo "- DNS servers : $DNS1 et $DNS2" >> $FIC_PARAM
echo "- IP address 'LAN side' ($INTIF) : $PRIVATE_IP/$PRIVATE_PREFIX" >> $FIC_PARAM
echo "- Dynamic IP addresses (DHCP) : from $PRIVATE_DYN_FIRST_IP to $PRIVATE_DYN_LAST_IP" >> $FIC_PARAM
echo "PRIVATE_NETWORK_MASK=$PRIVATE_NETWORK_MASK" > $DIR_DEST_ETC/alcasar-network
echo "PRIVATE_IP=$PRIVATE_IP" >> $DIR_DEST_ETC/alcasar-network
echo "DHCP=on" >> $DIR_DEST_ETC/alcasar-network
PUBLIC_NETMASK=`grep NETMASK /etc/sysconfig/network-scripts/default-ifcfg-$EXTIF|cut -d"=" -f2`
PUBLIC_PREFIX=`/bin/ipcalc -p $PUBLIC_IP $PUBLIC_NETMASK |cut -d"=" -f2` # prefixe du réseau (ex. 24)
PUBLIC_GATEWAY=`grep GATEWAY /etc/sysconfig/network-scripts/default-ifcfg-$EXTIF|cut -d"=" -f2`
echo "- WAN IP address ($EXTIF) :\t$PUBLIC_IP/$PUBLIC_PREFIX" >> $FIC_PARAM
echo "- Gateway IP address :\t$PUBLIC_GATEWAY" >> $FIC_PARAM
echo "- DNS servers :\t$DNS1 and $DNS2" >> $FIC_PARAM
echo "- LAN IP address ($INTIF) :\t$PRIVATE_IP_MASK" >> $FIC_PARAM
echo "- Dynamic IP addresses (DHCP) :\tfrom $PRIVATE_DYN_FIRST_IP to $PRIVATE_DYN_LAST_IP" >> $FIC_PARAM
echo "#### ALCASAR Network parameters ####" > $DIR_DEST_ETC/alcasar-network
echo "# Lauch the script 'alcasar-network.sh' after your changes" >> $DIR_DEST_ETC/alcasar-network
echo "# Lancez le script 'alcasar-network.sh' après vos modifications" >> $DIR_DEST_ETC/alcasar-network
echo "PUBLIC_IP=$PUBLIC_IP/$PUBLIC_PREFIX" >> $DIR_DEST_ETC/alcasar-network
echo "GW=$PUBLIC_GATEWAY" >> $DIR_DEST_ETC/alcasar-network
echo "DNS1=$DNS1" >> $DIR_DEST_ETC/alcasar-network
echo "DNS2=$DNS2" >> $DIR_DEST_ETC/alcasar-network
echo "PRIVATE_IP=$PRIVATE_IP_MASK" >> $DIR_DEST_ETC/alcasar-network
echo "DHCP=on" >> $DIR_DEST_ETC/alcasar-network
echo "DHCP_FIRST=$PRIVATE_DYN_FIRST_IP" >> $DIR_DEST_ETC/alcasar-network
echo "DHCP_LAST=$PRIVATE_DYN_LAST_IP" >> $DIR_DEST_ETC/alcasar-network
[ -e /etc/sysconfig/network.default ] || cp /etc/sysconfig/network /etc/sysconfig/network.default
# Configuration réseau
cat <<EOF > /etc/sysconfig/network
NETWORKING=yes
346,9 → 357,9
cat <<EOF > /etc/sysconfig/network-scripts/ifcfg-$EXTIF
DEVICE=$EXTIF
BOOTPROTO=static
IPADDR=$EXT_IP
NETMASK=$EXT_NETMASK
GATEWAY=$EXT_GATEWAY
IPADDR=$PUBLIC_IP
NETMASK=$PUBLIC_NETMASK
GATEWAY=$PUBLIC_GATEWAY
DNS1=127.0.0.1
ONBOOT=yes
METRIC=10
817,7 → 828,7
touch $DIR_DEST_ETC/alcasar-macallowed
chown root:apache $DIR_DEST_ETC/alcasar-*
chmod 660 $DIR_DEST_ETC/alcasar-*
echo "- Disconnect URL : http://alcasar:3990/logoff" >> $FIC_PARAM
echo "- User disconnect URL : http://alcasar:3990/logoff" >> $FIC_PARAM
# Configuration des fichier WEB d'interception (secret partagé avec coova-chilli et nom d'organisme)
$SED "s?^\$uamsecret =.*?\$uamsecret = \"$secretuam\";?g" $DIR_WEB/intercept.php
$SED "s?^\$userpassword=1.*?\$userpassword=1;?g" $DIR_WEB/intercept.php
1373,7 → 1384,7
/usr/sbin/userdel -f $rm_users
fi
done
# dans le cas d'une mise à jour, on charge la conf d'une version précédente
# Load the previous conf file
if [ "$mode" = "update" ]
then
$DIR_DEST_BIN/alcasar-conf.sh --load
1427,7 → 1438,7
-i | --install)
header_install
testing
# On teste la présence d'une version déjà installée
# Test if ALCASAR is already installed
if [ -e $DIR_WEB/VERSION ]
then
actual_version=`cat $DIR_WEB/VERSION`
1445,13 → 1456,15
fi
read response
done
if [ "$response" = "o" ] || [ "$response" = "O" ] || [ "$response" = "y" ] || [ "$response" = "Y" ]
if [ "$response" = "n" ] || [ "$response" = "N" ]
then
rm -f /tmp/alcasar-conf*
else
RUNNING_VERSION=`cat $DIR_WEB/VERSION|cut -d" " -f1`
MAJ_RUNNING_VERSION=`echo $RUNNING_VERSION|cut -d"." -f1`
MIN_RUNNING_VERSION=`echo $RUNNING_VERSION|cut -d"." -f2|cut -c1`
UPD_RUNNING_VERSION=`echo $RUNNING_VERSION|cut -d"." -f3`
# On crée le fichier de conf de la version actuelle
# Create the conf file of the running version
chmod u+x $DIR_SCRIPTS/alcasar-conf.sh
$DIR_SCRIPTS/alcasar-conf.sh --create
mode="update"
1465,16 → 1478,36
fi
if [ -e $DIR_WEB/VERSION ]
then
# On désinstalle la version actuelle
# Uninstall the running version
$DIR_SCRIPTS/sbin/alcasar-uninstall.sh
fi
if [ -e /tmp/alcasar-conf.tar.gz ]
if [ -e /tmp/alcasar-conf.tar.gz ] && [ "$mode" != "update" ]
then
if [ $Lang == "fr" ]
then echo "#### Installation avec mise à jour ####"
else echo "#### Installation with update ####"
then echo -n "Le fichier de configuration d'une ancienne version a été trouvé";
else echo -n "The configuration file of an old version has been found";
fi
# On récupère le nom d'organisme à partir de fichier de conf
response=0
PTN='^[oOnNyY]$'
until [[ $(expr $response : $PTN) -gt 0 ]]
do
if [ $Lang == "fr" ]
then echo -n "Voulez-vous l'utiliser (O/n)? ";
else echo -n "Do you want to use it (Y/n)?";
fi
read response
if [ "$response" = "n" ] || [ "$response" = "N" ]
then rm -f /tmp/alcasar-conf*
fi
done
fi
if [ -e /tmp/alcasar-conf.tar.gz ]
then
if [ $Lang == "fr" ]
then echo "#### Installation avec mise à jour ####";
else echo "#### Installation with update ####";
fi
# Read the organism name from the conf file
tar -xvf /tmp/alcasar-conf.tar.gz conf/organisme
ORGANISME=`cat $DIR_CONF/organisme`
mode="update"
1482,7 → 1515,6
mode="install"
fi
for func in init network gestion AC init_db param_radius param_web_radius param_chilli param_squid param_dansguardian antivirus firewall param_ulogd param_awstats param_dnsmasq BL cron post_install
 
do
$func
echo "*** 'debug' : end of function $func ***"; read a
1491,7 → 1523,10
-u | --uninstall)
if [ ! -e $DIR_DEST_SBIN/alcasar-uninstall.sh ]
then
echo "Aucune version d'ALCASAR n'a été trouvée.";
if [ $Lang == "fr" ]
then echo "ALCASAR n'est pas installé!";
else echo "ALCASAR isn't installed!";
fi
exit 0
fi
response=0
1498,16 → 1533,19
PTN='^[oOnN]$'
until [[ $(expr $response : $PTN) -gt 0 ]]
do
echo -n "Voulez-vous créer le fichier de conf de la version actuelle (0/n)? "
if [ $Lang == "fr" ]
then echo -n "Voulez-vous créer le fichier de configuration de la version actuelle (0/n)? ";
else echo -n "Do you want to crate the running version configuration file (Y/n)? ";
fi
read response
done
if [ "$reponse" = "o" ] || [ "$reponse" = "O" ]
if [ "$reponse" = "o" ] || [ "$reponse" = "O" ] || [ "$response" = "Y" ] || [ "$response" = "y" ]
then
$DIR_SCRIPT/alcasar-conf.sh --create
else
rm -f /tmp/alcasar-conf*
fi
# On désinstalle la version actuelle
# Uninstall the running version
$DIR_SCRIPTS/sbin/alcasar-uninstall.sh
;;
*)
/scripts/sbin/alcasar-logout.sh
3,8 → 3,10
 
# deconnexion d'un usager
radiussecret=""
OLDIFS=$IFS
IFS=$'\n'
 
usage="Usage: alcasar-logout.sh nom_d'usager"
usage="Usage: alcasar-logout.sh {user_name} | {all}"
nb_args=$#
args=$1
if [ $nb_args -eq 0 ]
17,8 → 19,22
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
/usr/sbin/chilli_query logout $active_mac
fi
done
;;
*)
echo "User-Name = $args" | /usr/bin/radclient 127.0.0.1:3799 40 $radiussecret
;;
esac
IFS=$OLDIFS
 
/scripts/sbin/alcasar-network.sh
0,0 → 1,76
#!/bin/sh
 
# alcasar-network.sh
# by Richard REY
# This script is distributed under the Gnu General Public License (GPL)
 
# Install network parameters for ALCASAR
# Installation des paramètres réseau d'ALCASAR
 
# ******* Global *******
DIR_DEST_ETC="/usr/local/etc" # répertoire des fichiers de conf
FIC_PARAM="/root/ALCASAR-parameters.txt"
HOSTNAME="alcasar"
DOMAIN="localdomain" # domaine local
EXTIF="eth0" # ETH0 est l'interface connectée à Internet (Box FAI)
INTIF="eth1" # ETH1 est l'interface connectée au réseau local de consultation
SED="/bin/sed -i"
 
PTN="\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\/[012]?[0-9]\b"
PRIVATE_IP_MASK=`cat $DIR_DEST_ETC/alcasar-network|grep PRIVATE_IP|cut -d"=" -f2`
check=$(echo $PRIVATE_IP_MASK | egrep $PTN)
if [[ "$?" -ne 0 ]]
then
echo "Syntax error for PRIVATE_IP ($PRIVATE_IP)"
exit 0
fi
PUBLIC_IP_MASK=`cat $DIR_DEST_ETC/alcasar-network|grep PUBLIC_IP|cut -d"=" -f2`
check=$(echo $PUBLIC_IP_MASK | egrep $PTN)
if [[ "$?" -ne 0 ]]
then
echo "Syntax error for PUBLIC_IP ($PUBLIC_IP)"
exit 0
fi
PTN="\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b"
PUBLIC_GATEWAY=`cat $DIR_DEST_ETC/alcasar-network|grep GW|cut -d"=" -f2`
check=$(echo $PUBLIC_GATEWAY | egrep $PTN)
if [[ "$?" -ne 0 ]]
then
echo "Syntax error for the Gateway IP ($PUBLIC_GATEWAY)"
exit 0
fi
DNS1=`cat $DIR_DEST_ETC/alcasar-network|grep DNS1|cut -d"=" -f2`
check=$(echo $PUBLIC_GATEWAY | egrep $PTN)
if [[ "$?" -ne 0 ]]
then
echo "Syntax error for the IP address of the first DNS server ($EXT_GATEWAY)"
exit 0
fi
DNS2=`cat $DIR_DEST_ETC/alcasar-network|grep DNS2|cut -d"=" -f2`
check=$(echo $PUBLIC_GATEWAY | egrep $PTN)
if [[ "$?" -ne 0 ]]
then
echo "Syntax error for the IP address of the second DNS server ($EXT_GATEWAY)"
exit 0
fi
PRIVATE_NETWORK=`/bin/ipcalc -n $PRIVATE_IP_MASK | cut -d"=" -f2` # @ réseau de consultation (ex.: 192.168.182.0)
private_prefix=`/bin/ipcalc -p $PRIVATE_IP_MASK |cut -d"=" -f2` # prefixe du réseau (ex. 24)
PRIVATE_NETWORK_MASK=$PRIVATE_NETWORK/$private_prefix # @ + masque du réseau de consult (192.168.182.0/24)
classe=$((private_prefix/8)); # classe de réseau (ex.: 2=classe B, 3=classe C)
classe_sup=`expr $classe + 1`
private_network_ending=`echo $PRIVATE_NETWORK | cut -d"." -f$classe_sup` # dernier octet de l'@ de réseau
PRIVATE_NETWORK_SHORT=`echo $PRIVATE_NETWORK | cut -d"." -f1-$classe`. # @ compatible hosts.allow et hosts.deny (ex.: 192.168.182.)
PRIVATE_MASK=`/bin/ipcalc -m $PRIVATE_IP_MASK | cut -d"=" -f2` # masque réseau de consultation (ex.: 255.255.255.0)
PRIVATE_BROADCAST=`/bin/ipcalc -b $PRIVATE_IP_MASK | cut -d"=" -f2` # @ broadcast réseau de consultation (ex.: 192.168.182.255)
private_broadcast_ending=`echo $PRIVATE_BROADCAST | cut -d"." -f$classe_sup` # dernier octet de l'@ de broadcast
PRIVATE_IP=`echo $PRIVATE_IP_MASK | cut -d"/" -f1` # @ip du portail (côté réseau de consultation)
PRIVATE_DYN_FIRST_IP=`echo $PRIVATE_NETWORK | cut -d"." -f1-3`"."`expr $private_network_ending + 2` # @ip du portail (côté réseau de consultation)
PRIVATE_DYN_LAST_IP=`echo $PRIVATE_BROADCAST | cut -d"." -f1-3`"."`expr $private_broadcast_ending - 1` # @ip du portail (côté réseau de consultation)
 
# Change in ALCASAR-parameters
$SED "s?^- WAN IP.*?- WAN IP address ($EXTIF) :\t$PUBLIC_IP_MASK?g" $FIC_PARAM
$SED "s?^- Gateway.*?- Gateway IP addess :\t$PUBLIC_GATEWAY?g" $FIC_PARAM
$SED "s?^- DNS servers.*?- DNS servers :\t$DNS1 and $DNS2?g" $FIC_PARAM
$SED "s?^- LAN IP.*?- LAN IP address ($INTIF) :\t$PRIVATE_IP_MASK?g" $FIC_PARAM
$SED "s?^- Dynamic.*?- Dynamic IP addresses (DHCP) :\tfrom $PRIVATE_DYN_FIRST_IP to $PRIVATE_DYN_LAST_IP?g" $FIC_PARAM
# Change in ...
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
Added: svn:executable
+*
\ No newline at end of property
/scripts/alcasar-watchdog.sh
15,6 → 15,7
tmp_file="/tmp/watchdog.txt"
DIR_WEB="/var/www/html"
Index_Page="$DIR_WEB/index.php"
OLDIFS=$IFS
IFS=$'\n'
 
# Fonction appelée si un Pb de connectivité Internet
117,4 → 118,4
fi
fi
done
 
IFS=$OLDIFS
/web/acc/manager/htdocs/clear_opensessions.php
1,5 → 1,23
<?php
require('/etc/freeradius-web/config.php');
require_once('../lib/xlat.php');
if (is_file("../lib/sql/drivers/$config[sql_type]/functions.php"))
include_once("../lib/sql/drivers/$config[sql_type]/functions.php");
else{
echo <<<EOM
<title>Fermeture des sessions ouvertes pour l'utilisateur $login</title>
<meta http-equiv="Content-Type" content="text/html; charset=$config[general_charset]">
<link rel="stylesheet" href="style.css">
</head>
<body>
<center>
<b>Could not include SQL library functions. Aborting</b>
</body>
</html>
EOM;
exit();
}
 
echo <<<EOM
<html>
<head>
29,6 → 47,14
 
include("../html/user_toolbar.html.php");
 
$open_sessions = 0;
 
$sql_extra_query = '';
if ($config[sql_accounting_extra_query] != ''){
$sql_extra_query = xlat($config[sql_accounting_extra_query],$login,$config);
$sql_extra_query = da_sql_escape_string($sql_extra_query);
}
 
print <<<EOM
</table>
 
47,11 → 73,97
<table border=0 width=100% cellpadding=12 cellspacing=0 bgcolor="#ffffd0" valign=top>
<tr><td>
EOM;
if ($drop_conns == 1){
$method = 'snmp';
$nastype = 'cisco';
if ($config[general_sessionclear_method] != '')
$method = $config[general_sessionclear_method];
if ($config[general_nas_type] != '')
$nastype = $config[general_nas_type];
if ($config[general_ld_library_path] != '')
putenv("LD_LIBRARY_PATH=$config[general_ld_library_path]");
$nas_by_ip = array();
$meth_by_ip = array();
$nastype_by_ip = array();
foreach ($nas_list as $nas){
if ($nas[ip] != ''){
$ip = $nas[ip];
$nas_by_ip[$ip] = $nas[community];
$meth_by_ip[$ip] = $nas[sessionclear_method];
$nastype_by_ip[$ip] = $nas[nas_type];
}
}
 
$link = @da_sql_pconnect($config);
if ($link){
$search = @da_sql_query($link,$config,
"SELECT nasipaddress,acctsessionid FROM $config[sql_accounting_table]
WHERE username = '$login' AND acctstoptime IS NULL;");
if ($search){
while($row = @da_sql_fetch_array($search,$config)){
$sessionid = $row[acctsessionid];
$sessionid = hexdec($sessionid);
$nas = $row[nasipaddress];
$port = $row[nasportid];
$meth = $meth_by_ip[$nas];
$nastype = ($nastype_by_ip[$nas] != '') ? $nastype_by_ip[$nas] : $nastype;
$comm = $nas_by_ip[$nas];
if ($meth == '')
$meth = $method;
if ($meth == 'snmp' && $comm != '')
exec("$config[general_sessionclear_bin] $nas snmp $nastype $login $sessionid $comm");
if ($meth == 'telnet')
exec("$config[general_sessionclear_bin] $nas telnet $nastype $login $sessionid $port");
}
}
else
echo "<b>Database query failed: " . da_sql_error($link,$config) . "</b><br>\n";
}
else
echo "<b>Could not connect to SQL database</b><br>\n";
}
if ($clear_sessions == 1)
{
exec ("sudo /usr/local/sbin/alcasar-logout.sh $login");
$sql_servers = array();
if ($config[sql_extra_servers] != '')
$sql_servers = explode(' ',$config[sql_extra_servers]);
$quer = '= 0';
if ($config[sql_type] == 'pg')
$quer = 'IS NULL';
$sql_servers[] = $config[sql_server];
foreach ($sql_servers as $server)
{
$link = @da_sql_host_connect($server,$config);
if ($link)
{
$res = @da_sql_query($link,$config,
"DELETE FROM $config[sql_accounting_table]
WHERE username='$login' AND acctstoptime $quer $sql_extra_query;");
if ($res)
echo "<b>La comptabilit&eacute; des sessions pour cet usager a &eacute;t&eacute; arr&eacute;t&eacute;e</b><br>\n";
else
echo "<b>Error deleting open sessions for user" . da_sql_error($link,$config) . "</b><br>\n";
}
else
echo "<b>Could not connect to SQL database</b><br>\n";
}
}
exec ("sudo /usr/sbin/chilli_query list|cut -d\" \" -f5,6|grep $login|grep ^1|wc -l" , $open_sessions);
$link = @da_sql_pconnect($config);
if ($link){
$search = @da_sql_query($link,$config,
"SELECT COUNT(*) AS counter FROM $config[sql_accounting_table]
WHERE username = '$login' AND acctstoptime IS NULL $sql_extra_query;");
if ($search){
if ($row = @da_sql_fetch_array($search,$config))
$open_sessions = $row[counter];
}
else
echo "<b>Database query failed: " . da_sql_error($link,$config) . "</b><br>\n";
}
else
echo "<b>Could not connect to SQL database</b><br>\n";
?>
<form method=post>
<input type=hidden name=login value=<?php print $login ?>>
60,12 → 172,12
<tr>
<td align=center>
<?
if ($open_sessions[0] == 0)
if ($open_sessions == 0)
{
echo "L'usager $login n'a pas de session ouverte";
}
else {
echo "L'usager $login a <i>$open_sessions[0]</i> session(s) ouverte(s)<br><br>";
echo "L'usager $login a <i>$open_sessions</i> session(s) ouverte(s)<br><br>";
echo "&Ecirc;tes-vous certain de vouloir ";
if ($open_sessions == 1) { echo "la"; } else {echo "les"; }
echo " fermer ? ";
74,6 → 186,7
?>
</form>
</td></tr></table>
<!--<input type=submit class=button value="Oui, poubelliser les connexions" OnClick="this.form.drop_conns.value=1">-->
</td></tr></table>
</TD></TR></TABLE>
</body>