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