672 |
richard |
1 |
#!/bin/bash
|
57 |
franck |
2 |
# $Id: alcasar.sh 967 2012-08-02 20:37:45Z franck $
|
1 |
root |
3 |
|
|
|
4 |
# alcasar.sh
|
959 |
franck |
5 |
|
|
|
6 |
# ALCASAR - Portail captif d'accès à l'Internet - Copyright (C) [2005] [ALcasar team - Rexy - 3abtux - ...]
|
|
|
7 |
# Ce programme est un logiciel libre ; vous pouvez le redistribuer et/ou le modifier au titre des clauses de la Licence Publique Générale GNU,
|
|
|
8 |
# elle que publiée par la Free Software Foundation ; soit la version 3 de la Licence.
|
|
|
9 |
# Ce programme est distribué dans l'espoir qu'il sera utile, mais SANS AUCUNE GARANTIE ;
|
|
|
10 |
# sans même une garantie implicite de COMMERCIABILITE ou DE CONFORMITE A UNE UTILISATION PARTICULIERE.
|
|
|
11 |
# Voir la Licence Publique Générale GNU pour plus de détails.
|
|
|
12 |
# Vous devriez avoir reçu un exemplaire de la Licence Publique Générale GNU avec ce programme ;
|
|
|
13 |
# si ce nest pas le cas, consultez : <http://www.gnu.org/licenses/>.
|
|
|
14 |
|
967 |
franck |
15 |
# team@alcasar.net
|
959 |
franck |
16 |
|
1 |
root |
17 |
# by Franck BOUIJOUX, Pascal LEVANT and Richard REY
|
|
|
18 |
# This script is distributed under the Gnu General Public License (GPL)
|
|
|
19 |
|
672 |
richard |
20 |
# Script d'installation d'ALCASAR (Application Libre pour le Contrôle d'Accès Sécurisé et Authentifié au Réseau)
|
|
|
21 |
# ALCASAR est architecturé autour d'une distribution Linux Mandriva minimaliste et les logiciels libres suivants :
|
1 |
root |
22 |
# Install script for ALCASAR (a secured and authenticated Internet access control captive portal)
|
|
|
23 |
# ALCASAR is based on a stripped Mandriva (LSB) with the following open source softwares :
|
672 |
richard |
24 |
#
|
806 |
richard |
25 |
# Coovachilli (a fork of chillispot), freeradius, mysql, apache, netfilter, squid, dansguardian, awstat, ntpd, openssl, dnsmasq, havp, libclamav and firewalleyes
|
1 |
root |
26 |
|
|
|
27 |
# Options :
|
376 |
franck |
28 |
# -i or --install
|
|
|
29 |
# -u or --uninstall
|
1 |
root |
30 |
|
376 |
franck |
31 |
# Functions :
|
29 |
richard |
32 |
# testing : Tests de connectivité et de téléchargement avant installation
|
1 |
root |
33 |
# init : Installation des RPM et des scripts
|
|
|
34 |
# network : Paramètrage du réseau
|
|
|
35 |
# gestion : Installation de l'interface de gestion
|
|
|
36 |
# AC : Initialisation de l'autorité de certification. Création des certificats
|
|
|
37 |
# init_db : Création de la base 'radius' sur le serveur MySql
|
|
|
38 |
# param_radius : Configuration du serveur d'authentification FreeRadius
|
|
|
39 |
# param_web_radius: Configuration de l'interface de gestion de FreeRadius (dialupadmin)
|
|
|
40 |
# param_chilli : Configuration du daemon 'coova-chilli' et de la page d'authentification
|
|
|
41 |
# param_squid : Configuration du proxy squid en mode 'cache'
|
|
|
42 |
# param_dansguardian : Configuration de l'analyseur de contenu DansGuardian
|
479 |
richard |
43 |
# antivirus : Installation havp + libclamav
|
1 |
root |
44 |
# param_awstats : Configuration de l'interface des statistiques de consultation WEB
|
297 |
richard |
45 |
# dnsmasq : Configuration du serveur de noms et du serveur dhcp de secours
|
308 |
richard |
46 |
# BL : Configuration de la BlackList
|
1 |
root |
47 |
# cron : Mise en place des exports de logs (+ chiffrement)
|
532 |
richard |
48 |
# post_install : Finalisation environnement ( sécurité, bannières, rotation logs, ...)
|
1 |
root |
49 |
|
|
|
50 |
DATE=`date '+%d %B %Y - %Hh%M'`
|
|
|
51 |
DATE_SHORT=`date '+%d/%m/%Y'`
|
595 |
richard |
52 |
Lang=`echo $LANG|cut -c 1-2`
|
1 |
root |
53 |
# ******* Files parameters - paramètres fichiers *********
|
832 |
richard |
54 |
DIR_INSTALL=`pwd` # install directory
|
1 |
root |
55 |
DIR_CONF="$DIR_INSTALL/conf" # répertoire d'installation contenant les fichiers de configuration
|
|
|
56 |
DIR_SCRIPTS="$DIR_INSTALL/scripts" # répertoire d'installation contenant les scripts
|
806 |
richard |
57 |
DIR_SAVE="/var/Save" # répertoire de sauvegarde (system_backup, user_db_backup, logs)
|
316 |
richard |
58 |
DIR_WEB="/var/www/html" # répertoire racine APACHE
|
648 |
richard |
59 |
DIR_DG="/etc/dansguardian" # répertoire de config de DansGuardian
|
316 |
richard |
60 |
DIR_ACC="$DIR_WEB/acc" # répertoire du centre de gestion 'ALCASAR Control Center'
|
1 |
root |
61 |
DIR_DEST_BIN="/usr/local/bin" # répertoire des scripts
|
|
|
62 |
DIR_DEST_SBIN="/usr/local/sbin" # répertoire des scripts d'admin
|
|
|
63 |
DIR_DEST_ETC="/usr/local/etc" # répertoire des fichiers de conf
|
628 |
richard |
64 |
CONF_FILE="$DIR_DEST_ETC/alcasar.conf" # fichier de conf d'alcasar
|
|
|
65 |
PASSWD_FILE="/root/ALCASAR-passwords.txt" # fichier texte contenant les mots de passe et secrets partagés
|
1 |
root |
66 |
# ******* DBMS parameters - paramètres SGBD ********
|
|
|
67 |
DB_RADIUS="radius" # nom de la base de données utilisée par le serveur FreeRadius
|
|
|
68 |
DB_USER="radius" # nom de l'utilisateur de la base de données
|
|
|
69 |
# ******* Network parameters - paramètres réseau *******
|
503 |
richard |
70 |
HOSTNAME="alcasar" #
|
1 |
root |
71 |
DOMAIN="localdomain" # domaine local
|
|
|
72 |
EXTIF="eth0" # ETH0 est l'interface connectée à Internet (Box FAI)
|
|
|
73 |
INTIF="eth1" # ETH1 est l'interface connectée au réseau local de consultation
|
597 |
richard |
74 |
DEFAULT_PRIVATE_IP_MASK="192.168.182.1/24" # adresse d'ALCASAR (+masque) proposée par défaut sur le réseau de consultation
|
1 |
root |
75 |
# ****** Paths - chemin des commandes *******
|
|
|
76 |
SED="/bin/sed -i"
|
|
|
77 |
# ****************** End of global parameters *********************
|
|
|
78 |
|
959 |
franck |
79 |
license ()
|
|
|
80 |
{
|
|
|
81 |
if [ $Lang == "fr" ]
|
967 |
franck |
82 |
then cat $DIR_INSTALL/gpl-3.0.fr.txt | more
|
|
|
83 |
else cat $DIR_INSTALL/gpl-3.0.txt | more
|
959 |
franck |
84 |
fi
|
967 |
franck |
85 |
echo "Taper une touche pour continuer !"
|
959 |
franck |
86 |
read a
|
|
|
87 |
}
|
|
|
88 |
|
1 |
root |
89 |
header_install ()
|
|
|
90 |
{
|
|
|
91 |
clear
|
|
|
92 |
echo "-----------------------------------------------------------------------------"
|
460 |
richard |
93 |
echo " ALCASAR V$VERSION Installation"
|
1 |
root |
94 |
echo "Application Libre pour le Contrôle d'Accès Sécurisé et Authentifié au Réseau"
|
|
|
95 |
echo "-----------------------------------------------------------------------------"
|
|
|
96 |
} # End of header_install ()
|
|
|
97 |
|
|
|
98 |
##################################################################
|
29 |
richard |
99 |
## Fonction TESTING ##
|
|
|
100 |
## - Test de la connectivité Internet ##
|
|
|
101 |
##################################################################
|
|
|
102 |
testing ()
|
|
|
103 |
{
|
595 |
richard |
104 |
if [ $Lang == "fr" ]
|
784 |
richard |
105 |
then echo -n "Tests des paramètres réseau : "
|
595 |
richard |
106 |
else echo -n "Network parameters tests : "
|
|
|
107 |
fi
|
784 |
richard |
108 |
# We test eth0 config files
|
|
|
109 |
PUBLIC_IP=`grep IPADDR /etc/sysconfig/network-scripts/ifcfg-$EXTIF|cut -d"=" -f2`
|
|
|
110 |
PUBLIC_GATEWAY=`grep GATEWAY /etc/sysconfig/network-scripts/ifcfg-$EXTIF|cut -d"=" -f2`
|
|
|
111 |
if [ `echo $PUBLIC_IP|wc -c` -lt 7 ] || [ `echo $PUBLIC_GATEWAY|wc -c` -lt 7 ]
|
|
|
112 |
then
|
|
|
113 |
if [ $Lang == "fr" ]
|
|
|
114 |
then
|
|
|
115 |
echo "Échec"
|
|
|
116 |
echo "La carte réseau connectée à Internet ($EXTIF) n'est pas correctement configurée."
|
|
|
117 |
echo "Renseignez les champs suivants dans le fichier '/etc/sysconfig/network-scripts/ifcfg-$EXTIF' :"
|
830 |
richard |
118 |
echo "Appliquez les changements : 'service network restart'"
|
784 |
richard |
119 |
else
|
|
|
120 |
echo "Failed"
|
|
|
121 |
echo "The Internet connected network card ($EXTIF) isn't well configured."
|
|
|
122 |
echo "The folowing parametres must be set in the file '/etc/sysconfig/network-scripts/ifcfg-$EXTIF' :"
|
830 |
richard |
123 |
echo "Apply the new configuration 'service network restart'"
|
784 |
richard |
124 |
fi
|
830 |
richard |
125 |
echo "DEVICE=$EXTIF"
|
784 |
richard |
126 |
echo "IPADDR="
|
|
|
127 |
echo "NETMASK="
|
|
|
128 |
echo "GATEWAY="
|
|
|
129 |
echo "DNS1="
|
|
|
130 |
echo "DNS2="
|
830 |
richard |
131 |
echo "ONBOOT=yes"
|
784 |
richard |
132 |
exit 0
|
|
|
133 |
fi
|
|
|
134 |
echo -n "."
|
460 |
richard |
135 |
# We test the Ethernet links state
|
29 |
richard |
136 |
for i in $EXTIF $INTIF
|
|
|
137 |
do
|
294 |
richard |
138 |
/sbin/ip link set $i up
|
306 |
richard |
139 |
sleep 3
|
808 |
franck |
140 |
CMD=`/usr/sbin/ethtool $i |grep Link | awk '{print $NF}'`
|
|
|
141 |
CMD2=`/sbin/mii-tool $i | grep -i link | awk '{print $NF}'`
|
|
|
142 |
if [ $CMD != "yes" ] && [ $CMD2 != "ok" ]
|
29 |
richard |
143 |
then
|
595 |
richard |
144 |
if [ $Lang == "fr" ]
|
|
|
145 |
then
|
|
|
146 |
echo "Échec"
|
|
|
147 |
echo "Le lien réseau de la carte $i n'est pas actif."
|
|
|
148 |
echo "Réglez ce problème puis relancez ce script."
|
|
|
149 |
else
|
|
|
150 |
echo "Failed"
|
|
|
151 |
echo "The link state of $i interface id down."
|
|
|
152 |
echo "Resolv this problem, then restart this script."
|
|
|
153 |
fi
|
29 |
richard |
154 |
exit 0
|
|
|
155 |
fi
|
308 |
richard |
156 |
echo -n "."
|
29 |
richard |
157 |
done
|
|
|
158 |
# On teste la présence d'un routeur par défaut (Box FAI)
|
784 |
richard |
159 |
if [ `ip route list|grep -c ^default` -ne "1" ] ; then
|
595 |
richard |
160 |
if [ $Lang == "fr" ]
|
|
|
161 |
then
|
|
|
162 |
echo "Échec"
|
|
|
163 |
echo "Vous n'avez pas configuré l'accès à Internet ou le câble réseau n'est pas sur la bonne carte."
|
|
|
164 |
echo "Réglez ce problème puis relancez ce script."
|
|
|
165 |
else
|
|
|
166 |
echo "Failed"
|
|
|
167 |
echo "You haven't configured Internet access or Internet link is on the wrong Ethernet card"
|
|
|
168 |
echo "Resolv this problem, then restart this script."
|
|
|
169 |
fi
|
29 |
richard |
170 |
exit 0
|
|
|
171 |
fi
|
308 |
richard |
172 |
echo -n "."
|
|
|
173 |
# On traite le cas où l'interface configurée lors de l'installation est "eth1" au lieu de "eth0" (mystère sur certaines version de BIOS et de VirtualBox)
|
784 |
richard |
174 |
if [ `ip route list|grep ^default|grep -c eth1` -eq "1" ] ; then
|
595 |
richard |
175 |
if [ $Lang == "fr" ]
|
|
|
176 |
then echo "La configuration des cartes réseau va être corrigée."
|
|
|
177 |
else echo "The Ethernet card configuration will be corrected."
|
|
|
178 |
fi
|
29 |
richard |
179 |
/etc/init.d/network stop
|
|
|
180 |
mv -f /etc/sysconfig/network-scripts/ifcfg-eth1 /etc/sysconfig/network-scripts/ifcfg-eth0
|
|
|
181 |
$SED "s?eth1?eth0?g" /etc/sysconfig/network-scripts/ifcfg-eth0
|
|
|
182 |
/etc/init.d/network start
|
|
|
183 |
echo 0 > /proc/sys/net/ipv4/conf/all/log_martians
|
|
|
184 |
sleep 2
|
595 |
richard |
185 |
if [ $Lang == "fr" ]
|
|
|
186 |
then echo "Configuration corrigée"
|
|
|
187 |
else echo "Configuration updated"
|
|
|
188 |
fi
|
29 |
richard |
189 |
sleep 2
|
595 |
richard |
190 |
if [ $Lang == "fr" ]
|
|
|
191 |
then echo "Vous pouvez relancer ce script."
|
|
|
192 |
else echo "You can restart this script."
|
|
|
193 |
fi
|
29 |
richard |
194 |
exit 0
|
|
|
195 |
fi
|
308 |
richard |
196 |
echo -n "."
|
|
|
197 |
# On test le lien vers le routeur par default
|
|
|
198 |
IP_GW=`ip route list|grep ^default|cut -d" " -f3`
|
|
|
199 |
arp_reply=`/usr/sbin/arping -b -I$EXTIF -c1 -w2 $IP_GW|grep response|cut -d" " -f2`
|
527 |
richard |
200 |
if [ $(expr $arp_reply) -eq 0 ]
|
308 |
richard |
201 |
then
|
595 |
richard |
202 |
if [ $Lang == "fr" ]
|
|
|
203 |
then
|
|
|
204 |
echo "Échec"
|
|
|
205 |
echo "Le routeur de site ou la Box Internet ($IP_GW) ne répond pas."
|
|
|
206 |
echo "Réglez ce problème puis relancez ce script."
|
|
|
207 |
else
|
|
|
208 |
echo "Failed"
|
|
|
209 |
echo "The Internet gateway doesn't answered"
|
|
|
210 |
echo "Resolv this problem, then restart this script."
|
|
|
211 |
fi
|
308 |
richard |
212 |
exit 0
|
|
|
213 |
fi
|
|
|
214 |
echo -n "."
|
421 |
franck |
215 |
# On teste la connectivité Internet
|
29 |
richard |
216 |
rm -rf /tmp/con_ok.html
|
308 |
richard |
217 |
/usr/bin/curl www.google.fr -s -o /tmp/con_ok.html
|
29 |
richard |
218 |
if [ ! -e /tmp/con_ok.html ]
|
|
|
219 |
then
|
595 |
richard |
220 |
if [ $Lang == "fr" ]
|
|
|
221 |
then
|
|
|
222 |
echo "La tentative de connexion vers Internet a échoué (google.fr)."
|
|
|
223 |
echo "Vérifiez que la carte $EXTIF est bien connectée au routeur du FAI."
|
|
|
224 |
echo "Vérifiez la validité des adresses IP des DNS."
|
|
|
225 |
else
|
|
|
226 |
echo "The Internet connection try failed (google.fr)."
|
|
|
227 |
echo "Please, verify that the $EXTIF card is connected with the Internet gateway."
|
|
|
228 |
echo "Verify the DNS IP addresses"
|
|
|
229 |
fi
|
29 |
richard |
230 |
exit 0
|
|
|
231 |
fi
|
|
|
232 |
rm -rf /tmp/con_ok.html
|
308 |
richard |
233 |
echo ". : ok"
|
302 |
richard |
234 |
} # end of testing
|
|
|
235 |
|
|
|
236 |
##################################################################
|
|
|
237 |
## Fonction INIT ##
|
|
|
238 |
## - Création du fichier "/root/ALCASAR_parametres.txt" ##
|
|
|
239 |
## - Installation et modification des scripts du portail ##
|
|
|
240 |
##################################################################
|
|
|
241 |
init ()
|
|
|
242 |
{
|
527 |
richard |
243 |
if [ "$mode" != "update" ]
|
302 |
richard |
244 |
then
|
|
|
245 |
# On affecte le nom d'organisme
|
597 |
richard |
246 |
header_install
|
302 |
richard |
247 |
ORGANISME=!
|
|
|
248 |
PTN='^[a-zA-Z0-9-]*$'
|
580 |
richard |
249 |
until [[ $(expr $ORGANISME : $PTN) -gt 0 ]]
|
302 |
richard |
250 |
do
|
595 |
richard |
251 |
if [ $Lang == "fr" ]
|
597 |
richard |
252 |
then echo -n "Entrez le nom de votre organisme : "
|
|
|
253 |
else echo -n "Enter the name of your organism : "
|
595 |
richard |
254 |
fi
|
330 |
franck |
255 |
read ORGANISME
|
613 |
richard |
256 |
if [ "$ORGANISME" == "" ]
|
330 |
franck |
257 |
then
|
|
|
258 |
ORGANISME=!
|
|
|
259 |
fi
|
|
|
260 |
done
|
302 |
richard |
261 |
fi
|
1 |
root |
262 |
# On crée aléatoirement les mots de passe et les secrets partagés
|
628 |
richard |
263 |
rm -f $PASSWD_FILE
|
59 |
richard |
264 |
grubpwd=`cat /dev/urandom | tr -dc [:alnum:] | head -c8` # mot de passe de protection du menu Grub
|
628 |
richard |
265 |
echo -n "Password to protect the boot menu (GRUB) : " > $PASSWD_FILE
|
|
|
266 |
echo "$grubpwd" >> $PASSWD_FILE
|
59 |
richard |
267 |
md5_grubpwd=`/usr/bin/md5pass $grubpwd`
|
384 |
richard |
268 |
$SED "/^password.*/d" /boot/grub/menu.lst
|
|
|
269 |
$SED "1ipassword --md5 $md5_grubpwd" /boot/grub/menu.lst
|
1 |
root |
270 |
mysqlpwd=`cat /dev/urandom | tr -dc [:alnum:] | head -c8` # mot de passe de l'administrateur Mysqld
|
628 |
richard |
271 |
echo -n "Name and password of MYSQL administrator : " >> $PASSWD_FILE
|
|
|
272 |
echo "root / $mysqlpwd" >> $PASSWD_FILE
|
1 |
root |
273 |
radiuspwd=`cat /dev/urandom | tr -dc [:alnum:] | head -c8` # mot de passe de l'utilisateur Mysqld (utilisé par freeradius)
|
628 |
richard |
274 |
echo -n "Name and password of MYSQL user : " >> $PASSWD_FILE
|
|
|
275 |
echo "$DB_USER / $radiuspwd" >> $PASSWD_FILE
|
1 |
root |
276 |
secretuam=`cat /dev/urandom | tr -dc [:alnum:] | head -c8` # secret partagé entre intercept.php et coova-chilli
|
628 |
richard |
277 |
echo -n "Shared secret between the script 'intercept.php' and coova-chilli : " >> $PASSWD_FILE
|
|
|
278 |
echo "$secretuam" >> $PASSWD_FILE
|
1 |
root |
279 |
secretradius=`cat /dev/urandom | tr -dc [:alnum:] | head -c8` # secret partagé entre coova-chilli et FreeRadius
|
628 |
richard |
280 |
echo -n "Shared secret between coova-chilli and FreeRadius : " >> $PASSWD_FILE
|
|
|
281 |
echo "$secretradius" >> $PASSWD_FILE
|
|
|
282 |
chmod 640 $PASSWD_FILE
|
453 |
franck |
283 |
# On installe les scripts et fichiers de configuration d'ALCASAR
|
865 |
richard |
284 |
# - dans /usr/local/bin : alcasar-{CA.sh,conf.sh,import-clean.sh,iptables-bypass.sh,iptables.sh,log.sh,watchdog.sh}
|
5 |
franck |
285 |
cp -f $DIR_SCRIPTS/alcasar* $DIR_DEST_BIN/. ; chown root:root $DIR_DEST_BIN/alcasar* ; chmod 740 $DIR_DEST_BIN/alcasar*
|
453 |
franck |
286 |
# - dans /usr/local/sbin : alcasar-{bl.sh,bypass.sh,dateLog.sh,havp.sh,logout.sh,mysql.sh,nf.sh,profil.sh,uninstall.sh,version-list.sh,load-balancing.sh}
|
5 |
franck |
287 |
cp -f $DIR_SCRIPTS/sbin/alcasar* $DIR_DEST_SBIN/. ; chown root:root $DIR_DEST_SBIN/alcasar* ; chmod 740 $DIR_DEST_SBIN/alcasar*
|
453 |
franck |
288 |
# - des fichiers de conf dans /usr/local/etc : alcasar-{bl-categories-enabled,dns-name,ethers,iptables-local.sh,services}
|
648 |
richard |
289 |
cp -f $DIR_CONF/etc/alcasar* $DIR_DEST_ETC/. ; chown root:apache $DIR_DEST_ETC/alcasar* ; chmod 660 $DIR_DEST_ETC/alcasar*
|
1 |
root |
290 |
$SED "s?^radiussecret.*?radiussecret=\"$secretradius\"?g" $DIR_DEST_SBIN/alcasar-logout.sh
|
|
|
291 |
$SED "s?^DB_RADIUS=.*?DB_RADIUS=\"$DB_RADIUS\"?g" $DIR_DEST_SBIN/alcasar-mysql.sh
|
5 |
franck |
292 |
$SED "s?^DB_USER=.*?DB_USER=\"$DB_USER\"?g" $DIR_DEST_SBIN/alcasar-mysql.sh $DIR_DEST_BIN/alcasar-conf.sh
|
|
|
293 |
$SED "s?^radiuspwd=.*?radiuspwd=\"$radiuspwd\"?g" $DIR_DEST_SBIN/alcasar-mysql.sh $DIR_DEST_BIN/alcasar-conf.sh
|
628 |
richard |
294 |
# generate central conf file
|
|
|
295 |
cat <<EOF > $CONF_FILE
|
612 |
richard |
296 |
##########################################
|
|
|
297 |
## ##
|
|
|
298 |
## ALCASAR Parameters ##
|
|
|
299 |
## ##
|
|
|
300 |
##########################################
|
1 |
root |
301 |
|
612 |
richard |
302 |
INSTALL_DATE=$DATE
|
|
|
303 |
VERSION=$VERSION
|
|
|
304 |
ORGANISM=$ORGANISME
|
923 |
franck |
305 |
DOMAIN=$DOMAIN
|
612 |
richard |
306 |
EOF
|
628 |
richard |
307 |
chmod o-rwx $CONF_FILE
|
1 |
root |
308 |
} # End of init ()
|
|
|
309 |
|
|
|
310 |
##################################################################
|
|
|
311 |
## Fonction network ##
|
|
|
312 |
## - Définition du plan d'adressage du réseau de consultation ##
|
595 |
richard |
313 |
## - Nommage DNS du système ##
|
1 |
root |
314 |
## - Configuration de l'interface eth1 (réseau de consultation) ##
|
|
|
315 |
## - Modification du fichier /etc/hosts ##
|
|
|
316 |
## - Configuration du serveur de temps (NTP) ##
|
|
|
317 |
## - Renseignement des fichiers hosts.allow et hosts.deny ##
|
|
|
318 |
##################################################################
|
|
|
319 |
network ()
|
|
|
320 |
{
|
|
|
321 |
header_install
|
636 |
richard |
322 |
if [ "$mode" != "update" ]
|
|
|
323 |
then
|
|
|
324 |
if [ $Lang == "fr" ]
|
|
|
325 |
then echo "Par défaut, l'adresse IP d'ALCASAR sur le réseau de consultation est : $DEFAULT_PRIVATE_IP_MASK"
|
|
|
326 |
else echo "The default ALCASAR IP address on consultation network is : $DEFAULT_PRIVATE_IP_MASK"
|
|
|
327 |
fi
|
|
|
328 |
response=0
|
|
|
329 |
PTN='^[oOyYnN]$'
|
|
|
330 |
until [[ $(expr $response : $PTN) -gt 0 ]]
|
1 |
root |
331 |
do
|
595 |
richard |
332 |
if [ $Lang == "fr" ]
|
659 |
richard |
333 |
then echo -n "Voulez-vous utiliser cette adresse et ce plan d'adressage (recommandé) (O/n)? : "
|
618 |
richard |
334 |
else echo -n "Do you want to use this IP address and this IP addressing plan (recommanded) (Y/n)? : "
|
595 |
richard |
335 |
fi
|
1 |
root |
336 |
read response
|
|
|
337 |
done
|
636 |
richard |
338 |
if [ "$response" = "n" ] || [ "$response" = "N" ]
|
|
|
339 |
then
|
|
|
340 |
PRIVATE_IP_MASK="0"
|
|
|
341 |
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:]]$'
|
|
|
342 |
until [[ $(expr $PRIVATE_IP_MASK : $PTN) -gt 0 ]]
|
1 |
root |
343 |
do
|
595 |
richard |
344 |
if [ $Lang == "fr" ]
|
597 |
richard |
345 |
then echo -n "Entrez l'adresse IP d'ALCASAR au format CIDR (a.b.c.d/xx) : "
|
|
|
346 |
else echo -n "Enter ALCASAR IP address in CIDR format (a.b.c.d/xx) : "
|
595 |
richard |
347 |
fi
|
597 |
richard |
348 |
read PRIVATE_IP_MASK
|
1 |
root |
349 |
done
|
636 |
richard |
350 |
else
|
|
|
351 |
PRIVATE_IP_MASK=$DEFAULT_PRIVATE_IP_MASK
|
|
|
352 |
fi
|
595 |
richard |
353 |
else
|
637 |
richard |
354 |
PRIVATE_IP_MASK=`grep PRIVATE_IP conf/etc/alcasar.conf|cut -d"=" -f2`
|
|
|
355 |
rm -rf conf/etc/alcasar.conf
|
1 |
root |
356 |
fi
|
861 |
richard |
357 |
# Define LAN side global parameters
|
1 |
root |
358 |
hostname $HOSTNAME
|
837 |
richard |
359 |
PRIVATE_NETWORK=`/bin/ipcalc -n $PRIVATE_IP_MASK | cut -d"=" -f2` # private network address (ie.: 192.168.182.0)
|
|
|
360 |
PRIVATE_NETMASK=`/bin/ipcalc -m $PRIVATE_IP_MASK | cut -d"=" -f2` # private network mask (ie.: 255.255.255.0)
|
|
|
361 |
PRIVATE_IP=`echo $PRIVATE_IP_MASK | cut -d"/" -f1` # ALCASAR private ip address (consultation LAN side)
|
861 |
richard |
362 |
PRIVATE_PREFIX=`/bin/ipcalc -p $PRIVATE_IP_MASK |cut -d"=" -f2` # network prefix (ie. 24)
|
|
|
363 |
PRIVATE_NETWORK_MASK=$PRIVATE_NETWORK/$PRIVATE_PREFIX # ie.: 192.168.182.0/24
|
|
|
364 |
classe=$((PRIVATE_PREFIX/8)); classe_sup=`expr $classe + 1`; classe_sup_sup=`expr $classe + 2` # ie.: 2=classe B, 3=classe C
|
837 |
richard |
365 |
PRIVATE_NETWORK_SHORT=`echo $PRIVATE_NETWORK | cut -d"." -f1-$classe`. # compatibility with hosts.allow et hosts.deny (ie.: 192.168.182.)
|
|
|
366 |
PRIVATE_BROADCAST=`/bin/ipcalc -b $PRIVATE_NETWORK_MASK | cut -d"=" -f2` # private network broadcast (ie.: 192.168.182.255)
|
|
|
367 |
private_network_ending=`echo $PRIVATE_NETWORK | cut -d"." -f$classe_sup` # last octet of LAN address
|
|
|
368 |
private_broadcast_ending=`echo $PRIVATE_BROADCAST | cut -d"." -f$classe_sup` # last octet of LAN broadcast
|
|
|
369 |
PRIVATE_FIRST_IP=`echo $PRIVATE_NETWORK | cut -d"." -f1-3`"."`expr $private_network_ending + 1` # First network address (ex.: 192.168.182.1)
|
|
|
370 |
PRIVATE_LAST_IP=`echo $PRIVATE_BROADCAST | cut -d"." -f1-3`"."`expr $private_broadcast_ending - 1` # last network address (ex.: 192.168.182.254)
|
861 |
richard |
371 |
|
841 |
richard |
372 |
# Define Internet parameters
|
14 |
richard |
373 |
[ -e /etc/sysconfig/network-scripts/default-ifcfg-$EXTIF ] || cp /etc/sysconfig/network-scripts/ifcfg-$EXTIF /etc/sysconfig/network-scripts/default-ifcfg-$EXTIF
|
|
|
374 |
DNS1=`grep DNS1 /etc/sysconfig/network-scripts/default-ifcfg-$EXTIF|cut -d"=" -f2` # @ip 1er DNS
|
|
|
375 |
DNS2=`grep DNS2 /etc/sysconfig/network-scripts/default-ifcfg-$EXTIF|cut -d"=" -f2` # @ip 2ème DNS
|
70 |
franck |
376 |
DNS1=${DNS1:=208.67.220.220}
|
|
|
377 |
DNS2=${DNS2:=208.67.222.222}
|
597 |
richard |
378 |
PUBLIC_NETMASK=`grep NETMASK /etc/sysconfig/network-scripts/default-ifcfg-$EXTIF|cut -d"=" -f2`
|
784 |
richard |
379 |
DEFAULT_PUBLIC_NETMASK=`ipcalc -m 192.168.182.2 | cut -d"=" -f2`
|
|
|
380 |
PUBLIC_NETMASK=${PUBLIC_NETMASK:=$DEFAULT_PUBLIC_NETMASK}
|
|
|
381 |
PUBLIC_PREFIX=`/bin/ipcalc -p 192.168.182.2 $PUBLIC_NETMASK|cut -d"=" -f2`
|
861 |
richard |
382 |
|
765 |
stephane |
383 |
echo "PUBLIC_IP=$PUBLIC_IP/$PUBLIC_PREFIX" >> $CONF_FILE
|
|
|
384 |
echo "PUBLIC_MTU=1500" >> $CONF_FILE
|
628 |
richard |
385 |
echo "GW=$PUBLIC_GATEWAY" >> $CONF_FILE
|
|
|
386 |
echo "DNS1=$DNS1" >> $CONF_FILE
|
|
|
387 |
echo "DNS2=$DNS2" >> $CONF_FILE
|
|
|
388 |
echo "PRIVATE_IP=$PRIVATE_IP_MASK" >> $CONF_FILE
|
941 |
richard |
389 |
echo "DHCP=full" >> $CONF_FILE
|
914 |
franck |
390 |
echo "EXT_DHCP_IP=none" >> $CONF_FILE
|
|
|
391 |
echo "RELAY_DHCP_IP=none" >> $CONF_FILE
|
|
|
392 |
echo "RELAY_DHCP_PORT=none" >> $CONF_FILE
|
597 |
richard |
393 |
[ -e /etc/sysconfig/network.default ] || cp /etc/sysconfig/network /etc/sysconfig/network.default
|
841 |
richard |
394 |
# config network
|
1 |
root |
395 |
cat <<EOF > /etc/sysconfig/network
|
|
|
396 |
NETWORKING=yes
|
|
|
397 |
HOSTNAME="$HOSTNAME"
|
|
|
398 |
FORWARD_IPV4=true
|
|
|
399 |
EOF
|
841 |
richard |
400 |
# config /etc/hosts
|
1 |
root |
401 |
[ -e /etc/hosts.default ] || cp /etc/hosts /etc/hosts.default
|
|
|
402 |
cat <<EOF > /etc/hosts
|
503 |
richard |
403 |
127.0.0.1 localhost
|
914 |
franck |
404 |
$PRIVATE_IP $HOSTNAME $HOSTNAME.$DOMAIN
|
1 |
root |
405 |
EOF
|
841 |
richard |
406 |
# Config eth0 (Internet)
|
14 |
richard |
407 |
cat <<EOF > /etc/sysconfig/network-scripts/ifcfg-$EXTIF
|
|
|
408 |
DEVICE=$EXTIF
|
|
|
409 |
BOOTPROTO=static
|
597 |
richard |
410 |
IPADDR=$PUBLIC_IP
|
|
|
411 |
NETMASK=$PUBLIC_NETMASK
|
|
|
412 |
GATEWAY=$PUBLIC_GATEWAY
|
14 |
richard |
413 |
DNS1=127.0.0.1
|
|
|
414 |
ONBOOT=yes
|
|
|
415 |
METRIC=10
|
|
|
416 |
NOZEROCONF=yes
|
|
|
417 |
MII_NOT_SUPPORTED=yes
|
|
|
418 |
IPV6INIT=no
|
|
|
419 |
IPV6TO4INIT=no
|
|
|
420 |
ACCOUNTING=no
|
|
|
421 |
USERCTL=no
|
|
|
422 |
EOF
|
841 |
richard |
423 |
# Config eth1 (consultation LAN) in normal mode
|
|
|
424 |
cat <<EOF > /etc/sysconfig/network-scripts/ifcfg-$INTIF
|
|
|
425 |
DEVICE=$INTIF
|
|
|
426 |
BOOTPROTO=static
|
|
|
427 |
ONBOOT=yes
|
|
|
428 |
NOZEROCONF=yes
|
|
|
429 |
MII_NOT_SUPPORTED=yes
|
|
|
430 |
IPV6INIT=no
|
|
|
431 |
IPV6TO4INIT=no
|
|
|
432 |
ACCOUNTING=no
|
|
|
433 |
USERCTL=no
|
|
|
434 |
EOF
|
|
|
435 |
# Config of eth1 in bypass mode (see "alcasar-bypass.sh")
|
793 |
richard |
436 |
cat <<EOF > /etc/sysconfig/network-scripts/default-ifcfg-$INTIF
|
1 |
root |
437 |
DEVICE=$INTIF
|
|
|
438 |
BOOTPROTO=static
|
|
|
439 |
IPADDR=$PRIVATE_IP
|
604 |
richard |
440 |
NETMASK=$PRIVATE_NETMASK
|
1 |
root |
441 |
ONBOOT=yes
|
|
|
442 |
METRIC=10
|
|
|
443 |
NOZEROCONF=yes
|
|
|
444 |
MII_NOT_SUPPORTED=yes
|
14 |
richard |
445 |
IPV6INIT=no
|
|
|
446 |
IPV6TO4INIT=no
|
|
|
447 |
ACCOUNTING=no
|
|
|
448 |
USERCTL=no
|
1 |
root |
449 |
EOF
|
440 |
franck |
450 |
# Mise à l'heure du serveur
|
|
|
451 |
[ -e /etc/ntp/step-tickers.default ] || cp /etc/ntp/step-tickers /etc/ntp/step-tickers.default
|
|
|
452 |
cat <<EOF > /etc/ntp/step-tickers
|
455 |
franck |
453 |
0.fr.pool.ntp.org # adapt to your country
|
|
|
454 |
1.fr.pool.ntp.org
|
|
|
455 |
2.fr.pool.ntp.org
|
440 |
franck |
456 |
EOF
|
|
|
457 |
# Configuration du serveur de temps (sur lui même)
|
1 |
root |
458 |
[ -e /etc/ntp.conf.default ] || cp /etc/ntp.conf /etc/ntp.conf.default
|
|
|
459 |
cat <<EOF > /etc/ntp.conf
|
456 |
franck |
460 |
server 0.fr.pool.ntp.org # adapt to your country
|
447 |
franck |
461 |
server 1.fr.pool.ntp.org
|
|
|
462 |
server 2.fr.pool.ntp.org
|
|
|
463 |
server 127.127.1.0 # local clock si NTP internet indisponible ...
|
411 |
richard |
464 |
fudge 127.127.1.0 stratum 10
|
604 |
richard |
465 |
restrict $PRIVATE_NETWORK mask $PRIVATE_NETMASK nomodify notrap
|
1 |
root |
466 |
restrict 127.0.0.1
|
310 |
richard |
467 |
driftfile /var/lib/ntp/drift
|
1 |
root |
468 |
logfile /var/log/ntp.log
|
|
|
469 |
EOF
|
440 |
franck |
470 |
|
310 |
richard |
471 |
chown -R ntp:ntp /var/lib/ntp
|
1 |
root |
472 |
# Renseignement des fichiers hosts.allow et hosts.deny
|
|
|
473 |
[ -e /etc/hosts.allow.default ] || cp /etc/hosts.allow /etc/hosts.allow.default
|
|
|
474 |
cat <<EOF > /etc/hosts.allow
|
|
|
475 |
ALL: LOCAL, 127.0.0.1, localhost, $PRIVATE_IP
|
604 |
richard |
476 |
sshd: ALL
|
1 |
root |
477 |
ntpd: $PRIVATE_NETWORK_SHORT
|
|
|
478 |
EOF
|
|
|
479 |
[ -e /etc/host.deny.default ] || cp /etc/hosts.deny /etc/hosts.deny.default
|
|
|
480 |
cat <<EOF > /etc/hosts.deny
|
|
|
481 |
ALL: ALL: spawn ( /bin/echo "service %d demandé par %c" | /bin/mail -s "Tentative d'accès au service %d par %c REFUSE !!!" security ) &
|
|
|
482 |
EOF
|
604 |
richard |
483 |
# Firewall config
|
790 |
richard |
484 |
$SED "s?^EXTIF=.*?EXTIF=\"$EXTIF\"?g" $DIR_DEST_BIN/alcasar-iptables.sh $DIR_DEST_BIN/alcasar-iptables-bypass.sh
|
|
|
485 |
$SED "s?^INTIF=.*?INTIF=\"$INTIF\"?g" $DIR_DEST_BIN/alcasar-iptables.sh $DIR_DEST_BIN/alcasar-iptables-bypass.sh
|
|
|
486 |
chmod o+r $DIR_DEST_BIN/alcasar-iptables.sh #lecture possible pour apache (interface php du filtrage réseau)
|
860 |
richard |
487 |
# create the filter exception file and ip_bloqued file
|
790 |
richard |
488 |
touch $DIR_DEST_ETC/alcasar-filter-exceptions
|
860 |
richard |
489 |
# create the ip_blocked file with a first line (LAN between ALCASAR and the Internet GW)
|
|
|
490 |
echo "#$PUBLIC_IP/$PUBLIC_PREFIX LAN-ALCASAR-BOX" > $DIR_DEST_ETC/alcasar-ip-blocked
|
790 |
richard |
491 |
# load conntrack ftp module
|
|
|
492 |
[ -e /etc/modprobe.preload.default ] || cp /etc/modprobe.preload /etc/modprobe.preload.default
|
|
|
493 |
echo "ip_conntrack_ftp" >> /etc/modprobe.preload
|
860 |
richard |
494 |
# the script "$DIR_DEST_BIN/alcasar-iptables.sh" is launched at the end in order to allow update via ssh
|
1 |
root |
495 |
} # End of network ()
|
|
|
496 |
|
|
|
497 |
##################################################################
|
|
|
498 |
## Fonction gestion ##
|
|
|
499 |
## - installation du centre de gestion ##
|
|
|
500 |
## - configuration du serveur web (Apache) ##
|
|
|
501 |
## - définition du 1er comptes de gestion ##
|
|
|
502 |
## - sécurisation des accès ##
|
|
|
503 |
##################################################################
|
|
|
504 |
gestion()
|
|
|
505 |
{
|
|
|
506 |
[ -d $DIR_WEB ] && rm -rf $DIR_WEB
|
|
|
507 |
mkdir $DIR_WEB
|
|
|
508 |
# Copie et configuration des fichiers du centre de gestion
|
316 |
richard |
509 |
cp -rf $DIR_INSTALL/web/* $DIR_WEB/
|
1 |
root |
510 |
echo "$VERSION du $DATE" > $DIR_WEB/VERSION
|
316 |
richard |
511 |
$SED "s?99/99/9999?$DATE_SHORT?g" $DIR_ACC/menu.php
|
|
|
512 |
$SED "s?\$DB_RADIUS = .*?\$DB_RADIUS = \"$DB_RADIUS\"\;?g" $DIR_ACC/phpsysinfo/includes/xml/portail.php
|
|
|
513 |
$SED "s?\$DB_USER = .*?\$DB_USER = \"$DB_USER\"\;?g" $DIR_ACC/phpsysinfo/includes/xml/portail.php
|
|
|
514 |
$SED "s?\$radiuspwd = .*?\$radiuspwd = \"$radiuspwd\"\;?g" $DIR_ACC/phpsysinfo/includes/xml/portail.php
|
498 |
richard |
515 |
$SED "s?\$hostname =.*?\$hostname = \"$HOSTNAME\";?g" $DIR_WEB/index.php
|
316 |
richard |
516 |
chmod 640 $DIR_ACC/phpsysinfo/includes/xml/portail.php
|
5 |
franck |
517 |
chown -R apache:apache $DIR_WEB/*
|
840 |
richard |
518 |
for i in system_backup base logs/firewall logs/httpd logs/squid logs/security;
|
1 |
root |
519 |
do
|
|
|
520 |
[ -d $DIR_SAVE/$i ] || mkdir -p $DIR_SAVE/$i
|
|
|
521 |
done
|
5 |
franck |
522 |
chown -R root:apache $DIR_SAVE
|
71 |
richard |
523 |
# Configuration et sécurisation php
|
|
|
524 |
[ -e /etc/php.ini.default ] || cp /etc/php.ini /etc/php.ini.default
|
534 |
richard |
525 |
timezone=`cat /etc/sysconfig/clock|grep ZONE|cut -d"=" -f2`
|
|
|
526 |
$SED "s?^;date.timezone =.*?date.timezone = $timezone?g" /etc/php.ini
|
411 |
richard |
527 |
$SED "s?^upload_max_filesize.*?upload_max_filesize = 100M?g" /etc/php.ini
|
|
|
528 |
$SED "s?^post_max_size.*?post_max_size = 100M?g" /etc/php.ini
|
71 |
richard |
529 |
$SED "s?^html_errors.*?html_errors = Off?g" /etc/php.ini
|
|
|
530 |
$SED "s?^expose_php.*?expose_php = Off?g" /etc/php.ini
|
|
|
531 |
# Configuration et sécurisation Apache
|
790 |
richard |
532 |
rm -rf /var/www/cgi-bin/* /var/www/perl/* /var/www/icons/README* /var/www/error/README*
|
1 |
root |
533 |
[ -e /etc/httpd/conf/httpd.conf.default ] || cp /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.conf.default
|
580 |
richard |
534 |
$SED "s?^#ServerName.*?ServerName $HOSTNAME?g" /etc/httpd/conf/httpd.conf
|
303 |
richard |
535 |
$SED "s?^Listen.*?Listen $PRIVATE_IP:80?g" /etc/httpd/conf/httpd.conf
|
1 |
root |
536 |
$SED "s?^ServerTokens.*?ServerTokens Prod?g" /etc/httpd/conf/httpd.conf
|
|
|
537 |
$SED "s?^ServerSignature.*?ServerSignature Off?g" /etc/httpd/conf/httpd.conf
|
|
|
538 |
$SED "s?^#ErrorDocument 404 /missing.html.*?ErrorDocument 404 /index.html?g" /etc/httpd/conf/httpd.conf
|
790 |
richard |
539 |
$SED "s?^LoadModule authn_anon_module.*?#LoadModule authn_anon_module modules/mod_authn_anon.so?g" /etc/httpd/conf/httpd.conf
|
|
|
540 |
$SED "s?^LoadModule status_module.*?#LoadModule status_module modules/mod_status.so?g" /etc/httpd/conf/httpd.conf
|
|
|
541 |
$SED "s?^LoadModule autoindex_module.*?#LoadModule autoindex_module modules/mod_autoindex.so?g" /etc/httpd/conf/httpd.conf
|
|
|
542 |
$SED "s?^LoadModule info_module.*?#LoadModule info_module modules/mod_info.so?g" /etc/httpd/conf/httpd.conf
|
|
|
543 |
$SED "s?^LoadModule imagemap_module.*?#LoadModule imagemap_module modules/mod_imagemap.so?g" /etc/httpd/conf/httpd.conf
|
|
|
544 |
$SED "s?^LoadModule rewrite_module.*?#LoadModule rewrite_module modules/mod_rewrite.so?g" /etc/httpd/conf/httpd.conf
|
1 |
root |
545 |
FIC_MOD_SSL=`find /etc/httpd/modules.d/ -type f -name *mod_ssl.conf`
|
|
|
546 |
$SED "s?^Listen.*?Listen $PRIVATE_IP:443?g" $FIC_MOD_SSL # On écoute en SSL que sur INTIF
|
|
|
547 |
$SED "s?background-color.*?background-color: #EFEFEF; }?g" /var/www/error/include/top.html
|
|
|
548 |
[ -e /var/www/error/include/bottom.html.default ] || mv /var/www/error/include/bottom.html /var/www/error/include/bottom.html.default
|
|
|
549 |
cat <<EOF > /var/www/error/include/bottom.html
|
|
|
550 |
</body>
|
|
|
551 |
</html>
|
|
|
552 |
EOF
|
|
|
553 |
# Définition du premier compte lié au profil 'admin'
|
509 |
richard |
554 |
header_install
|
510 |
richard |
555 |
if [ "$mode" = "install" ]
|
|
|
556 |
then
|
613 |
richard |
557 |
admin_portal=!
|
|
|
558 |
PTN='^[a-zA-Z0-9-]*$'
|
|
|
559 |
until [[ $(expr $admin_portal : $PTN) -gt 0 ]]
|
|
|
560 |
do
|
|
|
561 |
header_install
|
|
|
562 |
if [ $Lang == "fr" ]
|
|
|
563 |
then
|
|
|
564 |
echo ""
|
|
|
565 |
echo "Définissez un premier compte d'administration du portail :"
|
|
|
566 |
echo
|
|
|
567 |
echo -n "Nom : "
|
|
|
568 |
else
|
|
|
569 |
echo ""
|
|
|
570 |
echo "Define the first account allow to administrate the portal :"
|
|
|
571 |
echo
|
|
|
572 |
echo -n "Account : "
|
|
|
573 |
fi
|
|
|
574 |
read admin_portal
|
|
|
575 |
if [ "$admin_portal" == "" ]
|
|
|
576 |
then
|
|
|
577 |
admin_portal=!
|
|
|
578 |
fi
|
|
|
579 |
done
|
1 |
root |
580 |
# Création du fichier de clés de ce compte dans le profil "admin"
|
510 |
richard |
581 |
[ -d $DIR_DEST_ETC/digest ] && rm -rf $DIR_DEST_ETC/digest
|
|
|
582 |
mkdir -p $DIR_DEST_ETC/digest
|
|
|
583 |
chmod 755 $DIR_DEST_ETC/digest
|
|
|
584 |
until [ -s $DIR_DEST_ETC/digest/key_admin ]
|
|
|
585 |
do
|
613 |
richard |
586 |
/usr/sbin/htdigest -c $DIR_DEST_ETC/digest/key_admin $HOSTNAME $admin_portal
|
510 |
richard |
587 |
done
|
|
|
588 |
$DIR_DEST_SBIN/alcasar-profil.sh --list
|
595 |
richard |
589 |
else # mise à jour des versions < 2.1
|
510 |
richard |
590 |
if ([ $MAJ_RUNNING_VERSION -lt 2 ] || ([ $MAJ_RUNNING_VERSION -eq 2 ] && [ $MIN_RUNNING_VERSION -lt 1 ]))
|
|
|
591 |
then
|
613 |
richard |
592 |
if [ $Lang == "fr" ]
|
|
|
593 |
then
|
|
|
594 |
echo "Cette mise à jour nécessite de redéfinir le premier compte d'administration du portail"
|
|
|
595 |
echo
|
|
|
596 |
echo -n "Nom : "
|
|
|
597 |
else
|
|
|
598 |
echo "This update need to redefine the first admin account"
|
|
|
599 |
echo
|
|
|
600 |
echo -n "Account : "
|
|
|
601 |
fi
|
|
|
602 |
read admin_portal
|
510 |
richard |
603 |
[ -d $DIR_DEST_ETC/digest ] && rm -rf $DIR_DEST_ETC/digest
|
|
|
604 |
mkdir -p $DIR_DEST_ETC/digest
|
|
|
605 |
chmod 755 $DIR_DEST_ETC/digest
|
|
|
606 |
until [ -s $DIR_DEST_ETC/digest/key_admin ]
|
|
|
607 |
do
|
613 |
richard |
608 |
/usr/sbin/htdigest -c $DIR_DEST_ETC/digest/key_admin $HOSTNAME $admin_portal
|
510 |
richard |
609 |
done
|
|
|
610 |
$DIR_DEST_SBIN/alcasar-profil.sh --list
|
|
|
611 |
fi
|
|
|
612 |
fi
|
434 |
richard |
613 |
# synchronisation horaire
|
|
|
614 |
ntpd -q -g &
|
1 |
root |
615 |
# Sécurisation du centre
|
|
|
616 |
rm -f /etc/httpd/conf/webapps.d/*
|
|
|
617 |
cat <<EOF > /etc/httpd/conf/webapps.d/alcasar.conf
|
316 |
richard |
618 |
<Directory $DIR_ACC>
|
1 |
root |
619 |
SSLRequireSSL
|
|
|
620 |
AllowOverride None
|
|
|
621 |
Order deny,allow
|
|
|
622 |
Deny from all
|
|
|
623 |
Allow from 127.0.0.1
|
|
|
624 |
Allow from $PRIVATE_NETWORK_MASK
|
|
|
625 |
require valid-user
|
|
|
626 |
AuthType digest
|
|
|
627 |
AuthName $HOSTNAME
|
|
|
628 |
BrowserMatch "MSIE" AuthDigestEnableQueryStringHack=On
|
434 |
richard |
629 |
AuthUserFile $DIR_DEST_ETC/digest/key_all
|
580 |
richard |
630 |
ErrorDocument 404 https://$HOSTNAME/
|
1 |
root |
631 |
</Directory>
|
316 |
richard |
632 |
<Directory $DIR_ACC/admin>
|
1 |
root |
633 |
SSLRequireSSL
|
|
|
634 |
AllowOverride None
|
|
|
635 |
Order deny,allow
|
|
|
636 |
Deny from all
|
|
|
637 |
Allow from 127.0.0.1
|
|
|
638 |
Allow from $PRIVATE_NETWORK_MASK
|
|
|
639 |
require valid-user
|
|
|
640 |
AuthType digest
|
|
|
641 |
AuthName $HOSTNAME
|
|
|
642 |
BrowserMatch "MSIE" AuthDigestEnableQueryStringHack=On
|
434 |
richard |
643 |
AuthUserFile $DIR_DEST_ETC/digest/key_admin
|
580 |
richard |
644 |
ErrorDocument 404 https://$HOSTNAME/
|
1 |
root |
645 |
</Directory>
|
344 |
richard |
646 |
<Directory $DIR_ACC/manager>
|
1 |
root |
647 |
SSLRequireSSL
|
|
|
648 |
AllowOverride None
|
|
|
649 |
Order deny,allow
|
|
|
650 |
Deny from all
|
|
|
651 |
Allow from 127.0.0.1
|
|
|
652 |
Allow from $PRIVATE_NETWORK_MASK
|
|
|
653 |
require valid-user
|
|
|
654 |
AuthType digest
|
|
|
655 |
AuthName $HOSTNAME
|
|
|
656 |
BrowserMatch "MSIE" AuthDigestEnableQueryStringHack=On
|
434 |
richard |
657 |
AuthUserFile $DIR_DEST_ETC/digest/key_manager
|
580 |
richard |
658 |
ErrorDocument 404 https://$HOSTNAME/
|
1 |
root |
659 |
</Directory>
|
316 |
richard |
660 |
<Directory $DIR_ACC/backup>
|
|
|
661 |
SSLRequireSSL
|
|
|
662 |
AllowOverride None
|
|
|
663 |
Order deny,allow
|
|
|
664 |
Deny from all
|
|
|
665 |
Allow from 127.0.0.1
|
|
|
666 |
Allow from $PRIVATE_NETWORK_MASK
|
|
|
667 |
require valid-user
|
|
|
668 |
AuthType digest
|
|
|
669 |
AuthName $HOSTNAME
|
|
|
670 |
BrowserMatch "MSIE" AuthDigestEnableQueryStringHack=On
|
434 |
richard |
671 |
AuthUserFile $DIR_DEST_ETC/digest/key_backup
|
580 |
richard |
672 |
ErrorDocument 404 https://$HOSTNAME/
|
316 |
richard |
673 |
</Directory>
|
811 |
richard |
674 |
Alias /save/ "$DIR_SAVE/"
|
|
|
675 |
<Directory $DIR_SAVE>
|
|
|
676 |
SSLRequireSSL
|
|
|
677 |
Options Indexes
|
|
|
678 |
Order deny,allow
|
|
|
679 |
Deny from all
|
|
|
680 |
Allow from 127.0.0.1
|
|
|
681 |
Allow from $PRIVATE_NETWORK_MASK
|
|
|
682 |
require valid-user
|
|
|
683 |
AuthType digest
|
|
|
684 |
AuthName $HOSTNAME
|
|
|
685 |
AuthUserFile $DIR_DEST_ETC/digest/key_backup
|
|
|
686 |
ErrorDocument 404 https://$HOSTNAME/
|
|
|
687 |
</Directory>
|
1 |
root |
688 |
EOF
|
|
|
689 |
} # End of gestion ()
|
|
|
690 |
|
|
|
691 |
##########################################################################################
|
|
|
692 |
## Fonction AC() ##
|
|
|
693 |
## - Création d'une Autorité de Certification et du certificat serveur pour apache ##
|
|
|
694 |
##########################################################################################
|
|
|
695 |
AC ()
|
|
|
696 |
{
|
|
|
697 |
$SED "s?ifcfg-eth.?ifcfg-$INTIF?g" $DIR_DEST_BIN/alcasar-CA.sh
|
510 |
richard |
698 |
$DIR_DEST_BIN/alcasar-CA.sh
|
800 |
richard |
699 |
FIC_VIRTUAL_SSL=`find /etc/httpd/conf -type f -name *default_ssl_vhost.conf`
|
303 |
richard |
700 |
[ -e /etc/httpd/conf/vhosts-ssl.default ] || cp $FIC_VIRTUAL_SSL /etc/httpd/conf/vhosts-ssl.default
|
|
|
701 |
$SED "s?localhost.crt?alcasar.crt?g" $FIC_VIRTUAL_SSL
|
|
|
702 |
$SED "s?localhost.key?alcasar.key?g" $FIC_VIRTUAL_SSL
|
679 |
richard |
703 |
$SED "s?^#SSLCertificateChainFile.*?SSLCertificateChainFile /etc/pki/tls/certs/server-chain.crt?" $FIC_VIRTUAL_SSL
|
5 |
franck |
704 |
chown -R root:apache /etc/pki
|
1 |
root |
705 |
chmod -R 750 /etc/pki
|
|
|
706 |
} # End AC ()
|
|
|
707 |
|
|
|
708 |
##########################################################################################
|
|
|
709 |
## Fonction init_db() ##
|
|
|
710 |
## - Initialisation de la base Mysql ##
|
|
|
711 |
## - Affectation du mot de passe de l'administrateur (root) ##
|
|
|
712 |
## - Suppression des bases et des utilisateurs superflus ##
|
|
|
713 |
## - Création de la base 'radius' ##
|
|
|
714 |
## - Installation du schéma de cette base ##
|
|
|
715 |
## - Import des tables de comptabilité (mtotacct, totacct) et info_usagers (userinfo) ##
|
|
|
716 |
## ces table proviennent de 'dialupadmin' (paquetage freeradius-web) ##
|
|
|
717 |
##########################################################################################
|
|
|
718 |
init_db ()
|
|
|
719 |
{
|
|
|
720 |
mkdir -p /var/lib/mysql/.tmp
|
|
|
721 |
chown mysql:mysql /var/lib/mysql/.tmp
|
227 |
franck |
722 |
[ -e /etc/my.cnf.rpmnew ] && mv /etc/my.cnf.rpmnew /etc/my.cnf # prend en compte les migrations de MySQL
|
1 |
root |
723 |
[ -e /etc/my.cnf.default ] || cp /etc/my.cnf /etc/my.cnf.default
|
|
|
724 |
$SED "s?^#bind-address.*?bind-address=127.0.0.1?g" /etc/my.cnf
|
|
|
725 |
/etc/init.d/mysqld start
|
|
|
726 |
sleep 4
|
|
|
727 |
mysqladmin -u root password $mysqlpwd
|
|
|
728 |
MYSQL="/usr/bin/mysql -uroot -p$mysqlpwd --exec"
|
615 |
richard |
729 |
# Delete exemple databases if exist
|
1 |
root |
730 |
$MYSQL="DROP DATABASE IF EXISTS test;DROP DATABASE IF EXISTS tmp;CONNECT mysql;DELETE from user where user='';FLUSH PRIVILEGES;"
|
615 |
richard |
731 |
# Create 'radius' database
|
1 |
root |
732 |
$MYSQL="CREATE DATABASE IF NOT EXISTS $DB_RADIUS;GRANT ALL ON $DB_RADIUS.* TO $DB_USER@localhost IDENTIFIED BY '$radiuspwd';FLUSH PRIVILEGES"
|
615 |
richard |
733 |
# Add an empty radius database structure
|
364 |
franck |
734 |
mysql -u$DB_USER -p$radiuspwd $DB_RADIUS < $DIR_CONF/radiusd-db-vierge.sql
|
615 |
richard |
735 |
# modify the start script in order to close accounting connexion when the system is comming down or up
|
|
|
736 |
[ -e /etc/init.d/mysqld.default ] || cp /etc/init.d/mysqld /etc/init.d/mysqld.default
|
|
|
737 |
$SED "/wait_for_pid created/a echo \"Flush ALCASAR open accounting sessions\"; /usr/local/sbin/alcasar-mysql.sh -acct_stop" /etc/init.d/mysqld
|
|
|
738 |
$SED "/'stop')/a echo \"Flush ALCASAR open accounting sessions\"; /usr/local/sbin/alcasar-mysql.sh -acct_stop" /etc/init.d/mysqld
|
1 |
root |
739 |
} # End init_db ()
|
|
|
740 |
|
|
|
741 |
##########################################################################
|
|
|
742 |
## Fonction param_radius ##
|
|
|
743 |
## - Paramètrage des fichiers de configuration FreeRadius ##
|
|
|
744 |
## - Affectation du secret partagé entre coova-chilli et freeradius ##
|
|
|
745 |
## - Modification de fichier de conf pour l'accès à Mysql ##
|
|
|
746 |
##########################################################################
|
|
|
747 |
param_radius ()
|
|
|
748 |
{
|
|
|
749 |
cp -f $DIR_CONF/radiusd-db-vierge.sql /etc/raddb/
|
|
|
750 |
chown -R radius:radius /etc/raddb
|
|
|
751 |
[ -e /etc/raddb/radiusd.conf.default ] || cp /etc/raddb/radiusd.conf /etc/raddb/radiusd.conf.default
|
|
|
752 |
# paramètrage radius.conf
|
|
|
753 |
$SED "s?^[\t ]*#[\t ]*user =.*?user = radius?g" /etc/raddb/radiusd.conf
|
|
|
754 |
$SED "s?^[\t ]*#[\t ]*group =.*?group = radius?g" /etc/raddb/radiusd.conf
|
|
|
755 |
$SED "s?^[\t ]*status_server =.*?status_server = no?g" /etc/raddb/radiusd.conf
|
|
|
756 |
# suppression de la fonction proxy
|
|
|
757 |
$SED "s?^[\t ]*proxy_requests.*?proxy_requests = no?g" /etc/raddb/radiusd.conf
|
|
|
758 |
$SED "s?^[\t ]*\$INCLUDE proxy.conf.*?#\$INCLUDE proxy.conf?g" /etc/raddb/radiusd.conf
|
654 |
richard |
759 |
# suppression du module EAP
|
|
|
760 |
$SED "s?^[\t ]*\$INCLUDE eap.conf.*?#\$INCLUDE eap.conf?g" /etc/raddb/radiusd.conf
|
1 |
root |
761 |
# écoute sur loopback uniquement (à modifier plus tard pour l'EAP)
|
|
|
762 |
$SED "s?^[\t ]*ipaddr =.*?ipaddr = 127.0.0.1?g" /etc/raddb/radiusd.conf
|
|
|
763 |
# prise en compte du module SQL et des compteurs SQL
|
|
|
764 |
$SED "s?^[\t ]*#[\t ]*\$INCLUDE sql.conf.*?\$INCLUDE sql.conf?g" /etc/raddb/radiusd.conf
|
|
|
765 |
$SED "s?^[\t ]*#[\t ]*\$INCLUDE sql/mysql/counter.conf?\$INCLUDE sql/mysql/counter.conf?g" /etc/raddb/radiusd.conf
|
|
|
766 |
$SED "s?^[\t ]*\$INCLUDE policy.conf?#\$INCLUDE policy.conf?g" /etc/raddb/radiusd.conf
|
|
|
767 |
# purge du répertoire des serveurs virtuels et copie du fichier de configuration d'Alcasar
|
|
|
768 |
rm -f /etc/raddb/sites-enabled/*
|
|
|
769 |
cp $DIR_CONF/alcasar-radius /etc/raddb/sites-available/alcasar
|
|
|
770 |
chown radius:apache /etc/raddb/sites-available/alcasar /etc/raddb/modules/ldap # droits rw pour apache (module ldap)
|
|
|
771 |
chmod 660 /etc/raddb/sites-available/alcasar /etc/raddb/modules/ldap
|
|
|
772 |
chgrp apache /etc/raddb /etc/raddb/sites-available /etc/raddb/modules
|
|
|
773 |
ln -s /etc/raddb/sites-available/alcasar /etc/raddb/sites-enabled/alcasar
|
384 |
richard |
774 |
# Inutile dans notre fonctionnement mais les liens sont recréés par un update de radius ... donc forcé en tant que fichier à 'vide'
|
1 |
root |
775 |
touch /etc/raddb/sites-enabled/{inner-tunnel,control-socket,default}
|
|
|
776 |
# configuration du fichier client.conf (127.0.0.1 suffit mais on laisse le deuxième client pour la future gestion de l'EAP)
|
|
|
777 |
[ -e /etc/raddb/clients.conf.default ] || cp -f /etc/raddb/clients.conf /etc/raddb/clients.conf.default
|
|
|
778 |
cat << EOF > /etc/raddb/clients.conf
|
|
|
779 |
client 127.0.0.1 {
|
|
|
780 |
secret = $secretradius
|
|
|
781 |
shortname = localhost
|
|
|
782 |
}
|
|
|
783 |
EOF
|
|
|
784 |
# modif sql.conf
|
|
|
785 |
[ -e /etc/raddb/sql.conf.default ] || cp /etc/raddb/sql.conf /etc/raddb/sql.conf.default
|
|
|
786 |
$SED "s?^[\t ]*login =.*?login = \"$DB_USER\"?g" /etc/raddb/sql.conf
|
|
|
787 |
$SED "s?^[\t ]*password =.*?password = \"$radiuspwd\"?g" /etc/raddb/sql.conf
|
|
|
788 |
$SED "s?^[\t ]*radius_db =.*?radius_db = \"$DB_RADIUS\"?g" /etc/raddb/sql.conf
|
|
|
789 |
$SED "s?^[\t ]*sqltrace =.*?sqltrace = no?g" /etc/raddb/sql.conf
|
|
|
790 |
# modif dialup.conf
|
|
|
791 |
[ -e /etc/raddb/sql/mysql/dialup.conf.default ] || cp /etc/raddb/sql/mysql/dialup.conf /etc/raddb/sql/mysql/dialup.conf.default
|
|
|
792 |
cp -f $DIR_CONF/dialup.conf /etc/raddb/sql/mysql/dialup.conf
|
|
|
793 |
} # End param_radius ()
|
|
|
794 |
|
|
|
795 |
##########################################################################
|
|
|
796 |
## Fonction param_web_radius ##
|
|
|
797 |
## - Import, modification et paramètrage de l'interface "dialupadmin" ##
|
|
|
798 |
## - Création du lien vers la page de changement de mot de passe ##
|
|
|
799 |
##########################################################################
|
|
|
800 |
param_web_radius ()
|
|
|
801 |
{
|
|
|
802 |
# copie de l'interface d'origine dans la structure Alcasar
|
316 |
richard |
803 |
[ -d /usr/share/freeradius-web ] && cp -rf /usr/share/freeradius-web/* $DIR_ACC/manager/
|
|
|
804 |
rm -f $DIR_ACC/manager/index.html $DIR_ACC/manager/readme
|
|
|
805 |
rm -f $DIR_ACC/manager/htdocs/about.html $DIR_ACC/manager/htdocs/index.html $DIR_ACC/manager/htdocs/content.html
|
344 |
richard |
806 |
# copie des fichiers modifiés
|
|
|
807 |
cp -rf $DIR_INSTALL/web/acc/manager/* $DIR_ACC/manager/
|
316 |
richard |
808 |
chown -R apache:apache $DIR_ACC/manager/
|
344 |
richard |
809 |
# Modification des fichiers de configuration
|
1 |
root |
810 |
[ -e /etc/freeradius-web/admin.conf.default ] || cp /etc/freeradius-web/admin.conf /etc/freeradius-web/admin.conf.default
|
503 |
richard |
811 |
$SED "s?^general_domain:.*?general_domain: $DOMAIN?g" /etc/freeradius-web/admin.conf
|
1 |
root |
812 |
$SED "s?^sql_username:.*?sql_username: $DB_USER?g" /etc/freeradius-web/admin.conf
|
|
|
813 |
$SED "s?^sql_password:.*?sql_password: $radiuspwd?g" /etc/freeradius-web/admin.conf
|
|
|
814 |
$SED "s?^sql_debug:.*?sql_debug: false?g" /etc/freeradius-web/admin.conf
|
|
|
815 |
$SED "s?^sql_usergroup_table: .*?sql_usergroup_table: radusergroup?g" /etc/freeradius-web/admin.conf
|
|
|
816 |
$SED "s?^sql_password_attribute:.*?sql_password_attribute: Crypt-Password?g" /etc/freeradius-web/admin.conf
|
|
|
817 |
$SED "s?^general_finger_type.*?# general_finger_type: snmp?g" /etc/freeradius-web/admin.conf
|
|
|
818 |
$SED "s?^general_stats_use_totacct.*?general_stats_use_totacct: yes?g" /etc/freeradius-web/admin.conf
|
946 |
richard |
819 |
$SED "s?^general_charset.*?general_charset: utf-8?g" /etc/freeradius-web/admin.conf
|
344 |
richard |
820 |
[ -e /etc/freeradius-web/config.php.default ] || cp /etc/freeradius-web/config.php /etc/freeradius-web/config.php.default
|
|
|
821 |
cp -f $DIR_CONF/freeradiusweb-config.php /etc/freeradius-web/config.php
|
131 |
richard |
822 |
cat <<EOF > /etc/freeradius-web/naslist.conf
|
632 |
richard |
823 |
nas1_name: alcasar-$ORGANISME
|
1 |
root |
824 |
nas1_model: Portail captif
|
|
|
825 |
nas1_ip: $PRIVATE_IP
|
|
|
826 |
nas1_port_num: 0
|
|
|
827 |
nas1_community: public
|
|
|
828 |
EOF
|
|
|
829 |
# Modification des attributs visibles lors de la création d'un usager ou d'un groupe
|
|
|
830 |
[ -e /etc/freeradius-web/user_edit.attrs.default ] || mv /etc/freeradius-web/user_edit.attrs /etc/freeradius-web/user_edit.attrs.default
|
|
|
831 |
cp -f $DIR_CONF/user_edit.attrs /etc/freeradius-web/user_edit.attrs
|
114 |
richard |
832 |
# Ajout du mappage des attributs chillispot
|
|
|
833 |
[ -e /etc/freeradius-web/sql.attrmap.default ] || mv /etc/freeradius-web/sql.attrmap /etc/freeradius-web/sql.attrmap.default
|
|
|
834 |
cp -f $DIR_CONF/sql.attrmap /etc/freeradius-web/sql.attrmap
|
1 |
root |
835 |
# Modification des attributs visibles sur les pages des statistiques (suppression NAS_IP et NAS_port)
|
|
|
836 |
[ -e /etc/freeradius-web/sql.attrs.default ] || cp /etc/freeradius-web/sql.attrs /etc/freeradius-web/user_edit.attrs.default
|
|
|
837 |
$SED "s?^NASIPAddress.*?NASIPAddress\tNas IP Address\tno?g" /etc/freeradius-web/sql.attrs
|
|
|
838 |
$SED "s?^NASPortId.*?NASPortId\tNas Port\tno?g" /etc/freeradius-web/sql.attrs
|
5 |
franck |
839 |
chown -R apache:apache /etc/freeradius-web
|
1 |
root |
840 |
# Ajout de l'alias vers la page de "changement de mot de passe usager"
|
|
|
841 |
cat <<EOF >> /etc/httpd/conf/webapps.d/alcasar.conf
|
344 |
richard |
842 |
<Directory $DIR_WEB/pass>
|
1 |
root |
843 |
SSLRequireSSL
|
|
|
844 |
AllowOverride None
|
|
|
845 |
Order deny,allow
|
|
|
846 |
Deny from all
|
|
|
847 |
Allow from 127.0.0.1
|
|
|
848 |
Allow from $PRIVATE_NETWORK_MASK
|
580 |
richard |
849 |
ErrorDocument 404 https://$HOSTNAME
|
1 |
root |
850 |
</Directory>
|
|
|
851 |
EOF
|
|
|
852 |
} # End of param_web_radius ()
|
|
|
853 |
|
799 |
richard |
854 |
##################################################################################
|
|
|
855 |
## Fonction param_chilli ##
|
|
|
856 |
## - Création du fichier d'initialisation et de configuration de coova-chilli ##
|
|
|
857 |
## - Paramètrage de la page d'authentification (intercept.php) ##
|
|
|
858 |
##################################################################################
|
1 |
root |
859 |
param_chilli ()
|
|
|
860 |
{
|
799 |
richard |
861 |
# init file creation
|
461 |
richard |
862 |
[ -e /etc/init.d/chilli.default ] || cp /etc/init.d/chilli /etc/init.d/chilli.default
|
799 |
richard |
863 |
cat <<EOF > /etc/init.d/chilli
|
|
|
864 |
#!/bin/sh
|
|
|
865 |
#
|
|
|
866 |
# chilli CoovaChilli init
|
|
|
867 |
#
|
|
|
868 |
# chkconfig: 2345 65 35
|
|
|
869 |
# description: CoovaChilli
|
|
|
870 |
### BEGIN INIT INFO
|
|
|
871 |
# Provides: chilli
|
|
|
872 |
# Required-Start: network
|
|
|
873 |
# Should-Start:
|
|
|
874 |
# Required-Stop: network
|
|
|
875 |
# Should-Stop:
|
|
|
876 |
# Default-Start: 2 3 5
|
|
|
877 |
# Default-Stop:
|
|
|
878 |
# Description: CoovaChilli access controller
|
|
|
879 |
### END INIT INFO
|
|
|
880 |
|
|
|
881 |
[ -f /usr/sbin/chilli ] || exit 0
|
|
|
882 |
. /etc/init.d/functions
|
|
|
883 |
CONFIG=/etc/chilli.conf
|
|
|
884 |
pidfile=/var/run/chilli.pid
|
|
|
885 |
[ -f \$CONFIG ] || {
|
|
|
886 |
echo "\$CONFIG Not found"
|
|
|
887 |
exit 0
|
|
|
888 |
}
|
|
|
889 |
RETVAL=0
|
|
|
890 |
prog="chilli"
|
|
|
891 |
case \$1 in
|
|
|
892 |
start)
|
|
|
893 |
if [ -f \$pidfile ] ; then
|
|
|
894 |
gprintf "chilli is already running"
|
|
|
895 |
else
|
|
|
896 |
gprintf "Starting \$prog: "
|
|
|
897 |
rm -f /var/run/chilli* # cleaning
|
|
|
898 |
/sbin/modprobe tun >/dev/null 2>&1
|
|
|
899 |
echo 1 > /proc/sys/net/ipv4/ip_forward
|
|
|
900 |
[ -e /dev/net/tun ] || {
|
|
|
901 |
(cd /dev;
|
|
|
902 |
mkdir net;
|
|
|
903 |
cd net;
|
|
|
904 |
mknod tun c 10 200)
|
|
|
905 |
}
|
|
|
906 |
ifconfig eth1 0.0.0.0
|
|
|
907 |
daemon /usr/sbin/chilli -c \$CONFIG --pidfile=\$pidfile &
|
|
|
908 |
RETVAL=$?
|
|
|
909 |
fi
|
|
|
910 |
;;
|
|
|
911 |
|
|
|
912 |
reload)
|
|
|
913 |
killall -HUP chilli
|
|
|
914 |
;;
|
|
|
915 |
|
|
|
916 |
restart)
|
|
|
917 |
\$0 stop
|
|
|
918 |
sleep 2
|
|
|
919 |
\$0 start
|
|
|
920 |
;;
|
|
|
921 |
|
|
|
922 |
status)
|
|
|
923 |
status chilli
|
|
|
924 |
RETVAL=0
|
|
|
925 |
;;
|
|
|
926 |
|
|
|
927 |
stop)
|
|
|
928 |
if [ -f \$pidfile ] ; then
|
|
|
929 |
gprintf "Shutting down \$prog: "
|
|
|
930 |
killproc /usr/sbin/chilli
|
|
|
931 |
RETVAL=\$?
|
|
|
932 |
[ \$RETVAL = 0 ] && rm -f $pidfile
|
|
|
933 |
else
|
|
|
934 |
gprintf "chilli is not running"
|
|
|
935 |
fi
|
|
|
936 |
;;
|
|
|
937 |
|
|
|
938 |
*)
|
|
|
939 |
echo "Usage: \$0 {start|stop|restart|reload|status}"
|
|
|
940 |
exit 1
|
|
|
941 |
esac
|
|
|
942 |
echo
|
|
|
943 |
EOF
|
|
|
944 |
|
|
|
945 |
# conf file creation
|
346 |
richard |
946 |
[ -e /etc/chilli.conf.default ] || cp /etc/chilli.conf /etc/chilli.conf.default
|
|
|
947 |
cat <<EOF > /etc/chilli.conf
|
|
|
948 |
# coova config for ALCASAR
|
|
|
949 |
cmdsocket /var/run/chilli.sock
|
|
|
950 |
unixipc chilli.eth1.ipc
|
|
|
951 |
pidfile /var/run/chilli.eth1.pid
|
|
|
952 |
net $PRIVATE_NETWORK_MASK
|
595 |
richard |
953 |
dhcpif $INTIF
|
841 |
richard |
954 |
ethers $DIR_DEST_ETC/alcasar-ethers
|
861 |
richard |
955 |
#nodynip
|
865 |
richard |
956 |
#statip
|
|
|
957 |
dynip $PRIVATE_NETWORK_MASK
|
346 |
richard |
958 |
domain localdomain
|
355 |
richard |
959 |
dns1 $PRIVATE_IP
|
|
|
960 |
dns2 $PRIVATE_IP
|
346 |
richard |
961 |
uamlisten $PRIVATE_IP
|
503 |
richard |
962 |
uamport 3990
|
837 |
richard |
963 |
macauth
|
|
|
964 |
macpasswd password
|
346 |
richard |
965 |
locationname $HOSTNAME
|
|
|
966 |
radiusserver1 127.0.0.1
|
|
|
967 |
radiusserver2 127.0.0.1
|
|
|
968 |
radiussecret $secretradius
|
|
|
969 |
radiusauthport 1812
|
|
|
970 |
radiusacctport 1813
|
467 |
richard |
971 |
uamserver https://$HOSTNAME/intercept.php
|
346 |
richard |
972 |
radiusnasid $HOSTNAME
|
|
|
973 |
uamsecret $secretuam
|
793 |
richard |
974 |
uamallowed alcasar
|
346 |
richard |
975 |
coaport 3799
|
503 |
richard |
976 |
include $DIR_DEST_ETC/alcasar-uamallowed
|
|
|
977 |
include $DIR_DEST_ETC/alcasar-uamdomain
|
917 |
franck |
978 |
#dhcpgateway
|
|
|
979 |
#dhcprelayagent
|
|
|
980 |
#dhcpgatewayport
|
346 |
richard |
981 |
EOF
|
605 |
richard |
982 |
# création du fichier d'allocation d'adresses IP statiques
|
|
|
983 |
touch $DIR_DEST_ETC/alcasar-ethers
|
840 |
richard |
984 |
# create files for trusted domains and urls
|
|
|
985 |
touch $DIR_DEST_ETC/alcasar-uamallowed $DIR_DEST_ETC/alcasar-uamdomain
|
503 |
richard |
986 |
chown root:apache $DIR_DEST_ETC/alcasar-*
|
|
|
987 |
chmod 660 $DIR_DEST_ETC/alcasar-*
|
847 |
richard |
988 |
# Configuration des fichier WEB d'interception (secret partagé avec coova-chilli)
|
526 |
stephane |
989 |
$SED "s?^\$uamsecret =.*?\$uamsecret = \"$secretuam\";?g" $DIR_WEB/intercept.php
|
|
|
990 |
$SED "s?^\$userpassword=1.*?\$userpassword=1;?g" $DIR_WEB/intercept.php
|
796 |
richard |
991 |
# user 'chilli' creation (in order to run conup/off and up/down scripts
|
|
|
992 |
chilli_exist=`grep chilli /etc/passwd|wc -l`
|
|
|
993 |
if [ "$chilli_exist" == "1" ]
|
|
|
994 |
then
|
|
|
995 |
userdel -r chilli 2>/dev/null
|
|
|
996 |
fi
|
|
|
997 |
groupadd -f chilli
|
|
|
998 |
useradd -r -g chilli -s /bin/false -c "system user for coova-chilli" chilli
|
1 |
root |
999 |
} # End of param_chilli ()
|
|
|
1000 |
|
|
|
1001 |
##########################################################
|
|
|
1002 |
## Fonction param_squid ##
|
|
|
1003 |
## - Paramètrage du proxy 'squid' en mode 'cache' ##
|
|
|
1004 |
## - Initialisation de la base de données ##
|
|
|
1005 |
##########################################################
|
|
|
1006 |
param_squid ()
|
|
|
1007 |
{
|
|
|
1008 |
# paramètrage de Squid (connecté en série derrière Dansguardian)
|
|
|
1009 |
[ -e /etc/squid/squid.conf.default ] || cp /etc/squid/squid.conf /etc/squid/squid.conf.default
|
|
|
1010 |
# suppression des références 'localnet', 'icp', 'htcp' et 'always_direct'
|
|
|
1011 |
$SED "/^acl localnet/d" /etc/squid/squid.conf
|
|
|
1012 |
$SED "/^icp_access allow localnet/d" /etc/squid/squid.conf
|
|
|
1013 |
$SED "/^icp_port 3130/d" /etc/squid/squid.conf
|
|
|
1014 |
$SED "/^http_access allow localnet/d" /etc/squid/squid.conf
|
|
|
1015 |
$SED "/^htcp_access allow localnet/d" /etc/squid/squid.conf
|
|
|
1016 |
$SED "/^always_direct allow localnet/d" /etc/squid/squid.conf
|
|
|
1017 |
# mode 'proxy transparent local'
|
595 |
richard |
1018 |
$SED "s?^http_port.*?http_port 127.0.0.1:3128 transparent?g" /etc/squid/squid.conf
|
726 |
franck |
1019 |
# Configuration du cache local
|
749 |
franck |
1020 |
$SED "s?^#cache_dir.*?cache_dir ufs \/var\/spool\/squid 256 16 256?g" /etc/squid/squid.conf
|
405 |
franck |
1021 |
# emplacement et formatage standard des logs
|
419 |
franck |
1022 |
echo '#logformat common %>a %ui %un [%tl] "%rm %ru HTTP/%rv" %>Hs %<st %Ss:%Sh' >> /etc/squid/squid.conf
|
749 |
franck |
1023 |
echo '#logformat combined %>a %ui %un [%tl] "%rm %ru HTTP/%rv" %>Hs %<st "%{Referer}>h" "%{User-Agent}>h" %Ss:%Sh' >> /etc/squid/squid.conf
|
405 |
franck |
1024 |
echo "access_log /var/log/squid/access.log" >> /etc/squid/squid.conf
|
1 |
root |
1025 |
# compatibilité des logs avec awstats
|
315 |
richard |
1026 |
echo "emulate_httpd_log on" >> /etc/squid/squid.conf
|
749 |
franck |
1027 |
echo "half_closed_clients off" >> /etc/squid/squid.conf
|
|
|
1028 |
echo "server_persistent_connections off" >> /etc/squid/squid.conf
|
|
|
1029 |
echo "client_persistent_connections on" >> /etc/squid/squid.conf
|
|
|
1030 |
echo "client_lifetime 1440 minutes" >> /etc/squid/squid.conf
|
|
|
1031 |
echo "request_timeout 5 minutes" >> /etc/squid/squid.conf
|
|
|
1032 |
echo "persistent_request_timeout 2 minutes" >> /etc/squid/squid.conf
|
726 |
franck |
1033 |
echo "cache_mem 256 MB" >> /etc/squid/squid.conf
|
749 |
franck |
1034 |
echo "maximum_object_size_in_memory 4096 KB" >> /etc/squid/squid.conf
|
|
|
1035 |
echo "maximum_object_size 4096 KB" >> /etc/squid/squid.conf
|
835 |
richard |
1036 |
# anonymisation of squid version
|
813 |
richard |
1037 |
echo "via off" >> /etc/squid/squid.conf
|
835 |
richard |
1038 |
# remove the 'X_forwarded' http option
|
812 |
richard |
1039 |
echo "forwarded_for delete" >> /etc/squid/squid.conf
|
835 |
richard |
1040 |
# linked squid output in HAVP input
|
|
|
1041 |
echo "cache_peer 127.0.0.1 parent 8090 0 no-query default" >> /etc/squid/squid.conf
|
|
|
1042 |
echo "never_direct allow all" >> /etc/squid/squid.conf
|
|
|
1043 |
# avoid error messages on network interfaces state changes
|
313 |
richard |
1044 |
$SED "s?^SQUID_AUTO_RELOAD.*?SQUID_AUTO_RELOAD=no?g" /etc/sysconfig/squid
|
894 |
richard |
1045 |
# reduce squid shutdown time (100 to 50)
|
|
|
1046 |
$SED "s?^SQUID_SHUTDOWN_TIMEOUT.*?SQUID_SHUTDOWN_TIMEOUT=50?g" /etc/sysconfig/squid
|
|
|
1047 |
|
835 |
richard |
1048 |
# Squid cache init
|
1 |
root |
1049 |
/usr/sbin/squid -z
|
|
|
1050 |
} # End of param_squid ()
|
|
|
1051 |
|
|
|
1052 |
##################################################################
|
|
|
1053 |
## Fonction param_dansguardian ##
|
|
|
1054 |
## - Paramètrage du gestionnaire de contenu Dansguardian ##
|
|
|
1055 |
##################################################################
|
|
|
1056 |
param_dansguardian ()
|
|
|
1057 |
{
|
|
|
1058 |
mkdir /var/dansguardian
|
|
|
1059 |
chown dansguardian /var/dansguardian
|
497 |
richard |
1060 |
[ -e $DIR_DG/dansguardian.conf.default ] || cp $DIR_DG/dansguardian.conf $DIR_DG/dansguardian.conf.default
|
307 |
richard |
1061 |
# Le filtrage est désactivé par défaut
|
497 |
richard |
1062 |
$SED "s/^reportinglevel =.*/reportinglevel = -1/g" $DIR_DG/dansguardian.conf
|
1 |
root |
1063 |
# la page d'interception est en français
|
497 |
richard |
1064 |
$SED "s?^language =.*?language = french?g" $DIR_DG/dansguardian.conf
|
1 |
root |
1065 |
# on limite l'écoute de Dansguardian côté LAN
|
497 |
richard |
1066 |
$SED "s?^filterip.*?filterip = $PRIVATE_IP?g" $DIR_DG/dansguardian.conf
|
835 |
richard |
1067 |
# on chaîne Dansguardian au proxy cache SQUID
|
|
|
1068 |
$SED "s?^proxyport.*?proxyport = 3128?g" $DIR_DG/dansguardian.conf
|
1 |
root |
1069 |
# on remplace la page d'interception (template)
|
|
|
1070 |
cp -f $DIR_CONF/template.html /usr/share/dansguardian/languages/ukenglish/
|
|
|
1071 |
cp -f $DIR_CONF/template-fr.html /usr/share/dansguardian/languages/french/template.html
|
|
|
1072 |
# on ne loggue que les deny (pour le reste, on a squid)
|
497 |
richard |
1073 |
$SED "s?^loglevel =.*?loglevel = 1?g" $DIR_DG/dansguardian.conf
|
659 |
richard |
1074 |
# lauch of 10 daemons (20 in largest server)
|
|
|
1075 |
$SED "s?^minchildren =.*?minchildren = 10?g" $DIR_DG/dansguardian.conf
|
1 |
root |
1076 |
# on désactive par défaut le controle de contenu des pages html
|
497 |
richard |
1077 |
$SED "s?^weightedphrasemode =.*?weightedphrasemode = 0?g" $DIR_DG/dansguardian.conf
|
|
|
1078 |
cp $DIR_DG/lists/bannedphraselist $DIR_DG/lists/bannedphraselist.default
|
|
|
1079 |
$SED "s?^[^#]?#&?g" $DIR_DG/lists/bannedphraselist # (on commente ce qui ne l'est pas)
|
1 |
root |
1080 |
# on désactive par défaut le contrôle d'URL par expressions régulières
|
497 |
richard |
1081 |
cp $DIR_DG/lists/bannedregexpurllist $DIR_DG/lists/bannedregexpurllist.default
|
|
|
1082 |
$SED "s?^[^#]?#&?g" $DIR_DG/lists/bannedregexpurllist # (on commente ce qui ne l'est pas)
|
1 |
root |
1083 |
# on désactive par défaut le contrôle de téléchargement de fichiers
|
497 |
richard |
1084 |
[ -e $DIR_DG/dansguardianf1.conf.default ] || cp $DIR_DG/dansguardianf1.conf $DIR_DG/dansguardianf1.conf.default
|
|
|
1085 |
$SED "s?^blockdownloads =.*?blockdownloads = off?g" $DIR_DG/dansguardianf1.conf
|
|
|
1086 |
[ -e $DIR_DG/lists/bannedextensionlist.default ] || mv $DIR_DG/lists/bannedextensionlist $DIR_DG/lists/bannedextensionlist.default
|
|
|
1087 |
[ -e $DIR_DG/lists/bannedmimetypelist.default ] || mv $DIR_DG/lists/bannedmimetypelist $DIR_DG/lists/bannedmimetypelist.default
|
|
|
1088 |
touch $DIR_DG/lists/bannedextensionlist
|
|
|
1089 |
touch $DIR_DG/lists/bannedmimetypelist
|
|
|
1090 |
# 'Safesearch' regex actualisation
|
498 |
richard |
1091 |
$SED "s?images?search?g" $DIR_DG/lists/urlregexplist
|
497 |
richard |
1092 |
# empty LAN IP list that won't be WEB filtered
|
|
|
1093 |
[ -e $DIR_DG/lists/exceptioniplist.default ] || mv $DIR_DG/lists/exceptioniplist $DIR_DG/lists/exceptioniplist.default
|
|
|
1094 |
touch $DIR_DG/lists/exceptioniplist
|
|
|
1095 |
# Keep a copy of URL & domain filter configuration files
|
|
|
1096 |
[ -e $DIR_DG/lists/bannedsitelist.default ] || mv $DIR_DG/lists/bannedsitelist $DIR_DG/lists/bannedsitelist.default
|
|
|
1097 |
[ -e $DIR_DG/lists/bannedurllist.default ] || mv $DIR_DG/lists/bannedurllist $DIR_DG/lists/bannedurllist.default
|
1 |
root |
1098 |
} # End of param_dansguardian ()
|
|
|
1099 |
|
71 |
richard |
1100 |
##################################################################
|
|
|
1101 |
## Fonction antivirus ##
|
479 |
richard |
1102 |
## - configuration havp + libclamav ##
|
71 |
richard |
1103 |
##################################################################
|
|
|
1104 |
antivirus ()
|
|
|
1105 |
{
|
288 |
richard |
1106 |
# création de l'usager 'havp'
|
|
|
1107 |
havp_exist=`grep havp /etc/passwd|wc -l`
|
307 |
richard |
1108 |
if [ "$havp_exist" == "1" ]
|
288 |
richard |
1109 |
then
|
478 |
richard |
1110 |
userdel -r havp 2>/dev/null
|
894 |
richard |
1111 |
groupdel havp 2>/dev/null
|
288 |
richard |
1112 |
fi
|
307 |
richard |
1113 |
groupadd -f havp
|
796 |
richard |
1114 |
useradd -r -g havp -s /bin/false -c "system user for havp" havp
|
476 |
richard |
1115 |
mkdir -p /var/tmp/havp /var/log/havp
|
|
|
1116 |
chown -R havp /var/tmp/havp /var/log/havp /var/run/havp
|
307 |
richard |
1117 |
$SED "/$HAVP_BIN -c $HAVP_CONFIG/i chown -R havp:havp \/var\/tmp\/havp" /etc/init.d/havp
|
109 |
richard |
1118 |
# configuration d'HAVP
|
|
|
1119 |
[ -e /etc/havp/havp.config.default ] || cp /etc/havp/havp.config /etc/havp/havp.config.default
|
|
|
1120 |
$SED "/^REMOVETHISLINE/d" /etc/havp/havp.config
|
631 |
richard |
1121 |
$SED "s?^# PORT.*?PORT 8090?g" /etc/havp/havp.config # datas come on 8090
|
|
|
1122 |
$SED "s?^# BIND_ADDRESS.*?BIND_ADDRESS 127.0.0.1?g" /etc/havp/havp.config # we listen only on loopback
|
|
|
1123 |
$SED "s?^ENABLECLAMLIB.*?ENABLECLAMLIB true?g" /etc/havp/havp.config # active libclamav AV
|
|
|
1124 |
$SED "s?^# LOG_OKS.*?LOG_OKS false?g" /etc/havp/havp.config # log only when malware matches
|
659 |
richard |
1125 |
$SED "s?^# SERVERNUMBER.*?SERVERNUMBER 10?g" /etc/havp/havp.config # 10 daemons are started simultaneously
|
835 |
richard |
1126 |
$SED "s?^# SCANIMAGES.*?SCANIMAGES false?g" /etc/havp/havp.config # doesn't scan image files
|
|
|
1127 |
$SED "s?^# SKIPMIME.*?SKIPMIME image\/\* video\/\* audio\/\*?g" /etc/havp/havp.config # doesn't scan some multimedia files
|
481 |
franck |
1128 |
# remplacement du fichier d'initialisation
|
335 |
richard |
1129 |
[ -e /etc/init.d/havp.default ] || cp /etc/init.d/havp /etc/init.d/havp.default
|
481 |
franck |
1130 |
cp -f $DIR_CONF/havp-init /etc/init.d/havp
|
340 |
richard |
1131 |
# on remplace la page d'interception (template)
|
|
|
1132 |
cp -f $DIR_CONF/virus-fr.html /etc/havp/templates/fr/virus.html
|
|
|
1133 |
cp -f $DIR_CONF/virus-en.html /etc/havp/templates/en/virus.html
|
489 |
richard |
1134 |
# automatisation de la mise à jour de la base antivirale (toutes les 2 heures)
|
|
|
1135 |
$SED "s?^Checks.*?Checks 12?g" /etc/freshclam.conf
|
|
|
1136 |
$SED "s?^NotifyClamd.*?# NotifyClamd /etc/clamd.conf?g" /etc/freshclam.conf
|
734 |
richard |
1137 |
# Virus database update
|
|
|
1138 |
rm -f /var/lib/clamav/*.cld # in case of old database scheme
|
|
|
1139 |
[ -e /var/lib/clamav/main.cvd ] || /usr/bin/freshclam
|
71 |
richard |
1140 |
}
|
|
|
1141 |
|
1 |
root |
1142 |
##################################################################################
|
476 |
richard |
1143 |
## param_ulogd function ##
|
|
|
1144 |
## - Ulog config for multi-log files ##
|
|
|
1145 |
##################################################################################
|
|
|
1146 |
param_ulogd ()
|
|
|
1147 |
{
|
|
|
1148 |
# Three instances of ulogd (three different logfiles)
|
|
|
1149 |
[ -d /var/log/firewall ] || mkdir -p /var/log/firewall
|
478 |
richard |
1150 |
nl=1
|
|
|
1151 |
for log_type in tracability ssh ext-access
|
|
|
1152 |
do
|
|
|
1153 |
[ -e /var/log/firewall/$log_type.log ] || touch /var/log/firewall/$log_type.log
|
|
|
1154 |
cp -f /etc/ulogd.conf /etc/ulogd-$log_type.conf
|
|
|
1155 |
$SED "s?^nlgroup=.*?nlgroup=$nl?g" /etc/ulogd-$log_type.conf
|
|
|
1156 |
$SED '/OPRINT/,$d' /etc/ulogd-$log_type.conf
|
|
|
1157 |
cat << EOF >> /etc/ulogd-$log_type.conf
|
|
|
1158 |
[LOGEMU]
|
|
|
1159 |
file="/var/log/firewall/$log_type.log"
|
|
|
1160 |
sync=1
|
|
|
1161 |
EOF
|
|
|
1162 |
nl=`expr $nl + 1`
|
|
|
1163 |
done
|
476 |
richard |
1164 |
chown -R root:apache /var/log/firewall
|
|
|
1165 |
chmod 750 /var/log/firewall
|
|
|
1166 |
chmod 640 /var/log/firewall/*
|
|
|
1167 |
[ -e /etc/init.d/ulogd.default ] || cp /etc/init.d/ulogd /etc/init.d/ulogd.default
|
|
|
1168 |
cp -f $DIR_CONF/ulogd-init /etc/init.d/ulogd
|
|
|
1169 |
} # End of param_ulogd ()
|
|
|
1170 |
|
|
|
1171 |
##################################################################################
|
1 |
root |
1172 |
## Fonction param_awstats ##
|
|
|
1173 |
## - configuration de l'interface des logs de consultation WEB (AWSTAT) ##
|
|
|
1174 |
##################################################################################
|
|
|
1175 |
param_awstats()
|
|
|
1176 |
{
|
316 |
richard |
1177 |
cp -rf /usr/share/awstats/www/ $DIR_ACC/awstats/
|
|
|
1178 |
chown -R apache:apache $DIR_ACC/awstats
|
1 |
root |
1179 |
cp /etc/awstats/awstats.conf /etc/awstats/awstats.conf.default
|
|
|
1180 |
$SED "s?^LogFile=.*?LogFile=\"/var/log/squid/access.log\"?g" /etc/awstats/awstats.conf
|
|
|
1181 |
$SED "s?^LogFormat=.*?LogFormat=4?g" /etc/awstats/awstats.conf
|
|
|
1182 |
$SED "s?^SiteDomain=.*?SiteDomain=\"$HOSTNAME\"?g" /etc/awstats/awstats.conf
|
|
|
1183 |
$SED "s?^HostAliases=.*?HostAliases=\"$PRIVATE_IP\"?g" /etc/awstats/awstats.conf
|
|
|
1184 |
$SED "s?^DNSLookup=.*?DNSLookup=0?g" /etc/awstats/awstats.conf
|
344 |
richard |
1185 |
$SED "s?^DirData=.*?DirData=\"/var/lib/awstats\"?g" /etc/awstats/awstats.conf
|
|
|
1186 |
$SED "s?^DirIcons=.*?DirIcons=\"/acc/awstats/icon\"?g" /etc/awstats/awstats.conf
|
1 |
root |
1187 |
$SED "s?^StyleSheet=.*?StyleSheet=\"/css/style.css\"?g" /etc/awstats/awstats.conf
|
|
|
1188 |
$SED "s?^BuildReportFormat=.*?BuildReportFormat=xhtml?g" /etc/awstats/awstats.conf
|
59 |
richard |
1189 |
$SED "s?^UseFramesWhenCGI=.*?UseFramesWhenCGI=0?g" /etc/awstats/awstats.conf
|
580 |
richard |
1190 |
$SED "s?^UseFramesWhenCGI=.*?UseFramesWhenCGI=0?g" /etc/awstats/awstats.conf
|
|
|
1191 |
$SED "s?^ShowSummary=.*?ShowSummary=VPHB?g" /etc/awstats/awstats.conf
|
|
|
1192 |
$SED "s?^ShowSummary=.*?ShowSummary=VPHB?g" /etc/awstats/awstats.conf
|
|
|
1193 |
$SED "s?^ShowMonthStats=.*?ShowMonthStats=VPHB?g" /etc/awstats/awstats.conf
|
|
|
1194 |
$SED "s?^ShowDaysOfMonthStats=.*?ShowDaysOfMonthStats=PHB?g" /etc/awstats/awstats.conf
|
|
|
1195 |
$SED "s?^ShowDaysOfWeekStats=.*?ShowDaysOfWeekStats=PHB?g" /etc/awstats/awstats.conf
|
|
|
1196 |
$SED "s?^ShowHoursStats=.*?ShowHoursStats=PHB?g" /etc/awstats/awstats.conf
|
|
|
1197 |
$SED "s?^ShowDomainsStats=.*?ShowDomainsStats=0?g" /etc/awstats/awstats.conf
|
|
|
1198 |
$SED "s?^ShowHostsStats=.*?ShowHostsStats=0?g" /etc/awstats/awstats.conf
|
|
|
1199 |
$SED "s?^ShowAuthenticatedUsers=.*?ShowAuthenticatedUsers=0?g" /etc/awstats/awstats.conf
|
|
|
1200 |
$SED "s?^ShowRobotsStats=.*?ShowRobotsStats=0?g" /etc/awstats/awstats.conf
|
|
|
1201 |
$SED "s?^ShowFileTypesStats=.*?ShowFileTypesStats=0?g" /etc/awstats/awstats.conf
|
|
|
1202 |
$SED "s?^ShowFileSizesStats=.*?ShowFileSizesStats=0?g" /etc/awstats/awstats.conf
|
|
|
1203 |
$SED "s?^ShowOSStats=.*?ShowOSStats=0?g" /etc/awstats/awstats.conf
|
|
|
1204 |
$SED "s?^ShowScreenSizeStats=.*?ShowScreenSizeStats=0?g" /etc/awstats/awstats.conf
|
|
|
1205 |
|
1 |
root |
1206 |
cat <<EOF >> /etc/httpd/conf/webapps.d/alcasar.conf
|
316 |
richard |
1207 |
<Directory $DIR_ACC/awstats>
|
1 |
root |
1208 |
SSLRequireSSL
|
|
|
1209 |
Options ExecCGI
|
|
|
1210 |
AddHandler cgi-script .pl
|
|
|
1211 |
DirectoryIndex awstats.pl
|
|
|
1212 |
Order deny,allow
|
|
|
1213 |
Deny from all
|
|
|
1214 |
Allow from 127.0.0.1
|
|
|
1215 |
Allow from $PRIVATE_NETWORK_MASK
|
|
|
1216 |
require valid-user
|
|
|
1217 |
AuthType digest
|
|
|
1218 |
AuthName $HOSTNAME
|
|
|
1219 |
BrowserMatch "MSIE" AuthDigestEnableQueryStringHack=On
|
434 |
richard |
1220 |
AuthUserFile $DIR_DEST_ETC/digest/key_admin
|
580 |
richard |
1221 |
ErrorDocument 404 https://$HOSTNAME/
|
1 |
root |
1222 |
</Directory>
|
|
|
1223 |
SetEnv PERL5LIB /usr/share/awstats/lib:/usr/share/awstats/plugins
|
|
|
1224 |
EOF
|
|
|
1225 |
} # End of param_awstats ()
|
|
|
1226 |
|
|
|
1227 |
##########################################################
|
235 |
richard |
1228 |
## Fonction param_dnsmasq ##
|
1 |
root |
1229 |
##########################################################
|
219 |
jeremy |
1230 |
param_dnsmasq ()
|
|
|
1231 |
{
|
|
|
1232 |
[ -d /var/log/dnsmasq ] || mkdir /var/log/dnsmasq
|
259 |
richard |
1233 |
$SED "s?^DHCP_LEASE=.*?DHCP_LEASE=/var/log/dnsmasq/lease.log?g" /etc/sysconfig/dnsmasq # fichier contenant les baux
|
503 |
richard |
1234 |
[ -e /etc/dnsmasq.conf.default ] || cp /etc/dnsmasq.conf /etc/dnsmasq.conf.default
|
520 |
richard |
1235 |
# 1st dnsmasq listen on udp 53 ("dnsmasq - forward"). It's used as dhcp server only if bypass is on.
|
503 |
richard |
1236 |
cat << EOF > /etc/dnsmasq.conf
|
520 |
richard |
1237 |
# Configuration file for "dnsmasq in forward mode"
|
503 |
richard |
1238 |
conf-file=$DIR_DEST_ETC/alcasar-dns-name # zone de definition de noms DNS locaux
|
259 |
richard |
1239 |
listen-address=$PRIVATE_IP
|
|
|
1240 |
listen-address=127.0.0.1
|
286 |
richard |
1241 |
no-dhcp-interface=$INTIF
|
259 |
richard |
1242 |
bind-interfaces
|
|
|
1243 |
cache-size=256
|
|
|
1244 |
domain=$DOMAIN
|
|
|
1245 |
domain-needed
|
|
|
1246 |
expand-hosts
|
|
|
1247 |
bogus-priv
|
|
|
1248 |
filterwin2k
|
|
|
1249 |
server=$DNS1
|
|
|
1250 |
server=$DNS2
|
498 |
richard |
1251 |
# le servive DHCP est configuré mais n'est exploité que pour le "bypass"
|
865 |
richard |
1252 |
dhcp-range=$PRIVATE_FIRST_IP,$PRIVATE_LAST_IP,$PRIVATE_NETMASK,12h
|
632 |
richard |
1253 |
dhcp-option=option:router,$PRIVATE_IP
|
259 |
richard |
1254 |
#dhcp-option=option:ntp-server,192.168.0.4,10.10.0.5
|
|
|
1255 |
|
291 |
franck |
1256 |
# Exemple de configuration statique : <@MAC>,<name>,<@IP>,<MASK>,<ttl bail>
|
420 |
franck |
1257 |
#dhcp-host=11:22:33:44:55:66,ssic-test,192.168.182.20,255.255.255.0,45m
|
259 |
richard |
1258 |
EOF
|
520 |
richard |
1259 |
# 2nd dnsmasq listen on udp 54 ("dnsmasq with blackhole")
|
|
|
1260 |
cat << EOF > /etc/dnsmasq-blackhole.conf
|
|
|
1261 |
# Configuration file for "dnsmasq with blackhole"
|
|
|
1262 |
# Inclusion de la blacklist <domains> de Toulouse dans la configuration
|
|
|
1263 |
conf-dir=$DIR_DEST_ETC/alcasar-dnsfilter-enabled
|
503 |
richard |
1264 |
conf-file=$DIR_DEST_ETC/alcasar-dns-name # zone de definition de noms DNS locaux
|
498 |
richard |
1265 |
listen-address=$PRIVATE_IP
|
|
|
1266 |
port=54
|
|
|
1267 |
no-dhcp-interface=$INTIF
|
|
|
1268 |
bind-interfaces
|
|
|
1269 |
cache-size=256
|
|
|
1270 |
domain=$DOMAIN
|
|
|
1271 |
domain-needed
|
|
|
1272 |
expand-hosts
|
|
|
1273 |
bogus-priv
|
|
|
1274 |
filterwin2k
|
|
|
1275 |
server=$DNS1
|
|
|
1276 |
server=$DNS2
|
|
|
1277 |
EOF
|
718 |
franck |
1278 |
|
800 |
richard |
1279 |
# Init file modification
|
503 |
richard |
1280 |
[ -e /etc/init.d/dnsmasq.default ] || cp /etc/init.d/dnsmasq /etc/init.d/dnsmasq.default
|
800 |
richard |
1281 |
# Start and stop a 2nd process for the "DNS blackhole"
|
520 |
richard |
1282 |
$SED "/daemon/a \$dnsmasq -C /etc/dnsmasq-blackhole.conf \$OPTIONS" /etc/init.d/dnsmasq
|
503 |
richard |
1283 |
$SED "/killproc \$DAEMON_NAME/a killproc \$DAEMON_NAME" /etc/init.d/dnsmasq
|
800 |
richard |
1284 |
# Start after chilli (65) which create tun0
|
|
|
1285 |
$SED "s?^# chkconfig:.*?# chkconfig: 2345 99 40?g" /etc/init.d/dnsmasq
|
933 |
franck |
1286 |
# Optionnellement on pré-active les logs DNS des clients
|
786 |
richard |
1287 |
[ -e /etc/sysconfig/dnsmasq.default ] || cp /etc/sysconfig/dnsmasq /etc/sysconfig/dnsmasq.default
|
933 |
franck |
1288 |
$SED "s?log-facility?#OPTIONS=\"-q --log-facility=/var/log/dnsmasq/queries.log\"?g" /etc/sysconfig/dnsmasq
|
|
|
1289 |
# Optionnellement, exemple de configuration avec un A.D.
|
|
|
1290 |
echo '#OPTIONS="$OPTIONS --server=/your-domain/192.168.182.2"' >> /etc/sysconfig/dnsmasq
|
308 |
richard |
1291 |
} # End dnsmasq
|
|
|
1292 |
|
|
|
1293 |
##########################################################
|
|
|
1294 |
## Fonction BL (BlackList) ##
|
|
|
1295 |
##########################################################
|
|
|
1296 |
BL ()
|
|
|
1297 |
{
|
|
|
1298 |
# on copie par défaut la BL de toulouse embarqués dans l'archive d'ALCASAR
|
648 |
richard |
1299 |
rm -rf $DIR_DG/lists/blacklists
|
|
|
1300 |
tar zxf $DIR_CONF/blacklists.tar.gz --directory=$DIR_DG/lists/ > /dev/null 2>&1
|
878 |
richard |
1301 |
# on crée le répertoire ossi (noms de domaine et URLs ajoutés à la BL)
|
|
|
1302 |
mkdir $DIR_DG/lists/blacklists/ossi
|
|
|
1303 |
touch $DIR_DG/lists/blacklists/ossi/domains
|
|
|
1304 |
touch $DIR_DG/lists/blacklists/ossi/urls
|
309 |
richard |
1305 |
# On crée les fichiers vides de sites ou d'URL réhabilités
|
648 |
richard |
1306 |
[ -e $DIR_DG/lists/exceptionsitelist.default ] || mv $DIR_DG/lists/exceptionsitelist $DIR_DG/lists/exceptionsitelist.default
|
673 |
richard |
1307 |
[ -e $DIR_DG/lists/exceptionurllist.default ] || mv $DIR_DG/lists/exceptionurllist $DIR_DG/lists/exceptionurllist.default
|
648 |
richard |
1308 |
touch $DIR_DG/lists/exceptionsitelist
|
|
|
1309 |
touch $DIR_DG/lists/exceptionurllist
|
311 |
richard |
1310 |
# On crée la configuration de base du filtrage de domaine et d'URL pour Dansguardian
|
648 |
richard |
1311 |
cat <<EOF > $DIR_DG/lists/bannedurllist
|
311 |
richard |
1312 |
# Dansguardian filter config for ALCASAR
|
|
|
1313 |
EOF
|
648 |
richard |
1314 |
cat <<EOF > $DIR_DG/lists/bannedsitelist
|
311 |
richard |
1315 |
# Dansguardian domain filter config for ALCASAR
|
|
|
1316 |
# block all sites except those in the exceptionsitelist --> liste blanche (désactivée)
|
|
|
1317 |
#**
|
|
|
1318 |
# block all SSL and CONNECT tunnels
|
|
|
1319 |
**s
|
|
|
1320 |
# block all SSL and CONNECT tunnels specified only as an IP
|
|
|
1321 |
*ips
|
|
|
1322 |
# block all sites specified only by an IP
|
|
|
1323 |
*ip
|
|
|
1324 |
EOF
|
878 |
richard |
1325 |
# On ajoute Bing et Youtube à la récriture d'URL liée au contrôle scolaire/parental
|
|
|
1326 |
cat <<EOF >> $DIR_DG/lists/urlregexplist
|
|
|
1327 |
# Bing - add 'adlt=strict'
|
|
|
1328 |
#"(^http://[0-9a-z]+\.bing\.[a-z]+[-/%.0-9a-z]*\?)(.*)"->"\1\2&adlt=strict"
|
|
|
1329 |
# Youtube - add 'edufilter=your_ID'
|
885 |
richard |
1330 |
#"(^http://[0-9a-z]+\.youtube\.[a-z]+[-/%.0-9a-z]*\?)(.*)"->"\1\2&edufilter=ABCD1234567890abcdef"
|
878 |
richard |
1331 |
EOF
|
648 |
richard |
1332 |
chown -R dansguardian:apache $DIR_DG
|
|
|
1333 |
chmod -R g+rw $DIR_DG
|
304 |
richard |
1334 |
# On crée la structure du DNS-blackhole :
|
503 |
richard |
1335 |
mkdir $DIR_DEST_ETC/{alcasar-dnsfilter-available,alcasar-dnsfilter-enabled}
|
|
|
1336 |
chown -R 770 $DIR_DEST_ETC/{alcasar-dnsfilter-available,alcasar-dnsfilter-enabled}
|
|
|
1337 |
chown -R root:apache $DIR_DEST_ETC/{alcasar-dnsfilter-available,alcasar-dnsfilter-enabled}
|
786 |
richard |
1338 |
# On adapte la BL de Toulouse à notre structure
|
654 |
richard |
1339 |
if [ "$mode" != "update" ]; then
|
|
|
1340 |
$DIR_DEST_SBIN/alcasar-bl.sh --adapt
|
|
|
1341 |
fi
|
308 |
richard |
1342 |
}
|
219 |
jeremy |
1343 |
|
1 |
root |
1344 |
##########################################################
|
|
|
1345 |
## Fonction cron ##
|
|
|
1346 |
## - Mise en place des différents fichiers de cron ##
|
|
|
1347 |
##########################################################
|
|
|
1348 |
cron ()
|
|
|
1349 |
{
|
|
|
1350 |
# Modif du fichier 'crontab' pour passer les cron à minuit au lieu de 04h00
|
|
|
1351 |
[ -e /etc/crontab.default ] || cp /etc/crontab /etc/crontab.default
|
|
|
1352 |
cat <<EOF > /etc/crontab
|
|
|
1353 |
SHELL=/bin/bash
|
|
|
1354 |
PATH=/sbin:/bin:/usr/sbin:/usr/bin
|
|
|
1355 |
MAILTO=root
|
|
|
1356 |
HOME=/
|
|
|
1357 |
|
|
|
1358 |
# run-parts
|
|
|
1359 |
01 * * * * root nice -n 19 run-parts --report /etc/cron.hourly
|
|
|
1360 |
02 0 * * * root nice -n 19 run-parts --report /etc/cron.daily
|
|
|
1361 |
22 0 * * 0 root nice -n 19 run-parts --report /etc/cron.weekly
|
|
|
1362 |
42 0 1 * * root nice -n 19 run-parts --report /etc/cron.monthly
|
|
|
1363 |
EOF
|
|
|
1364 |
[ -e /etc/anacrontab.default ] || cp /etc/anacrontab /etc/anacrontab.default
|
|
|
1365 |
cat <<EOF >> /etc/anacrontab
|
667 |
franck |
1366 |
7 8 cron.MysqlDump nice /etc/cron.d/alcasar-mysql
|
|
|
1367 |
7 10 cron.logExport nice /etc/cron.d/alcasar-export_log
|
|
|
1368 |
7 15 cron.logClean nice /etc/cron.d/alcasar-clean_log
|
|
|
1369 |
7 20 cron.importClean nice /etc/cron.d/alcasar-clean_import
|
1 |
root |
1370 |
EOF
|
667 |
franck |
1371 |
cat <<EOF > /etc/cron.d/alcasar-clean_log
|
713 |
franck |
1372 |
# suppression des fichiers de logs de plus d'un an (tous les lundi à 4h30)
|
865 |
richard |
1373 |
30 4 * * 1 root $DIR_DEST_BIN/alcasar-log.sh --clean
|
1 |
root |
1374 |
EOF
|
811 |
richard |
1375 |
cat <<EOF > /etc/cron.d/alcasar-mysql
|
868 |
richard |
1376 |
# Contrôle, réparation et export de la base des usagers (tous les lundi à 4h45)
|
955 |
richard |
1377 |
45 4 * * 1 root $DIR_DEST_SBIN/alcasar-mysql.sh --dump
|
905 |
franck |
1378 |
# Nettoyage des utilisateurs dont la date d'expiration du compte est supérieure à 7 jours
|
917 |
franck |
1379 |
40 4 * * * root /usr/local/sbin/alcasar-mysql.sh --expire_user 2>&1 >/dev/null
|
1 |
root |
1380 |
EOF
|
667 |
franck |
1381 |
cat <<EOF > /etc/cron.d/alcasar-export_log
|
713 |
franck |
1382 |
# export des log squid, firewall et apache (tous les lundi à 5h00)
|
865 |
richard |
1383 |
00 5 * * 1 root $DIR_DEST_BIN/alcasar-log.sh --export
|
1 |
root |
1384 |
EOF
|
952 |
franck |
1385 |
cat <<EOF > /etc/cron.d/alcasar-archive
|
|
|
1386 |
# Archive des logs et de la base de données (tous les lundi à 5h35)
|
|
|
1387 |
35 5 * * 1 root $DIR_DEST_BIN/alcasar-archive.sh --now
|
|
|
1388 |
EOF
|
1 |
root |
1389 |
cat << EOF > /etc/cron.d/awstats
|
713 |
franck |
1390 |
# mise à jour des stats de consultation WEB toutes les 30'
|
419 |
franck |
1391 |
*/30 * * * * root $DIR_ACC/awstats/awstats.pl -config=localhost -update >/dev/null 2>&1
|
1 |
root |
1392 |
EOF
|
667 |
franck |
1393 |
cat << EOF > /etc/cron.d/alcasar-clean_import
|
713 |
franck |
1394 |
# suppression des fichiers de mots de passe lors d'imports massifs par fichier de plus de 24h
|
503 |
richard |
1395 |
30 * * * * root $DIR_DEST_BIN/alcasar-import-clean.sh
|
168 |
franck |
1396 |
EOF
|
722 |
franck |
1397 |
cat << EOF > /etc/cron.d/alcasar-distrib-updates
|
|
|
1398 |
# mise à jour automatique de la distribution tous les jours 3h30
|
762 |
franck |
1399 |
30 3 * * * root /usr/sbin/urpmi --auto-update --auto 2>&1
|
722 |
franck |
1400 |
EOF
|
1 |
root |
1401 |
# mise à jour des stats de connexion (accounting). Scripts provenant de "dialupadmin" (rpm freeradius-web) (cf. wiki.freeradius.org/Dialup_admin).
|
|
|
1402 |
# on écrase le crontab d'origine installé par le RPM "freeradius-web" (bug remonté à qa.mandriva.com : 46739).
|
|
|
1403 |
# 'tot_stats' (tout les jours à 01h01) : aggrégat des connexions journalières par usager (renseigne la table 'totacct')
|
|
|
1404 |
# 'monthly_tot_stat' (tous les jours à 01h05) : aggrégat des connexions mensuelles par usager (renseigne la table 'mtotacct')
|
|
|
1405 |
# 'truncate_raddact' (tous les 1er du mois à 01h10) : supprime les entrées journalisées plus vieilles que '$back_days' jours (défini ci-après)
|
|
|
1406 |
# 'clean_radacct' (tous les 1er du mois à 01h15) : ferme les session ouvertes de plus de '$back_days' jours (défini ci-après)
|
|
|
1407 |
$SED "s?^\$back_days.*?\$back_days = 365;?g" /usr/bin/truncate_radacct
|
|
|
1408 |
$SED "s?^\$back_days.*?\$back_days = 30;?g" /usr/bin/clean_radacct
|
|
|
1409 |
rm -f /etc/cron.daily/freeradius-web
|
|
|
1410 |
rm -f /etc/cron.monthly/freeradius-web
|
|
|
1411 |
cat << EOF > /etc/cron.d/freeradius-web
|
|
|
1412 |
1 1 * * * root /usr/bin/tot_stats > /dev/null 2>&1
|
|
|
1413 |
5 1 * * * root /usr/bin/monthly_tot_stats > /dev/null 2>&1
|
|
|
1414 |
10 1 1 * * root /usr/bin/truncate_radacct > /dev/null 2>&1
|
|
|
1415 |
15 1 1 * * root /usr/bin/clean_radacct > /dev/null 2>&1
|
|
|
1416 |
EOF
|
671 |
franck |
1417 |
cat << EOF > /etc/cron.d/alcasar-watchdog
|
713 |
franck |
1418 |
# activation du "chien de garde" (watchdog) toutes les 3'
|
1 |
root |
1419 |
*/3 * * * * root $DIR_DEST_BIN/alcasar-watchdog.sh > /dev/null 2>&1
|
|
|
1420 |
EOF
|
808 |
franck |
1421 |
# activation du "chien de garde des services" (watchdog) toutes les 18'
|
|
|
1422 |
cat << EOF > /etc/cron.d/alcasar-daemon-watchdog
|
|
|
1423 |
# activation du "chien de garde" (daemon-watchdog) toutes les 18'
|
|
|
1424 |
*/18 * * * * root $DIR_DEST_BIN/alcasar-daemon.sh > /dev/null 2>&1
|
|
|
1425 |
EOF
|
522 |
richard |
1426 |
# suppression des crons usagers
|
|
|
1427 |
rm -f /var/spool/cron/*
|
1 |
root |
1428 |
} # End cron
|
|
|
1429 |
|
|
|
1430 |
##################################################################
|
|
|
1431 |
## Fonction post_install ##
|
|
|
1432 |
## - Modification des bannières (locales et ssh) et des prompts ##
|
|
|
1433 |
## - Installation de la structure de chiffrement pour root ##
|
|
|
1434 |
## - Mise en place du sudoers et de la sécurité sur les fichiers##
|
|
|
1435 |
## - Mise en place du la rotation des logs ##
|
5 |
franck |
1436 |
## - Configuration dans le cas d'une mise à jour ##
|
1 |
root |
1437 |
##################################################################
|
|
|
1438 |
post_install()
|
|
|
1439 |
{
|
|
|
1440 |
# adaptation du script "chien de garde" (watchdog)
|
376 |
franck |
1441 |
$SED "s?^EXTIF=.*?EXTIF=\"$EXTIF\"?g" $DIR_DEST_BIN/alcasar-watchdog.sh
|
|
|
1442 |
$SED "s?^INTIF=.*?INTIF=\"$INTIF\"?g" $DIR_DEST_BIN/alcasar-watchdog.sh
|
1 |
root |
1443 |
# création de la bannière locale
|
|
|
1444 |
[ -e /etc/mandriva-release.default ] || cp /etc/mandriva-release /etc/mandriva-release.default
|
589 |
richard |
1445 |
cp -f $DIR_CONF/banner /etc/mandriva-release
|
|
|
1446 |
echo " V$VERSION" >> /etc/mandriva-release
|
1 |
root |
1447 |
# création de la bannière SSH
|
|
|
1448 |
cp /etc/mandriva-release /etc/ssh/alcasar-banner-ssh
|
5 |
franck |
1449 |
chmod 644 /etc/ssh/alcasar-banner-ssh ; chown root:root /etc/ssh/alcasar-banner-ssh
|
1 |
root |
1450 |
[ -e /etc/ssh/sshd_config.default ] || cp /etc/ssh/sshd_config /etc/ssh/sshd_config.default
|
|
|
1451 |
$SED "s?^Banner.*?Banner /etc/ssh/alcasar-banner-ssh?g" /etc/ssh/sshd_config
|
|
|
1452 |
$SED "s?^#Banner.*?Banner /etc/ssh/alcasar-banner-ssh?g" /etc/ssh/sshd_config
|
793 |
richard |
1453 |
# postfix banner anonymisation
|
|
|
1454 |
$SED "s?^smtpd_banner =.*?smtpd_banner = $myhostname ESMTP?g" /etc/postfix/main.cf
|
604 |
richard |
1455 |
# sshd écoute côté LAN et WAN
|
1 |
root |
1456 |
$SED "s?^#ListenAddress 0\.0\.0\.0?ListenAddress $PRIVATE_IP?g" /etc/ssh/sshd_config
|
604 |
richard |
1457 |
$SED "/^ListenAddress $PRIVATE_IP/a\ListenAddress $PUBLIC_IP" /etc/ssh/sshd_config
|
860 |
richard |
1458 |
# Put the default value in conf file (sshd, QOS and protocols/dns/ are off)(web antivirus is on)
|
1 |
root |
1459 |
/sbin/chkconfig --del sshd
|
628 |
richard |
1460 |
echo "SSH=off" >> $CONF_FILE
|
694 |
franck |
1461 |
echo 'Admin_from_IP="0.0.0.0/0.0.0.0"' >> $CONF_FILE
|
628 |
richard |
1462 |
echo "QOS=off" >> $CONF_FILE
|
|
|
1463 |
echo "LDAP=off" >> $CONF_FILE
|
786 |
richard |
1464 |
echo "LDAP_IP=0.0.0.0/0.0.0.0" >> $CONF_FILE
|
885 |
richard |
1465 |
echo "WEB_ANTIVIRUS=on" >> $CONF_FILE
|
628 |
richard |
1466 |
echo "PROTOCOLS_FILTERING=off" >> $CONF_FILE
|
|
|
1467 |
echo "DNS_FILTERING=off" >> $CONF_FILE
|
885 |
richard |
1468 |
echo "YOUTUBE_ID=ABCD1234567890abcdef" >> $CONF_FILE
|
1 |
root |
1469 |
# Coloration des prompts
|
|
|
1470 |
[ -e /etc/bashrc.default ] || cp /etc/bashrc /etc/bashrc.default
|
5 |
franck |
1471 |
cp -f $DIR_CONF/bashrc /etc/. ; chmod 644 /etc/bashrc ; chown root:root /etc/bashrc
|
630 |
franck |
1472 |
$SED "s?^ORGANISME.*?ORGANISME=$ORGANISME?g" /etc/bashrc
|
1 |
root |
1473 |
# Droits d'exécution pour utilisateur apache et sysadmin
|
|
|
1474 |
[ -e /etc/sudoers.default ] || cp /etc/sudoers /etc/sudoers.default
|
5 |
franck |
1475 |
cp -f $DIR_CONF/sudoers /etc/. ; chmod 440 /etc/sudoers ; chown root:root /etc/sudoers
|
629 |
richard |
1476 |
$SED "s?^Host_Alias.*?Host_Alias LAN_ORG=$PRIVATE_NETWORK/$PRIVATE_NETMASK,localhost #réseau de l'organisme?g" /etc/sudoers
|
132 |
franck |
1477 |
# prise en compte de la rotation des logs sur 1 an (concerne mysql, httpd, dansguardian, squid, radiusd, ulogd)
|
1 |
root |
1478 |
cp -f $DIR_CONF/logrotate.d/* /etc/logrotate.d/
|
|
|
1479 |
chmod 644 /etc/logrotate.d/*
|
714 |
franck |
1480 |
# rectification sur versions précédentes de la compression des logs
|
706 |
franck |
1481 |
$SED "s?^delaycompress.*?#&?g" /etc/logrotate.conf
|
|
|
1482 |
# actualisation des fichiers logs compressés
|
714 |
franck |
1483 |
for dir in firewall squid dansguardian httpd
|
706 |
franck |
1484 |
do
|
714 |
franck |
1485 |
find /var/log/$dir -type f -name *.log-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9] -exec gzip {} \;
|
706 |
franck |
1486 |
done
|
|
|
1487 |
# export des logs en 'retard' dans /var/Save/logs
|
865 |
richard |
1488 |
/usr/local/bin/alcasar-log.sh --export
|
1 |
root |
1489 |
# processus lancés par défaut au démarrage
|
796 |
richard |
1490 |
for i in ntpd iptables ulogd dnsmasq squid chilli httpd radiusd netfs mysqld dansguardian havp freshclam
|
1 |
root |
1491 |
do
|
|
|
1492 |
/sbin/chkconfig --add $i
|
|
|
1493 |
done
|
953 |
franck |
1494 |
# On rajoute une tempo pour relancer radius après le redémarrage de mysqld (bug en cours d'analyse)
|
|
|
1495 |
cat << EOF > /etc/rc.local
|
|
|
1496 |
#!/bin/sh
|
|
|
1497 |
#
|
|
|
1498 |
### BEGIN INIT INFO
|
|
|
1499 |
# Provides: rc.local
|
|
|
1500 |
# X-Mandriva-Compat-Mode
|
|
|
1501 |
# Default-Start: 2 3 4 5
|
|
|
1502 |
# Short-Description: Local initialization script
|
|
|
1503 |
# Description: This script will be executed *after* all the other init scripts.
|
|
|
1504 |
# You can put your own initialization stuff in here if you don't
|
|
|
1505 |
# want to do the full Sys V style init stuff.
|
|
|
1506 |
### END INIT INFO
|
|
|
1507 |
|
|
|
1508 |
/etc/init.d/mysqld restart
|
|
|
1509 |
sleep 1
|
|
|
1510 |
/etc/init.d/radiusd restart
|
|
|
1511 |
|
|
|
1512 |
touch /var/lock/subsys/local
|
|
|
1513 |
EOF
|
595 |
richard |
1514 |
# pour éviter les alertes de dépendance entre service.
|
384 |
richard |
1515 |
$SED "s?^# Required-Start.*?# Required-Start: \$local_fs \$network?g" /etc/init.d/mysqld
|
497 |
richard |
1516 |
$SED "s?^# Required-Stop.*?# Required-Stop: \$local_fs \$network?g" /etc/init.d/mysqld
|
595 |
richard |
1517 |
$SED "s?^# Should-Start.*?# Should-Start: radiusd ldap?g" /etc/init.d/httpd
|
|
|
1518 |
$SED "s?^# Should-Stop.*?# Should-Stop: radiusd ldap?g" /etc/init.d/httpd
|
306 |
richard |
1519 |
# On affecte le niveau de sécurité du système : type "fileserver"
|
235 |
richard |
1520 |
$SED "s?BASE_LEVEL=.*?BASE_LEVEL=fileserver?g" /etc/security/msec/security.conf
|
306 |
richard |
1521 |
# On supprime la vérification du mode promiscious des interfaces réseaux ( nombreuses alertes sur eth1 dûes à Tun0 )
|
235 |
richard |
1522 |
$SED "s?CHECK_PROMISC=.*?CHECK_PROMISC=no?g" /etc/security/msec/level.fileserver
|
568 |
richard |
1523 |
# On applique les préconisations ANSSI (sysctl + msec quand c'est possible)
|
|
|
1524 |
# Apply French Security Agency rules (sysctl + msec when possible)
|
|
|
1525 |
# ignorer les broadcast ICMP. (attaque smurf)
|
|
|
1526 |
$SED "s?^ACCEPT_BROADCASTED_ICMP_ECHO=.*?ACCEPT_BROADCASTED_ICMP_ECHO=no?g" /etc/security/msec/level.fileserver
|
|
|
1527 |
sysctl -w net.ipv4.icmp_echo_ignore_broadcasts=1
|
|
|
1528 |
# ignorer les erreurs ICMP bogus
|
|
|
1529 |
$SED "s?^ACCEPT_BOGUS_ERROR_RESPONSES=.*?ACCEPT_BOGUS_ERROR_RESPONSES=no?g" /etc/security/msec/level.fileserver
|
|
|
1530 |
sysctl -w net.ipv4.icmp_ignore_bogus_error_responses=1
|
595 |
richard |
1531 |
# désactiver l'envoi et la réponse aux ICMP redirects
|
679 |
richard |
1532 |
sysctl -w net.ipv4.conf.all.accept_redirects=0
|
568 |
richard |
1533 |
accept_redirect=`grep accept_redirect /etc/sysctl.conf|wc -l`
|
|
|
1534 |
if [ "$accept_redirect" == "0" ]
|
|
|
1535 |
then
|
679 |
richard |
1536 |
echo "net.ipv4.conf.all.accept_redirects = 0" >> /etc/sysctl.conf
|
|
|
1537 |
else
|
|
|
1538 |
$SED "s?accept_redirects.*?accept_redirects = 0?g" /etc/sysctl.conf
|
568 |
richard |
1539 |
fi
|
679 |
richard |
1540 |
sysctl -w net.ipv4.conf.all.send_redirects=0
|
568 |
richard |
1541 |
send_redirect=`grep send_redirect /etc/sysctl.conf|wc -l`
|
|
|
1542 |
if [ "$send_redirect" == "0" ]
|
|
|
1543 |
then
|
679 |
richard |
1544 |
echo "net.ipv4.conf.all.send_redirects = 0" >> /etc/sysctl.conf
|
|
|
1545 |
else
|
|
|
1546 |
$SED "s?send_redirects.*?send_redirects = 0?g" /etc/sysctl.conf
|
568 |
richard |
1547 |
fi
|
|
|
1548 |
# activer les SYN Cookies (attaque syn flood)
|
679 |
richard |
1549 |
sysctl -w net.ipv4.tcp_syncookies=1
|
568 |
richard |
1550 |
tcp_syncookies=`grep tcp_syncookies /etc/sysctl.conf|wc -l`
|
|
|
1551 |
if [ "$tcp_syncookies" == "0" ]
|
|
|
1552 |
then
|
679 |
richard |
1553 |
echo "net.ipv4.tcp_syncookies = 1" >> /etc/sysctl.conf
|
|
|
1554 |
else
|
|
|
1555 |
$SED "s?tcp_syncookies.*?tcp_syncookies = 1?g" /etc/sysctl.conf
|
568 |
richard |
1556 |
fi
|
595 |
richard |
1557 |
# activer l'antispoofing niveau Noyau
|
568 |
richard |
1558 |
$SED "s?^ENABLE_IP_SPOOFING_PROTECTION.*?ENABLE_IP_SPOOFING_PROTECTION=yes?g" /etc/security/msec/level.fileserver
|
|
|
1559 |
sysctl -w net.ipv4.conf.all.rp_filter=1
|
|
|
1560 |
# ignorer le source routing
|
679 |
richard |
1561 |
sysctl -w net.ipv4.conf.all.accept_source_route=0
|
568 |
richard |
1562 |
accept_source_route=`grep accept_source_route /etc/sysctl.conf|wc -l`
|
|
|
1563 |
if [ "$accept_source_route" == "0" ]
|
|
|
1564 |
then
|
679 |
richard |
1565 |
echo "net.ipv4.conf.all.accept_source_route = 0" >> /etc/sysctl.conf
|
|
|
1566 |
else
|
|
|
1567 |
$SED "s?accept_source_route.*?accept_source_route = 0?g" /etc/sysctl.conf
|
568 |
richard |
1568 |
fi
|
679 |
richard |
1569 |
# réglage du timer de maintien de suivi de session à 1h (3600s) au lieu de 5 semaines
|
|
|
1570 |
sysctl -w net.netfilter.nf_conntrack_tcp_timeout_established=3600
|
|
|
1571 |
timeout_established=`grep timeout_established /etc/sysctl.conf|wc -l`
|
|
|
1572 |
if [ "$timeout_established" == "0" ]
|
|
|
1573 |
then
|
|
|
1574 |
echo "net.netfilter.nf_conntrack_tcp_timeout_established = 3600" >> /etc/sysctl.conf
|
|
|
1575 |
else
|
793 |
richard |
1576 |
$SED "s?timeout_established.*?timeout_established = 3600?g" /etc/sysctl.conf
|
679 |
richard |
1577 |
fi
|
|
|
1578 |
# suppression des log_martians (ALCASAR est souvent entre deux réseaux en adressage privée)
|
568 |
richard |
1579 |
sysctl -w net.ipv4.conf.all.log_martians=0
|
|
|
1580 |
$SED "s?^ENABLE_LOG_STRANGE_PACKETS=.*?ENABLE_LOG_STRANGE_PACKETS=no?g" /etc/security/msec/level.fileserver
|
|
|
1581 |
|
793 |
richard |
1582 |
|
306 |
richard |
1583 |
# On supprime la gestion du <CTRL>+<ALT>+<SUPPR> et des Magic SysReq Keys
|
|
|
1584 |
$SED "s?^ALLOW_REBOOT=.*?ALLOW_REBOOT=no?g" /etc/security/msec/level.fileserver
|
1 |
root |
1585 |
# On mets en place la sécurité sur les fichiers
|
|
|
1586 |
# des modif par rapport à radius update
|
|
|
1587 |
cat <<EOF > /etc/security/msec/perm.local
|
|
|
1588 |
/var/log/firewall/ root.apache 750
|
|
|
1589 |
/var/log/firewall/* root.apache 640
|
|
|
1590 |
/etc/security/msec/perm.local root.root 640
|
|
|
1591 |
/etc/security/msec/level.local root.root 640
|
|
|
1592 |
/etc/freeradius-web root.apache 750
|
|
|
1593 |
/etc/freeradius-web/admin.conf root.apache 640
|
|
|
1594 |
/etc/freeradius-web/config.php root.apache 640
|
|
|
1595 |
/etc/raddb/dictionnary root.radius 640
|
|
|
1596 |
/etc/raddb/ldap.attrmap root.radius 640
|
|
|
1597 |
/etc/raddb/hints root.radius 640
|
|
|
1598 |
/etc/raddb/huntgroups root.radius 640
|
|
|
1599 |
/etc/raddb/attrs.access_reject root.radius 640
|
|
|
1600 |
/etc/raddb/attrs.accounting_response root.radius 640
|
|
|
1601 |
/etc/raddb/acct_users root.radius 640
|
|
|
1602 |
/etc/raddb/preproxy_users root.radius 640
|
|
|
1603 |
/etc/raddb/modules/ldap radius.apache 660
|
|
|
1604 |
/etc/raddb/sites-available/alcasar radius.apache 660
|
|
|
1605 |
/etc/pki/* root.apache 750
|
|
|
1606 |
EOF
|
|
|
1607 |
/usr/sbin/msec
|
59 |
richard |
1608 |
# modification /etc/inittab
|
|
|
1609 |
[ -e /etc/inittab.default ] || cp /etc/inittab /etc/inittab.default
|
60 |
richard |
1610 |
# On ne garde que 3 terminaux
|
59 |
richard |
1611 |
$SED "s?^4.*?#&?g" /etc/inittab
|
|
|
1612 |
$SED "s?^5.*?#&?g" /etc/inittab
|
|
|
1613 |
$SED "s?^6.*?#&?g" /etc/inittab
|
470 |
richard |
1614 |
# On limite le temps d'attente de grub (3s) et on change la résolution d'écran
|
|
|
1615 |
$SED "s?^timeout.*?timeout 3?g" /boot/grub/menu.lst
|
|
|
1616 |
$SED "s?^kernel.*?& vga=791?g" /boot/grub/menu.lst
|
532 |
richard |
1617 |
# On supprime les services et les utilisateurs inutiles
|
793 |
richard |
1618 |
for svc in alsa sound dm atd bootlogd stop-bootlogd
|
532 |
richard |
1619 |
do
|
|
|
1620 |
/sbin/chkconfig --del $svc
|
|
|
1621 |
done
|
|
|
1622 |
for rm_users in avahi-autoipd avahi icapd
|
|
|
1623 |
do
|
|
|
1624 |
user=`cat /etc/passwd|grep $rm_users|cut -d":" -f1`
|
|
|
1625 |
if [ "$user" == "$rm_users" ]
|
|
|
1626 |
then
|
|
|
1627 |
/usr/sbin/userdel -f $rm_users
|
|
|
1628 |
fi
|
|
|
1629 |
done
|
628 |
richard |
1630 |
# Load and update the previous conf file
|
5 |
franck |
1631 |
if [ "$mode" = "update" ]
|
|
|
1632 |
then
|
389 |
franck |
1633 |
$DIR_DEST_BIN/alcasar-conf.sh --load
|
628 |
richard |
1634 |
$SED "s?^INSTALL_DATE=.*?INSTALL_DATE=$DATE?g" $CONF_FILE
|
|
|
1635 |
$SED "s?^VERSION=.*?VERSION=$VERSION?g" $CONF_FILE
|
5 |
franck |
1636 |
fi
|
595 |
richard |
1637 |
rm -f /tmp/alcasar-conf*
|
434 |
richard |
1638 |
chown -R root:apache $DIR_DEST_ETC/*
|
512 |
richard |
1639 |
chmod -R 660 $DIR_DEST_ETC/*
|
434 |
richard |
1640 |
chmod ug+x $DIR_DEST_ETC/digest $DIR_DEST_ETC/alcasar-dnsfilter*
|
1 |
root |
1641 |
cd $DIR_INSTALL
|
5 |
franck |
1642 |
echo ""
|
1 |
root |
1643 |
echo "#############################################################################"
|
638 |
richard |
1644 |
if [ $Lang == "fr" ]
|
|
|
1645 |
then
|
|
|
1646 |
echo "# Fin d'installation d'ALCASAR #"
|
|
|
1647 |
echo "# #"
|
|
|
1648 |
echo "# Application Libre pour le Contrôle Authentifié et Sécurisé #"
|
|
|
1649 |
echo "# des Accès au Réseau ( ALCASAR ) #"
|
|
|
1650 |
echo "# #"
|
|
|
1651 |
echo "#############################################################################"
|
|
|
1652 |
echo
|
|
|
1653 |
echo "- ALCASAR sera fonctionnel après redémarrage du système"
|
|
|
1654 |
echo
|
|
|
1655 |
echo "- Lisez attentivement la documentation d'exploitation"
|
|
|
1656 |
echo
|
|
|
1657 |
echo "- Le centre de controle d'ALCASAR (ACC) est à l'adresse http://alcasar"
|
|
|
1658 |
echo
|
|
|
1659 |
echo " Appuyez sur 'Entrée' pour continuer"
|
|
|
1660 |
else
|
|
|
1661 |
echo "# Enf of ALCASAR install process #"
|
|
|
1662 |
echo "# #"
|
|
|
1663 |
echo "# Application Libre pour le Contrôle Authentifié et Sécurisé #"
|
|
|
1664 |
echo "# des Accès au Réseau ( ALCASAR ) #"
|
|
|
1665 |
echo "# #"
|
|
|
1666 |
echo "#############################################################################"
|
|
|
1667 |
echo
|
|
|
1668 |
echo "- The system will be rebooted in order to operate ALCASAR"
|
|
|
1669 |
echo
|
|
|
1670 |
echo "- Read the exploitation documentation"
|
|
|
1671 |
echo
|
|
|
1672 |
echo "- The ALCASAR Control Center (ACC) is at http://alcasar"
|
|
|
1673 |
echo
|
|
|
1674 |
echo " Hit 'Enter' to continue"
|
|
|
1675 |
fi
|
815 |
richard |
1676 |
sleep 2
|
|
|
1677 |
if [ "$mode" != "update" ]
|
820 |
richard |
1678 |
then
|
815 |
richard |
1679 |
read a
|
|
|
1680 |
fi
|
774 |
richard |
1681 |
clear
|
|
|
1682 |
# Apply and save the firewall rules
|
490 |
richard |
1683 |
sh $DIR_DEST_BIN/alcasar-iptables.sh
|
|
|
1684 |
sleep 2
|
1 |
root |
1685 |
reboot
|
|
|
1686 |
} # End post_install ()
|
|
|
1687 |
|
|
|
1688 |
#################################
|
|
|
1689 |
# Boucle principale du script #
|
|
|
1690 |
#################################
|
832 |
richard |
1691 |
dir_exec=`dirname "$0"`
|
|
|
1692 |
if [ $dir_exec != "." ]
|
|
|
1693 |
then
|
|
|
1694 |
echo "Lancez ce programme depuis le répertoire de l'archive d'ALCASAR"
|
|
|
1695 |
echo "Launch this program from the ALCASAR archive directory"
|
|
|
1696 |
exit 0
|
|
|
1697 |
fi
|
|
|
1698 |
VERSION=`cat $DIR_INSTALL/VERSION`
|
291 |
franck |
1699 |
usage="Usage: alcasar.sh {-i or --install} | {-u or --uninstall}"
|
1 |
root |
1700 |
nb_args=$#
|
|
|
1701 |
args=$1
|
|
|
1702 |
if [ $nb_args -eq 0 ]
|
|
|
1703 |
then
|
|
|
1704 |
nb_args=1
|
|
|
1705 |
args="-h"
|
|
|
1706 |
fi
|
|
|
1707 |
case $args in
|
|
|
1708 |
-\? | -h* | --h*)
|
|
|
1709 |
echo "$usage"
|
|
|
1710 |
exit 0
|
|
|
1711 |
;;
|
291 |
franck |
1712 |
-i | --install)
|
959 |
franck |
1713 |
license
|
5 |
franck |
1714 |
header_install
|
29 |
richard |
1715 |
testing
|
597 |
richard |
1716 |
# Test if ALCASAR is already installed
|
5 |
franck |
1717 |
if [ -e $DIR_WEB/VERSION ]
|
1 |
root |
1718 |
then
|
460 |
richard |
1719 |
actual_version=`cat $DIR_WEB/VERSION`
|
595 |
richard |
1720 |
if [ $Lang == "fr" ]
|
|
|
1721 |
then echo -n "La version "; echo -n $actual_version ; echo " d'ALCASAR est déjà installée";
|
|
|
1722 |
else echo -n "ALCASAR Version "; echo -n $actual_version ; echo " is already installed";
|
|
|
1723 |
fi
|
5 |
franck |
1724 |
response=0
|
460 |
richard |
1725 |
PTN='^[oOnNyY]$'
|
580 |
richard |
1726 |
until [[ $(expr $response : $PTN) -gt 0 ]]
|
5 |
franck |
1727 |
do
|
595 |
richard |
1728 |
if [ $Lang == "fr" ]
|
|
|
1729 |
then echo -n "Voulez-vous effectuer une mise à jour (O/n)? ";
|
|
|
1730 |
else echo -n "Do you want to update (Y/n)?";
|
|
|
1731 |
fi
|
5 |
franck |
1732 |
read response
|
|
|
1733 |
done
|
597 |
richard |
1734 |
if [ "$response" = "n" ] || [ "$response" = "N" ]
|
5 |
franck |
1735 |
then
|
597 |
richard |
1736 |
rm -f /tmp/alcasar-conf*
|
|
|
1737 |
else
|
510 |
richard |
1738 |
RUNNING_VERSION=`cat $DIR_WEB/VERSION|cut -d" " -f1`
|
|
|
1739 |
MAJ_RUNNING_VERSION=`echo $RUNNING_VERSION|cut -d"." -f1`
|
|
|
1740 |
MIN_RUNNING_VERSION=`echo $RUNNING_VERSION|cut -d"." -f2|cut -c1`
|
|
|
1741 |
UPD_RUNNING_VERSION=`echo $RUNNING_VERSION|cut -d"." -f3`
|
636 |
richard |
1742 |
# Create a backup of running version importants files
|
5 |
franck |
1743 |
chmod u+x $DIR_SCRIPTS/alcasar-conf.sh
|
389 |
franck |
1744 |
$DIR_SCRIPTS/alcasar-conf.sh --create
|
532 |
richard |
1745 |
mode="update"
|
5 |
franck |
1746 |
fi
|
1 |
root |
1747 |
fi
|
595 |
richard |
1748 |
# RPMs install
|
|
|
1749 |
$DIR_SCRIPTS/alcasar-urpmi.sh
|
|
|
1750 |
if [ "$?" != "0" ]
|
1 |
root |
1751 |
then
|
595 |
richard |
1752 |
exit 0
|
|
|
1753 |
fi
|
|
|
1754 |
if [ -e $DIR_WEB/VERSION ]
|
|
|
1755 |
then
|
597 |
richard |
1756 |
# Uninstall the running version
|
532 |
richard |
1757 |
$DIR_SCRIPTS/sbin/alcasar-uninstall.sh
|
595 |
richard |
1758 |
fi
|
636 |
richard |
1759 |
# Test if manual update
|
597 |
richard |
1760 |
if [ -e /tmp/alcasar-conf.tar.gz ] && [ "$mode" != "update" ]
|
595 |
richard |
1761 |
then
|
636 |
richard |
1762 |
header_install
|
595 |
richard |
1763 |
if [ $Lang == "fr" ]
|
636 |
richard |
1764 |
then echo "Le fichier de configuration d'une ancienne version a été trouvé";
|
|
|
1765 |
else echo "The configuration file of an old version has been found";
|
595 |
richard |
1766 |
fi
|
597 |
richard |
1767 |
response=0
|
|
|
1768 |
PTN='^[oOnNyY]$'
|
|
|
1769 |
until [[ $(expr $response : $PTN) -gt 0 ]]
|
|
|
1770 |
do
|
|
|
1771 |
if [ $Lang == "fr" ]
|
|
|
1772 |
then echo -n "Voulez-vous l'utiliser (O/n)? ";
|
|
|
1773 |
else echo -n "Do you want to use it (Y/n)?";
|
|
|
1774 |
fi
|
|
|
1775 |
read response
|
|
|
1776 |
if [ "$response" = "n" ] || [ "$response" = "N" ]
|
|
|
1777 |
then rm -f /tmp/alcasar-conf*
|
|
|
1778 |
fi
|
|
|
1779 |
done
|
|
|
1780 |
fi
|
636 |
richard |
1781 |
# Test if update
|
597 |
richard |
1782 |
if [ -e /tmp/alcasar-conf.tar.gz ]
|
|
|
1783 |
then
|
|
|
1784 |
if [ $Lang == "fr" ]
|
|
|
1785 |
then echo "#### Installation avec mise à jour ####";
|
|
|
1786 |
else echo "#### Installation with update ####";
|
|
|
1787 |
fi
|
636 |
richard |
1788 |
# Extract the central configuration file
|
637 |
richard |
1789 |
tar -xf /tmp/alcasar-conf.tar.gz conf/etc/alcasar.conf
|
|
|
1790 |
ORGANISME=`grep ORGANISM conf/etc/alcasar.conf|cut -d"=" -f2`
|
5 |
franck |
1791 |
mode="update"
|
|
|
1792 |
else
|
|
|
1793 |
mode="install"
|
1 |
root |
1794 |
fi
|
604 |
richard |
1795 |
for func in init network gestion AC init_db param_radius param_web_radius param_chilli param_squid param_dansguardian antivirus param_ulogd param_awstats param_dnsmasq BL cron post_install
|
5 |
franck |
1796 |
do
|
|
|
1797 |
$func
|
735 |
richard |
1798 |
# echo "*** 'debug' : end of function $func ***"; read a
|
14 |
richard |
1799 |
done
|
5 |
franck |
1800 |
;;
|
291 |
franck |
1801 |
-u | --uninstall)
|
5 |
franck |
1802 |
if [ ! -e $DIR_DEST_SBIN/alcasar-uninstall.sh ]
|
1 |
root |
1803 |
then
|
597 |
richard |
1804 |
if [ $Lang == "fr" ]
|
|
|
1805 |
then echo "ALCASAR n'est pas installé!";
|
|
|
1806 |
else echo "ALCASAR isn't installed!";
|
|
|
1807 |
fi
|
1 |
root |
1808 |
exit 0
|
|
|
1809 |
fi
|
5 |
franck |
1810 |
response=0
|
|
|
1811 |
PTN='^[oOnN]$'
|
580 |
richard |
1812 |
until [[ $(expr $response : $PTN) -gt 0 ]]
|
5 |
franck |
1813 |
do
|
597 |
richard |
1814 |
if [ $Lang == "fr" ]
|
|
|
1815 |
then echo -n "Voulez-vous créer le fichier de configuration de la version actuelle (0/n)? ";
|
854 |
richard |
1816 |
else echo -n "Do you want to create the running version configuration file (Y/n)? ";
|
597 |
richard |
1817 |
fi
|
5 |
franck |
1818 |
read response
|
|
|
1819 |
done
|
597 |
richard |
1820 |
if [ "$reponse" = "o" ] || [ "$reponse" = "O" ] || [ "$response" = "Y" ] || [ "$response" = "y" ]
|
1 |
root |
1821 |
then
|
389 |
franck |
1822 |
$DIR_SCRIPT/alcasar-conf.sh --create
|
498 |
richard |
1823 |
else
|
|
|
1824 |
rm -f /tmp/alcasar-conf*
|
1 |
root |
1825 |
fi
|
597 |
richard |
1826 |
# Uninstall the running version
|
65 |
richard |
1827 |
$DIR_SCRIPTS/sbin/alcasar-uninstall.sh
|
1 |
root |
1828 |
;;
|
|
|
1829 |
*)
|
|
|
1830 |
echo "Argument inconnu :$1";
|
460 |
richard |
1831 |
echo "Unknown argument :$1";
|
1 |
root |
1832 |
echo "$usage"
|
|
|
1833 |
exit 1
|
|
|
1834 |
;;
|
|
|
1835 |
esac
|
10 |
franck |
1836 |
# end of script
|
366 |
franck |
1837 |
|