| Line 1... |
Line 1... |
| 1 |
#!/bin/bash
|
1 |
#!/bin/bash
|
| 2 |
# $Id: alcasar.sh 2664 2018-11-19 17:35:12Z tom.houdayer $
|
2 |
# $Id: alcasar.sh 2669 2018-12-08 17:30:01Z tom.houdayer $
|
| 3 |
|
3 |
|
| 4 |
# alcasar.sh
|
4 |
# alcasar.sh
|
| 5 |
# ALCASAR is a Free and open source NAC created by Franck BOUIJOUX (3abtux), Pascal LEVANT and Richard REY (Rexy)
|
5 |
# ALCASAR is a Free and open source NAC created by Franck BOUIJOUX (3abtux), Pascal LEVANT and Richard REY (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 |
# team@alcasar.net
|
7 |
# team@alcasar.net
|
| Line 73... |
Line 73... |
| 73 |
DB_USER="radius" # user name allows to request the users database
|
73 |
DB_USER="radius" # user name allows to request the users database
|
| 74 |
DB_GAMMU="gammu" # database name used by Gammu-smsd
|
74 |
DB_GAMMU="gammu" # database name used by Gammu-smsd
|
| 75 |
# ******* Network parameters - paramètres réseau *******
|
75 |
# ******* Network parameters - paramètres réseau *******
|
| 76 |
HOSTNAME="alcasar" # default hostname
|
76 |
HOSTNAME="alcasar" # default hostname
|
| 77 |
DOMAIN="localdomain" # default local domain
|
77 |
DOMAIN="localdomain" # default local domain
|
| 78 |
EXTIF=`/usr/sbin/ip route|grep default|head -n1|cut -d" " -f5` # EXTIF is connected to the ISP broadband modem/router (In France : Box-FAI)
|
78 |
EXTIF='' # EXTIF is connected to the ISP broadband modem/router (In France : Box-FAI)
|
| 79 |
INTIF=`/usr/sbin/ip link|grep '^[[:digit:]]:'|grep -v "lo\|$EXTIF\|tun0"|head -n1|cut -d" " -f2|tr -d ":"` # INTIF is connected to the consultation network
|
79 |
INTIF='' # INTIF is connected to the consultation network
|
| 80 |
MTU="1500"
|
80 |
MTU="1500"
|
| 81 |
DEFAULT_PRIVATE_IP_MASK="192.168.182.1/24" # Default ALCASAR IP address
|
81 |
DEFAULT_PRIVATE_IP_MASK="192.168.182.1/24" # Default ALCASAR IP address
|
| 82 |
# ****** Paths - chemin des commandes *******
|
82 |
# ****** Paths - chemin des commandes *******
|
| 83 |
SED="/bin/sed -i"
|
83 |
SED="/bin/sed -i"
|
| 84 |
# ****************** End of global parameters *********************
|
84 |
# ****************** End of global parameters *********************
|
| Line 148... |
Line 148... |
| 148 |
then
|
148 |
then
|
| 149 |
ARCH=`echo $i|cut -d"=" -f2`
|
149 |
ARCH=`echo $i|cut -d"=" -f2`
|
| 150 |
unknown_os=`expr $unknown_os + 1`
|
150 |
unknown_os=`expr $unknown_os + 1`
|
| 151 |
fi
|
151 |
fi
|
| 152 |
done
|
152 |
done
|
| 153 |
if [ "$ARCH" == "i586" ]
|
153 |
if [ "$ARCH" != "x86_64" ]
|
| 154 |
then
|
154 |
then
|
| 155 |
if [ $Lang == "fr" ]
|
155 |
if [ $Lang == "fr" ]
|
| 156 |
then echo -n "Votre architecture matérielle doit être en 64bits"
|
156 |
then echo "Votre architecture matérielle doit être en 64bits"
|
| 157 |
else echo -n "You hardware architecture must be 64bits"
|
157 |
else echo "You hardware architecture must be 64bits"
|
| 158 |
fi
|
158 |
fi
|
| 159 |
exit 1
|
159 |
exit 1
|
| 160 |
fi
|
160 |
fi
|
| 161 |
IFS="$old"
|
161 |
IFS="$old"
|
| - |
|
162 |
if [[ ( $unknown_os != 3 ) || ("$DISTRIBUTION" != "Mageia" ) || ( "$CURRENT_VERSION" != "6" ) ]]
|
| - |
|
163 |
then
|
| - |
|
164 |
if [ -e /var/tmp/alcasar-conf.tar.gz ] # update
|
| - |
|
165 |
then
|
| - |
|
166 |
echo
|
| - |
|
167 |
if [ $Lang == "fr" ]
|
| - |
|
168 |
then
|
| - |
|
169 |
echo "La mise à jour automatique d'ALCASAR ne peut pas être réalisée."
|
| - |
|
170 |
echo "1 - Effectuez une sauvegarde des fichiers de traçabilité et de la base des usagers via l'ACC"
|
| - |
|
171 |
echo "2 - Installez Linux-Mageia 6.0 (64bits) et ALCASAR (cf. doc d'installation)"
|
| - |
|
172 |
echo "3 - Importez votre base des usagers"
|
| - |
|
173 |
else
|
| - |
|
174 |
echo "The automatic update of ALCASAR can't be performed."
|
| - |
|
175 |
echo "1 - Save your traceability files and the user database"
|
| - |
|
176 |
echo "2 - Install Linux-Mageia 6 (64bits) & ALCASAR (cf. installation doc)"
|
| - |
|
177 |
echo "3 - Import your users database"
|
| - |
|
178 |
fi
|
| - |
|
179 |
else
|
| - |
|
180 |
if [ $Lang == "fr" ]
|
| - |
|
181 |
then echo "L'installation d'ALCASAR ne peut pas être réalisée."
|
| - |
|
182 |
else echo "The installation of ALCASAR can't be performed."
|
| - |
|
183 |
fi
|
| - |
|
184 |
fi
|
| - |
|
185 |
echo
|
| - |
|
186 |
if [ $Lang == "fr" ]
|
| - |
|
187 |
then echo "Le système d'exploitation doit être remplacé (Mageia6-64bits)"
|
| - |
|
188 |
else echo "The OS must be replaced (Mageia6-64bits)"
|
| - |
|
189 |
fi
|
| - |
|
190 |
exit 0
|
| - |
|
191 |
fi
|
| - |
|
192 |
|
| 162 |
# Test if ALCASAR is already installed
|
193 |
# Test if ALCASAR is already installed
|
| 163 |
if [ -e $CONF_FILE ]
|
194 |
if [ -e $CONF_FILE ]
|
| 164 |
then
|
195 |
then
|
| 165 |
current_version=`grep ^VERSION= $CONF_FILE | cut -d"=" -f2`
|
196 |
current_version=`grep ^VERSION= $CONF_FILE | cut -d"=" -f2`
|
| 166 |
if [ $Lang == "fr" ]
|
197 |
if [ $Lang == "fr" ]
|
| 167 |
then echo -n "La version "; echo -n $current_version ; echo " d'ALCASAR est déjà installée";
|
198 |
then echo "La version $current_version d'ALCASAR est déjà installée"
|
| 168 |
else echo -n "ALCASAR Version "; echo -n $current_version ; echo " is already installed";
|
199 |
else echo "ALCASAR version $current_version is already installed"
|
| 169 |
fi
|
200 |
fi
|
| 170 |
response=0
|
201 |
response=0
|
| 171 |
PTN='^[12]$'
|
202 |
PTN='^[12]$'
|
| 172 |
until [[ $(expr $response : $PTN) -gt 0 ]]
|
203 |
until [[ $(expr $response : $PTN) -gt 0 ]]
|
| 173 |
do
|
204 |
do
|
| 174 |
if [ $Lang == "fr" ]
|
205 |
if [ $Lang == "fr" ]
|
| 175 |
then
|
- |
|
| 176 |
echo -n "Tapez '1' pour une mise à jour; Tapez '2' pour une réinstallation : "
|
206 |
then echo -n "Tapez '1' pour une mise à jour; Tapez '2' pour une réinstallation : "
|
| 177 |
else
|
- |
|
| 178 |
echo -n "Hit '1' for an update; Hit '2' for a reinstallation : "
|
207 |
else echo -n "Hit '1' for an update; Hit '2' for a reinstallation : "
|
| 179 |
fi
|
208 |
fi
|
| 180 |
read response
|
209 |
read response
|
| 181 |
done
|
210 |
done
|
| 182 |
if [ "$response" = "2" ]
|
211 |
if [ "$response" = "2" ]
|
| 183 |
then
|
212 |
then
|
| Line 191... |
Line 220... |
| 191 |
# Create the current conf file
|
220 |
# Create the current conf file
|
| 192 |
$DIR_SCRIPTS/alcasar-conf.sh --create
|
221 |
$DIR_SCRIPTS/alcasar-conf.sh --create
|
| 193 |
mode="update"
|
222 |
mode="update"
|
| 194 |
fi
|
223 |
fi
|
| 195 |
fi
|
224 |
fi
|
| 196 |
if [[ ( $unknown_os != 3 ) || ("$DISTRIBUTION" != "Mageia" ) || ( "$CURRENT_VERSION" != "6" ) ]]
|
- |
|
| 197 |
then
|
- |
|
| 198 |
if [ -e /var/tmp/alcasar-conf.tar.gz ] # update
|
- |
|
| 199 |
then
|
- |
|
| 200 |
echo
|
- |
|
| 201 |
if [ $Lang == "fr" ]
|
225 |
# Test free space on /var
|
| 202 |
then
|
- |
|
| 203 |
echo "La mise à jour automatique d'ALCASAR ne peut pas être réalisée."
|
- |
|
| 204 |
echo "1 - Effectuez une sauvegarde des fichiers de traçabilité et de la base des usagers via l'ACC"
|
- |
|
| 205 |
echo "2 - Installez Linux-Mageia 6.0 (64bits) et ALCASAR (cf. doc d'installation)"
|
- |
|
| 206 |
echo "3 - Importez votre base des usagers"
|
- |
|
| 207 |
else
|
- |
|
| 208 |
echo "The automatic update of ALCASAR can't be performed."
|
- |
|
| 209 |
echo "1 - Save your traceability files and the user database"
|
- |
|
| 210 |
echo "2 - Install Linux-Mageia 6 (64bits) & ALCASAR (cf. installation doc)"
|
- |
|
| 211 |
echo "3 - Import your users database"
|
- |
|
| 212 |
fi
|
- |
|
| 213 |
else
|
- |
|
| 214 |
if [ $Lang == "fr" ]
|
- |
|
| 215 |
then
|
- |
|
| 216 |
echo "L'installation d'ALCASAR ne peut pas être réalisée."
|
- |
|
| 217 |
else
|
- |
|
| 218 |
echo "The installation of ALCASAR can't be performed."
|
- |
|
| 219 |
fi
|
- |
|
| 220 |
fi
|
- |
|
| 221 |
echo
|
- |
|
| 222 |
if [ $Lang == "fr" ]
|
- |
|
| 223 |
then
|
- |
|
| 224 |
echo "Le système d'exploitation doit être remplacé (Mageia6-64bits)"
|
- |
|
| 225 |
else
|
- |
|
| 226 |
echo "The OS must be replaced (Mageia6-64bits)"
|
- |
|
| 227 |
fi
|
- |
|
| 228 |
exit 0
|
- |
|
| 229 |
fi
|
- |
|
| 230 |
if [ ! -d /var/log/netflow/porttracker ]
|
226 |
if [ ! -d /var/log/netflow/porttracker ]
|
| 231 |
then
|
227 |
then
|
| 232 |
# Test free space on /var
|
- |
|
| 233 |
free_space=`df -BG --output=avail /var|tail -1|tr -d [:space:]G`
|
228 |
free_space=`df -BG --output=avail /var|tail -1|tr -d [:space:]G`
|
| 234 |
if [ $free_space -lt 10 ]
|
229 |
if [ $free_space -lt 10 ]
|
| 235 |
then
|
230 |
then
|
| 236 |
if [ $Lang == "fr" ]
|
231 |
if [ $Lang == "fr" ]
|
| 237 |
then echo "place disponible sur /var insufisante ($free_space Go au lieu de 10 Go au minimum)"
|
232 |
then echo "place disponible sur /var insufisante ($free_space Go au lieu de 10 Go au minimum)"
|
| 238 |
else echo "not enough free space on /var ($free_space GB instead of at least 10 GB)"
|
233 |
else echo "not enough free space on /var ($free_space GB instead of at least 10 GB)"
|
| 239 |
fi
|
234 |
fi
|
| 240 |
exit 0
|
235 |
exit 0
|
| 241 |
fi
|
236 |
fi
|
| 242 |
fi
|
237 |
fi
|
| - |
|
238 |
|
| - |
|
239 |
# Detect external/internal interfaces
|
| - |
|
240 |
if [ -z "$EXTIF" ]; then
|
| - |
|
241 |
EXTIF=$(/usr/sbin/ip route list | awk '/^default / {print $5}')
|
| - |
|
242 |
if [ -z "$EXTIF" ]; then
|
| - |
|
243 |
if [ "$Lang" == 'fr' ]
|
| - |
|
244 |
then echo -n "Aucune passerelle par défaut configurée"
|
| - |
|
245 |
else echo -n "No default gateway configured"
|
| - |
|
246 |
fi
|
| - |
|
247 |
exit 1
|
| - |
|
248 |
fi
|
| - |
|
249 |
fi
|
| - |
|
250 |
if [ "$Lang" == 'fr' ]
|
| - |
|
251 |
then echo "Interface externe (Internet) utilisée : $EXTIF"
|
| - |
|
252 |
else echo "External interface (Internet) used: $EXTIF"
|
| - |
|
253 |
fi
|
| - |
|
254 |
|
| - |
|
255 |
if [ -z "$INTIF" ]; then
|
| - |
|
256 |
interfacesList=$(/usr/sbin/ip -br link show | cut -d' ' -f1 | grep -v "^\(lo\|tun0\|$EXTIF\)\$")
|
| - |
|
257 |
interfacesCount=$(echo "$interfacesList" | wc -l)
|
| - |
|
258 |
if [ $interfacesCount -eq 0 ]; then
|
| - |
|
259 |
if [ "$Lang" == 'fr' ]
|
| - |
|
260 |
then echo "Aucune interface de disponible pour le réseau interne"
|
| - |
|
261 |
else echo "No interface available for the internal network"
|
| - |
|
262 |
fi
|
| - |
|
263 |
exit 1
|
| - |
|
264 |
elif [ $interfacesCount -eq 1 ]; then
|
| - |
|
265 |
INTIF="$interfacesList"
|
| - |
|
266 |
else
|
| - |
|
267 |
interfacesSorted=$(/usr/sbin/ip -br addr | grep -v "^\(lo\|tun0\|$EXTIF\) " | sort -b -k3n -k2r -k1)
|
| - |
|
268 |
interfacePreferred=$(echo "$interfacesSorted" | head -1 | cut -d' ' -f1)
|
| - |
|
269 |
|
| - |
|
270 |
if [ "$Lang" == 'fr' ]
|
| - |
|
271 |
then echo 'Liste des interfaces disponible :'
|
| - |
|
272 |
else echo 'List of available interfaces:'
|
| - |
|
273 |
fi
|
| - |
|
274 |
echo "$interfacesSorted"
|
| - |
|
275 |
response=''
|
| - |
|
276 |
while true; do
|
| - |
|
277 |
if [ "$Lang" == 'fr' ]
|
| - |
|
278 |
then echo -n "Choix de l'interface interne ? [$interfacePreferred] "
|
| - |
|
279 |
else echo -n "Choice of internal interface ? [$interfacePreferred] "
|
| - |
|
280 |
fi
|
| - |
|
281 |
read response
|
| - |
|
282 |
|
| - |
|
283 |
[ -z "$response" ] && response="$interfacePreferred"
|
| - |
|
284 |
|
| - |
|
285 |
# Check if interface exist
|
| - |
|
286 |
if [ $(echo "$interfacesList" | grep -c "^$response\$") -eq 1 ]; then
|
| - |
|
287 |
INTIF="$response"
|
| - |
|
288 |
break
|
| - |
|
289 |
else
|
| - |
|
290 |
if [ "$Lang" == 'fr' ]
|
| - |
|
291 |
then echo "Interface \"$response\" introuvable"
|
| - |
|
292 |
else echo "Interface \"$response\" not found"
|
| - |
|
293 |
fi
|
| - |
|
294 |
fi
|
| - |
|
295 |
done
|
| - |
|
296 |
fi
|
| - |
|
297 |
fi
|
| - |
|
298 |
if [ "$Lang" == 'fr' ]
|
| - |
|
299 |
then echo "Interface interne utilisée : $INTIF"
|
| - |
|
300 |
else echo "Internal interface used: $INTIF"
|
| - |
|
301 |
fi
|
| - |
|
302 |
|
| 243 |
if [ $Lang == "fr" ]
|
303 |
if [ $Lang == "fr" ]
|
| 244 |
then echo -n "Tests des paramètres réseau : "
|
304 |
then echo -n "Tests des paramètres réseau : "
|
| 245 |
else echo -n "Network parameters tests: "
|
305 |
else echo -n "Network parameters tests: "
|
| 246 |
fi
|
306 |
fi
|
| 247 |
# Remove conf file if NIC is not plugged (ie : GSM/WIFI/Bt dongles)
|
307 |
# Remove conf file if NIC is not plugged (ie : GSM/WIFI/Bt dongles)
|
| Line 259... |
Line 319... |
| 259 |
fi
|
319 |
fi
|
| 260 |
done
|
320 |
done
|
| 261 |
cd $DIR_INSTALL
|
321 |
cd $DIR_INSTALL
|
| 262 |
echo -n "."
|
322 |
echo -n "."
|
| 263 |
# Test Ethernet NIC links state
|
323 |
# Test Ethernet NIC links state
|
| 264 |
DOWN_IF=`/usr/sbin/ip link|grep "NO-CARRIER"|cut -d":" -f2|tr -d " "|grep -v "^w"`
|
324 |
interfacesDown=$(/usr/sbin/ip -br link | grep "^\($EXTIF\|$INTIF\) " | grep 'NO-CARRIER' | cut -d' ' -f1)
|
| 265 |
for i in $DOWN_IF
|
325 |
if [ ! -z "$interfacesDown" ]; then
|
| 266 |
do
|
- |
|
| 267 |
echo $i
|
326 |
for i in $interfacesDown; do
|
| 268 |
if [ $Lang == "fr" ]
|
327 |
if [ $Lang == "fr" ]
|
| 269 |
then
|
328 |
then
|
| 270 |
echo "Échec"
|
329 |
echo -e "\nÉchec"
|
| 271 |
echo "Le lien réseau de la carte $i n'est pas actif."
|
330 |
echo "Le lien réseau de la carte $i n'est pas actif."
|
| 272 |
echo "Assurez-vous que cette carte est bien connectée à un équipement (commutateur, A.P., etc.)"
|
331 |
echo "Assurez-vous que cette carte est bien connectée à un équipement (commutateur, A.P., etc.)"
|
| 273 |
else
|
332 |
else
|
| 274 |
echo "Failed"
|
333 |
echo -e "\nFailed"
|
| 275 |
echo "The link state of $i interface is down."
|
334 |
echo "The link state of $i interface is down."
|
| 276 |
echo "Make sure that this network card is connected to a switch or an A.P."
|
335 |
echo "Make sure that this network card is connected to a switch or an A.P."
|
| 277 |
fi
|
336 |
fi
|
| - |
|
337 |
done
|
| 278 |
exit 0
|
338 |
exit 1
|
| 279 |
done
|
339 |
fi
|
| 280 |
echo -n "."
|
340 |
echo -n "."
|
| 281 |
# Test EXTIF config files
|
341 |
# Test EXTIF config files
|
| 282 |
PUBLIC_IP_MASK=`ip addr show $EXTIF|grep "inet "|cut -d" " -f6`
|
342 |
PUBLIC_IP=`/usr/sbin/ip addr show $EXTIF | grep '^\s*inet\s' | awk '{ print $2 }' | cut -d'/' -f1`
|
| 283 |
PUBLIC_IP=`echo $PUBLIC_IP_MASK | cut -d"/" -f1`
|
- |
|
| 284 |
PUBLIC_GATEWAY=`ip route list|grep $EXTIF|grep ^default|cut -d" " -f3`
|
343 |
PUBLIC_GATEWAY=`/usr/sbin/ip route list | awk '/^default / {print $3}'`
|
| 285 |
if [ `echo $PUBLIC_IP|wc -c` -lt 7 ] || [ `echo $PUBLIC_GATEWAY|wc -c` -lt 7 ]
|
344 |
if [ `echo $PUBLIC_IP|wc -c` -lt 7 ] || [ `echo $PUBLIC_GATEWAY|wc -c` -lt 7 ]
|
| 286 |
then
|
345 |
then
|
| 287 |
if [ $Lang == "fr" ]
|
346 |
if [ $Lang == "fr" ]
|
| 288 |
then
|
347 |
then
|
| 289 |
echo "Échec"
|
348 |
echo -e "\nÉchec"
|
| 290 |
echo "La carte réseau connectée à Internet ($EXTIF) n'est pas correctement configurée."
|
349 |
echo "La carte réseau connectée à Internet ($EXTIF) n'est pas correctement configurée."
|
| 291 |
echo "Renseignez les champs suivants dans le fichier '/etc/sysconfig/network-scripts/ifcfg-$EXTIF' :"
|
350 |
echo "Renseignez les champs suivants dans le fichier '/etc/sysconfig/network-scripts/ifcfg-$EXTIF' :"
|
| 292 |
echo "Appliquez les changements : 'systemctl restart network'"
|
351 |
echo "Appliquez les changements : 'systemctl restart network'"
|
| 293 |
else
|
352 |
else
|
| 294 |
echo "Failed"
|
353 |
echo -e "\nFailed"
|
| 295 |
echo "The Internet connected network card ($EXTIF) isn't well configured."
|
354 |
echo "The Internet connected network card ($EXTIF) isn't well configured."
|
| 296 |
echo "The folowing parametres must be set in the file '/etc/sysconfig/network-scripts/ifcfg-$EXTIF' :"
|
355 |
echo "The folowing parametres must be set in the file '/etc/sysconfig/network-scripts/ifcfg-$EXTIF' :"
|
| 297 |
echo "Apply the new configuration 'systemctl restart network'"
|
356 |
echo "Apply the new configuration: 'systemctl restart network'"
|
| 298 |
fi
|
357 |
fi
|
| 299 |
echo "DEVICE=$EXTIF"
|
358 |
echo "DEVICE=$EXTIF"
|
| 300 |
echo "IPADDR="
|
359 |
echo "IPADDR="
|
| 301 |
echo "NETMASK="
|
360 |
echo "NETMASK="
|
| 302 |
echo "GATEWAY="
|
361 |
echo "GATEWAY="
|
| 303 |
echo "DNS1="
|
362 |
echo "DNS1="
|
| 304 |
echo "DNS2="
|
363 |
echo "DNS2="
|
| 305 |
echo "ONBOOT=yes"
|
364 |
echo "ONBOOT=yes"
|
| 306 |
exit 0
|
365 |
exit 1
|
| 307 |
fi
|
366 |
fi
|
| 308 |
echo -n "."
|
367 |
echo -n "."
|
| 309 |
# Test if default GW is set on EXTIF (router or ISP provider equipment)
|
368 |
# Test if default GW is set on EXTIF (router or ISP provider equipment)
|
| 310 |
if [ `ip route list|grep $EXTIF|grep -c ^default` -ne "1" ] ; then
|
369 |
if [ `/usr/sbin/ip route list|grep " $EXTIF "|grep -c '^default '` -ne 1 ] ; then
|
| 311 |
if [ $Lang == "fr" ]
|
370 |
if [ $Lang == "fr" ]
|
| 312 |
then
|
371 |
then
|
| 313 |
echo "Échec"
|
372 |
echo -e "\nÉchec"
|
| 314 |
echo "Vous n'avez pas configuré l'accès à Internet ou le câble réseau n'est pas sur la bonne carte."
|
373 |
echo "Vous n'avez pas configuré l'accès à Internet ou le câble réseau n'est pas sur la bonne carte."
|
| 315 |
echo "Réglez ce problème puis relancez ce script."
|
374 |
echo "Réglez ce problème puis relancez ce script."
|
| 316 |
else
|
375 |
else
|
| 317 |
echo "Failed"
|
376 |
echo -e "\nFailed"
|
| 318 |
echo "You haven't configured Internet access or Internet link is on the wrong Ethernet card"
|
377 |
echo "You haven't configured Internet access or Internet link is on the wrong Ethernet card"
|
| 319 |
echo "Resolv this problem, then restart this script."
|
378 |
echo "Resolv this problem, then restart this script."
|
| 320 |
fi
|
379 |
fi
|
| 321 |
exit 0
|
380 |
exit 1
|
| 322 |
fi
|
381 |
fi
|
| 323 |
echo -n "."
|
382 |
echo -n "."
|
| 324 |
# Test if default GW is alive
|
383 |
# Test if default GW is alive
|
| 325 |
arp_reply=`/usr/sbin/arping -b -I$EXTIF -c1 -w2 $PUBLIC_GATEWAY|grep response|cut -d" " -f2`
|
384 |
arp_reply=`/usr/sbin/arping -b -I$EXTIF -c1 -w2 $PUBLIC_GATEWAY|grep response|cut -d" " -f2`
|
| 326 |
if [ $(expr $arp_reply) -eq 0 ]
|
385 |
if [ $(expr $arp_reply) -eq 0 ]
|
| 327 |
then
|
386 |
then
|
| 328 |
if [ $Lang == "fr" ]
|
387 |
if [ $Lang == "fr" ]
|
| 329 |
then
|
388 |
then
|
| 330 |
echo "Échec"
|
389 |
echo -e "\nÉchec"
|
| 331 |
echo "Le routeur de sortie ou la Box Internet ($PUBLIC_GATEWAY) ne répond pas."
|
390 |
echo "Le routeur de sortie ou la Box Internet ($PUBLIC_GATEWAY) ne répond pas."
|
| 332 |
echo "Réglez ce problème puis relancez ce script."
|
391 |
echo "Réglez ce problème puis relancez ce script."
|
| 333 |
else
|
392 |
else
|
| 334 |
echo "Failed"
|
393 |
echo -e "\nFailed"
|
| 335 |
echo "The Internet gateway or the ISP equipment ($PUBLIC_GATEWAY) doesn't answered."
|
394 |
echo "The Internet gateway or the ISP equipment ($PUBLIC_GATEWAY) doesn't answered."
|
| 336 |
echo "Resolv this problem, then restart this script."
|
395 |
echo "Resolv this problem, then restart this script."
|
| 337 |
fi
|
396 |
fi
|
| 338 |
exit 0
|
397 |
exit 1
|
| 339 |
fi
|
398 |
fi
|
| 340 |
echo -n "."
|
399 |
echo -n "."
|
| 341 |
# Test Internet connectivity
|
400 |
# Test Internet connectivity
|
| 342 |
rm -rf /tmp/con_ok.html
|
401 |
domainTested='www.google.com'
|
| 343 |
/usr/bin/curl www.google.fr -s -o /tmp/con_ok.html
|
402 |
/usr/bin/curl -s --head "$domainTested" &>/dev/null
|
| 344 |
if [ ! -e /tmp/con_ok.html ]
|
403 |
if [ $? -ne 0 ]; then
|
| 345 |
then
|
- |
|
| 346 |
if [ $Lang == "fr" ]
|
404 |
if [ $Lang == "fr" ]
|
| 347 |
then
|
405 |
then
|
| 348 |
echo "La tentative de connexion vers Internet a échoué (google.fr)."
|
406 |
echo -e "\nLa tentative de connexion vers Internet a échoué ($domainTested)."
|
| 349 |
echo "Vérifiez que la carte $EXTIF est bien connectée au routeur du FAI."
|
407 |
echo "Vérifiez que la carte $EXTIF est bien connectée au routeur du FAI."
|
| 350 |
echo "Vérifiez la validité des adresses IP des DNS."
|
408 |
echo "Vérifiez la validité des adresses IP des DNS."
|
| 351 |
else
|
409 |
else
|
| 352 |
echo "The Internet connection try failed (google.fr)."
|
410 |
echo -e "\nThe Internet connection try failed ($domainTested)."
|
| 353 |
echo "Please, verify that the $EXTIF card is connected with the Internet gateway."
|
411 |
echo "Please, verify that the $EXTIF card is connected with the Internet gateway."
|
| 354 |
echo "Verify the DNS IP addresses"
|
412 |
echo "Verify the DNS IP addresses"
|
| 355 |
fi
|
413 |
fi
|
| 356 |
exit 0
|
414 |
exit 1
|
| 357 |
fi
|
415 |
fi
|
| 358 |
rm -rf /tmp/con_ok.html
|
- |
|
| 359 |
echo ". : ok"
|
416 |
echo ". : ok"
|
| 360 |
} # end of testing ()
|
417 |
} # end of testing ()
|
| 361 |
|
418 |
|
| 362 |
#######################################################################
|
419 |
#######################################################################
|
| 363 |
## Function "init" ##
|
420 |
## Function "init" ##
|