672 |
richard |
1 |
#/bin/bash
|
64 |
franck |
2 |
# $Id: alcasar-conf.sh 1961 2016-06-23 21:23:34Z richard $
|
672 |
richard |
3 |
|
|
|
4 |
# alcasar-conf.sh
|
865 |
richard |
5 |
# by REXY
|
672 |
richard |
6 |
# This script is distributed under the Gnu General Public License (GPL)
|
|
|
7 |
|
|
|
8 |
# Ce script permet la mise à jour ALCASAR
|
1758 |
richard |
9 |
# - création de l'archive des fichiers de configuration dans "/tmp/alcasar-conf.tar.gz" (alcasar-conf.sh -create)
|
|
|
10 |
# - chargement de l'archive de fichiers de configuration lors de la mise à jour d'un alcasar (alcasar-conf -load)
|
|
|
11 |
# - application des directives du fichier de conf central "/usr/local/etc/alcasar.conf" lors d'un changement de conf réseau à chaud (alcasar-conf -apply)
|
672 |
richard |
12 |
# This script allows ALCASAR update
|
1758 |
richard |
13 |
# - create the configuration files backup "/tmp/alcasar-conf.tar.gz" (alcasar-conf.sh -create)
|
|
|
14 |
# - load the bachup of configuration files during the update process (alcasar-conf -load)
|
|
|
15 |
# - apply ALCASAR central configuration file "/usr/local/etc/alcasar.conf" when hot modification is needed (alcasar-conf -apply)
|
672 |
richard |
16 |
|
865 |
richard |
17 |
new="$(date +%G%m%d-%Hh%M)" # date et heure des fichiers
|
806 |
richard |
18 |
fichier="alcasar-conf-$new.tar.gz" # nom du fichier de sauvegarde
|
8 |
franck |
19 |
DIR_UPDATE="/tmp/conf" # répertoire de stockage des fichier de conf pour une mise à jour
|
|
|
20 |
DIR_WEB="/var/www/html" # répertoire du centre de gestion
|
478 |
richard |
21 |
DIR_BIN="/usr/local/bin" # répertoire des scripts d'admin
|
346 |
richard |
22 |
DIR_ETC="/usr/local/etc" # répertoire des fichiers de conf
|
1946 |
richard |
23 |
DIR_BLACKLIST="/etc/dansguardian/lists/blacklists" # répertoire de la BL de Toulouse
|
628 |
richard |
24 |
CONF_FILE="$DIR_ETC/alcasar.conf" # main alcasar conf file
|
510 |
richard |
25 |
VERSION="/var/www/html/VERSION" # contient la version en cours
|
1469 |
richard |
26 |
EXTIF=`grep ^EXTIF= $CONF_FILE|cut -d"=" -f2` # EXTernal InterFace
|
|
|
27 |
INTIF=`grep ^INTIF= $CONF_FILE|cut -d"=" -f2` # INTernal InterFace
|
1890 |
franck |
28 |
MTU=`grep ^PUBLIC_MTU= $CONF_FILE|cut -d"=" -f2` # INTernal InterFace
|
|
|
29 |
DHCP_mode=`grep ^DHCP= $CONF_FILE|cut -d"=" -f2`
|
|
|
30 |
INT_DNS_mode=`grep ^INT_DNS_ACTIVE= $CONF_FILE|cut -d"=" -f2`
|
|
|
31 |
LDAP_mode=`grep ^LDAP= $CONF_FILE|cut -d"=" -f2`
|
628 |
richard |
32 |
HOSTNAME="alcasar"
|
369 |
richard |
33 |
DB_USER="radius"
|
504 |
richard |
34 |
radiuspwd=""
|
384 |
richard |
35 |
SED="/bin/sed -i"
|
510 |
richard |
36 |
RUNNING_VERSION=`cat $VERSION|cut -d" " -f1`
|
|
|
37 |
MAJ_RUNNING_VERSION=`echo $RUNNING_VERSION|cut -d"." -f1`
|
|
|
38 |
MIN_RUNNING_VERSION=`echo $RUNNING_VERSION|cut -d"." -f2|cut -c1`
|
|
|
39 |
UPD_RUNNING_VERSION=`echo $RUNNING_VERSION|cut -d"." -f3`
|
1564 |
richard |
40 |
DOMAIN=`grep DOMAIN $CONF_FILE|cut -d"=" -f2` 2>/dev/null
|
923 |
franck |
41 |
DOMAIN=${DOMAIN:=localdomain}
|
628 |
richard |
42 |
DATE=`date '+%d %B %Y - %Hh%M'`
|
|
|
43 |
private_network_calc ()
|
|
|
44 |
{
|
1060 |
richard |
45 |
PRIVATE_PREFIX=`/bin/ipcalc -p $PRIVATE_IP $PRIVATE_NETMASK |cut -d"=" -f2` # prefixe du réseau (ex. 24)
|
|
|
46 |
PRIVATE_NETWORK=`/bin/ipcalc -n $PRIVATE_IP $PRIVATE_NETMASK| cut -d"=" -f2` # @ réseau de consultation (ex.: 192.168.182.0)
|
|
|
47 |
PRIVATE_NETWORK_MASK=$PRIVATE_NETWORK/$PRIVATE_PREFIX # @ + masque du réseau de consult (192.168.182.0/24)
|
628 |
richard |
48 |
classe=$((PRIVATE_PREFIX/8)); classe_sup=`expr $classe + 1`; classe_sup_sup=`expr $classe + 2` # classes de réseau (ex.: 2=classe B, 3=classe C)
|
1060 |
richard |
49 |
PRIVATE_NETWORK_SHORT=`echo $PRIVATE_NETWORK | cut -d"." -f1-$classe`. # @ compatible hosts.allow et hosts.deny (ex.: 192.168.182.)
|
|
|
50 |
PRIVATE_BROADCAST=`/bin/ipcalc -b $PRIVATE_NETWORK_MASK | cut -d"=" -f2` # private network broadcast (ie.: 192.168.182.255)
|
|
|
51 |
private_network_ending=`echo $PRIVATE_NETWORK | cut -d"." -f$classe_sup` # last octet of LAN address
|
|
|
52 |
private_broadcast_ending=`echo $PRIVATE_BROADCAST | cut -d"." -f$classe_sup` # last octet of LAN broadcast
|
|
|
53 |
PRIVATE_FIRST_IP=`echo $PRIVATE_NETWORK | cut -d"." -f1-3`"."`expr $private_network_ending + 1` # First network address (ex.: 192.168.182.1)
|
|
|
54 |
PRIVATE_SECOND_IP=`echo $PRIVATE_NETWORK | cut -d"." -f1-3`"."`expr $private_network_ending + 2` # second network address (ex.: 192.168.182.2)
|
|
|
55 |
PRIVATE_LAST_IP=`echo $PRIVATE_BROADCAST | cut -d"." -f1-3`"."`expr $private_broadcast_ending - 1` # last network address (ex.: 192.168.182.254)
|
1581 |
richard |
56 |
PRIVATE_MAC=`/sbin/ip link show $INTIF | grep ether | cut -d" " -f6| sed 's/:/-/g'| awk '{print toupper($0)}'` # MAC address of INTIF
|
628 |
richard |
57 |
}
|
8 |
franck |
58 |
|
933 |
franck |
59 |
usage="Usage: alcasar-conf.sh {--create or -create} | {--load or -load} | {--apply or -apply}"
|
8 |
franck |
60 |
nb_args=$#
|
|
|
61 |
args=$1
|
|
|
62 |
if [ $nb_args -eq 0 ]
|
|
|
63 |
then
|
1890 |
franck |
64 |
nb_args=100:26:6C:
|
8 |
franck |
65 |
args="-h"
|
|
|
66 |
fi
|
|
|
67 |
case $args in
|
|
|
68 |
-\? | -h* | --h*)
|
|
|
69 |
echo "$usage"
|
|
|
70 |
exit 0
|
|
|
71 |
;;
|
389 |
franck |
72 |
--create|-create)
|
8 |
franck |
73 |
[ -d $DIR_UPDATE ] && rm -rf $DIR_UPDATE
|
|
|
74 |
mkdir $DIR_UPDATE
|
1916 |
franck |
75 |
# backup the users database (test to delete in future version)
|
1918 |
franck |
76 |
if [ -e $DIR_BIN/alcasar-mysql.sh ]; then
|
|
|
77 |
$DIR_BIN/alcasar-mysql.sh --dump
|
1916 |
franck |
78 |
else
|
|
|
79 |
/usr/local/sbin/alcasar-mysql.sh --dump
|
|
|
80 |
fi
|
1777 |
richard |
81 |
cp /var/Save/base/`ls -1t /var/Save/base|head -1` $DIR_UPDATE
|
1758 |
richard |
82 |
# backup the logo
|
8 |
franck |
83 |
cp -f $DIR_WEB/images/organisme.png $DIR_UPDATE
|
1912 |
richard |
84 |
# backup BL/WL custom files
|
1914 |
richard |
85 |
mkdir $DIR_UPDATE/custom_bl
|
|
|
86 |
cp -f /etc/dansguardian/lists/exceptioniplist $DIR_UPDATE/custom_bl/
|
|
|
87 |
cp -f /etc/dansguardian/lists/urlregexplist $DIR_UPDATE/custom_bl/
|
|
|
88 |
cp -f /etc/dansguardian/lists/exceptionsitelist $DIR_UPDATE/custom_bl/
|
|
|
89 |
cp -f /etc/dansguardian/lists/bannedsitelist $DIR_UPDATE/custom_bl/
|
|
|
90 |
cp -f /etc/dansguardian/lists/exceptionurllist $DIR_UPDATE/custom_bl/
|
|
|
91 |
cp -f /etc/dansguardian/lists/bannedurllist $DIR_UPDATE/custom_bl/
|
1961 |
richard |
92 |
cp -rf $DIR_BLACKLIST/ossi-* $DIR_UPDATE/custom_bl/ 2>/dev/null
|
1758 |
richard |
93 |
# backup of different conf files (main conf file, filtering, digest, etc)
|
8 |
franck |
94 |
mkdir $DIR_UPDATE/etc/
|
346 |
richard |
95 |
cp -rf $DIR_ETC/* $DIR_UPDATE/etc/
|
1758 |
richard |
96 |
# backup of the security certificates (server & CA)
|
|
|
97 |
cp -f /etc/pki/tls/certs/alcasar.crt* $DIR_UPDATE # autosigned and official if exist
|
|
|
98 |
cp -f /etc/pki/tls/private/alcasar.key* $DIR_UPDATE # autosigned & official if exist
|
1564 |
richard |
99 |
cp -f /etc/pki/CA/alcasar-ca.crt $DIR_UPDATE
|
|
|
100 |
cp -f /etc/pki/CA/private/alcasar-ca.key $DIR_UPDATE
|
|
|
101 |
if [ -e /etc/pki/tls/certs/server-chain.crt ]; then
|
|
|
102 |
cp -f /etc/pki/tls/certs/server-chain.crt $DIR_UPDATE
|
510 |
richard |
103 |
else
|
1564 |
richard |
104 |
cp -f /etc/pki/tls/certs/alcasar.crt $DIR_UPDATE/server-chain.crt
|
510 |
richard |
105 |
fi
|
1758 |
richard |
106 |
# backup DNSMASQ conf file
|
933 |
franck |
107 |
cp /etc/sysconfig/dnsmasq $DIR_UPDATE
|
1758 |
richard |
108 |
# archive file creation
|
8 |
franck |
109 |
cd /tmp
|
|
|
110 |
tar -cf alcasar-conf.tar conf/
|
|
|
111 |
gzip -f alcasar-conf.tar
|
|
|
112 |
rm -rf $DIR_UPDATE
|
|
|
113 |
;;
|
389 |
franck |
114 |
--load|-load)
|
8 |
franck |
115 |
cd /tmp
|
1057 |
richard |
116 |
tar -xf /tmp/alcasar-conf*.tar.gz
|
1060 |
richard |
117 |
# Retrieve the logo
|
510 |
richard |
118 |
[ -e $DIR_UPDATE/organisme.png ] && cp -f $DIR_UPDATE/organisme.png $DIR_WEB/images/
|
8 |
franck |
119 |
chown apache:apache $DIR_WEB/images/organisme.png $DIR_WEB/intercept.php
|
1060 |
richard |
120 |
# Retrieve the security certificates (CA and server)
|
1758 |
richard |
121 |
cp -f $DIR_UPDATE/alcasar-ca.crt* /etc/pki/CA/ # autosigned & official
|
|
|
122 |
cp -f $DIR_UPDATE/alcasar-ca.key* /etc/pki/CA/private/ # autosigned & official
|
|
|
123 |
cp -f $DIR_UPDATE/alcasar.crt /etc/pki/tls/certs/
|
|
|
124 |
cp -f $DIR_UPDATE/alcasar.key /etc/pki/tls/private/
|
675 |
richard |
125 |
[ -e $DIR_UPDATE/server-chain.crt ] && cp -f $DIR_UPDATE/server-chain.crt /etc/pki/tls/certs/
|
8 |
franck |
126 |
chown -R root:apache /etc/pki
|
|
|
127 |
chmod -R 750 /etc/pki
|
1060 |
richard |
128 |
# Import of the users database
|
1671 |
richard |
129 |
gzip -dc < `ls $DIR_UPDATE/alcasar-users-database*` | mysql -u$DB_USER -p$radiuspwd
|
1914 |
richard |
130 |
# Retrieve local parameters
|
1760 |
richard |
131 |
[ -d $DIR_UPDATE/etc ] && cp -rf $DIR_UPDATE/etc/* $DIR_ETC/
|
1914 |
richard |
132 |
# Retrieve BL/WL custom files
|
|
|
133 |
cp -f $DIR_UPDATE/custom_bl/exceptioniplist /etc/dansguardian/lists/
|
|
|
134 |
cp -f $DIR_UPDATE/custom_bl/exceptionsitelist /etc/dansguardian/lists/
|
|
|
135 |
cp -f $DIR_UPDATE/custom_bl/urlregexplist /etc/dansguardian/lists/
|
|
|
136 |
cp -f $DIR_UPDATE/custom_bl/bannedsitelist /etc/dansguardian/lists/
|
|
|
137 |
cp -f $DIR_UPDATE/custom_bl/exceptionurllist /etc/dansguardian/lists/
|
|
|
138 |
cp -f $DIR_UPDATE/custom_bl/bannedurllist /etc/dansguardian/lists/
|
1961 |
richard |
139 |
cp -rf $DIR_UPDATE/custom_bl/ossi-* $DIR_BLACKLIST/ 2>/dev/null
|
8 |
franck |
140 |
chown -R dansguardian:apache /etc/dansguardian/lists
|
|
|
141 |
chmod -R g+rw /etc/dansguardian/lists
|
1060 |
richard |
142 |
# Adapt DNS/URL filtering
|
|
|
143 |
PARENT_SCRIPT=`basename $0`
|
637 |
richard |
144 |
export PARENT_SCRIPT
|
1946 |
richard |
145 |
$DIR_BIN/alcasar-bl.sh -cat_choice
|
1827 |
raphael.pi |
146 |
$DIR_BIN/alcasar-bl.sh -reload
|
1060 |
richard |
147 |
# retrieve dnsmasq general config file
|
|
|
148 |
[ -e $DIR_UPDATE/dnsmasq ] && cp -f $DIR_UPDATE/dnsmasq /etc/sysconfig/dnsmasq \
|
|
|
149 |
&& chown root.root /etc/sysconfig/dnsmasq \
|
|
|
150 |
&& chmod 644 /etc/sysconfig/dnsmasq
|
|
|
151 |
# admin profile update (admin + manager + backup)
|
1827 |
raphael.pi |
152 |
$DIR_BIN/alcasar-profil.sh --list
|
634 |
richard |
153 |
# Start / Stop SSH Daemon
|
1065 |
richard |
154 |
ssh_active=`grep SSH= $CONF_FILE|cut -d"=" -f2`
|
634 |
richard |
155 |
if [ $ssh_active = "on" ]
|
|
|
156 |
then
|
1574 |
richard |
157 |
/usr/bin/systemctl -q enable sshd.service
|
634 |
richard |
158 |
else
|
1574 |
richard |
159 |
/usr/bin/systemctl -q disable sshd.service
|
634 |
richard |
160 |
fi
|
1060 |
richard |
161 |
# Remove the update folder
|
8 |
franck |
162 |
rm -rf $DIR_UPDATE
|
|
|
163 |
;;
|
628 |
richard |
164 |
--apply|-apply)
|
994 |
franck |
165 |
PTN="\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\/([012]?[0-9]|3[0-2])\b"
|
1054 |
franck |
166 |
PRIVATE_IP_MASK=`grep ^PRIVATE_IP $CONF_FILE|cut -d"=" -f2`
|
628 |
richard |
167 |
check=$(echo $PRIVATE_IP_MASK | egrep $PTN)
|
|
|
168 |
if [[ "$?" -ne 0 ]]
|
|
|
169 |
then
|
|
|
170 |
echo "Syntax error for PRIVATE_IP_MASK ($PRIVATE_IP_MASK)"
|
|
|
171 |
exit 0
|
|
|
172 |
fi
|
1054 |
franck |
173 |
PUBLIC_IP_MASK=`grep ^PUBLIC_IP $CONF_FILE|cut -d"=" -f2`
|
1590 |
richard |
174 |
PTN="\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b"
|
1585 |
richard |
175 |
if [[ "$PUBLIC_IP_MASK" == "dhcp" ]]
|
|
|
176 |
then
|
|
|
177 |
PUBLIC_GATEWAY="dhcp"
|
1590 |
richard |
178 |
|
1585 |
richard |
179 |
else
|
|
|
180 |
check=$(echo $PUBLIC_IP_MASK | egrep $PTN)
|
|
|
181 |
if [[ "$?" -ne 0 ]]
|
628 |
richard |
182 |
then
|
1585 |
richard |
183 |
echo "Syntax error for PUBLIC_IP_MASK ($PUBLIC_IP_MASK)"
|
|
|
184 |
exit 0
|
|
|
185 |
fi
|
1590 |
richard |
186 |
PUBLIC_IP=`echo $PUBLIC_IP_MASK | cut -d"/" -f1`
|
|
|
187 |
PUBLIC_NETMASK=`/bin/ipcalc -m $PUBLIC_IP_MASK | cut -d"=" -f2`
|
1585 |
richard |
188 |
PUBLIC_GATEWAY=`grep ^GW $CONF_FILE|cut -d"=" -f2`
|
|
|
189 |
check=$(echo $PUBLIC_GATEWAY | egrep $PTN)
|
|
|
190 |
if [[ "$?" -ne 0 ]]
|
|
|
191 |
then
|
|
|
192 |
echo "Syntax error for the Gateway IP ($PUBLIC_GATEWAY)"
|
|
|
193 |
exit 0
|
|
|
194 |
fi
|
628 |
richard |
195 |
fi
|
1590 |
richard |
196 |
DNS1=`grep ^DNS1 $CONF_FILE|cut -d"=" -f2`
|
|
|
197 |
check=$(echo $DNS1 | egrep $PTN)
|
|
|
198 |
if [[ "$?" -ne 0 ]]
|
|
|
199 |
then
|
|
|
200 |
echo "Syntax error for the IP address of the first DNS server ($DNS1)"
|
|
|
201 |
exit 0
|
|
|
202 |
fi
|
|
|
203 |
DNS2=`grep ^DNS2 $CONF_FILE|cut -d"=" -f2`
|
|
|
204 |
check=$(echo $DNS2 | egrep $PTN)
|
|
|
205 |
if [[ "$?" -ne 0 ]]
|
|
|
206 |
then
|
|
|
207 |
echo "Syntax error for the IP address of the second DNS server ($DNS2)"
|
|
|
208 |
exit 0
|
|
|
209 |
fi
|
631 |
richard |
210 |
PRIVATE_IP=`echo $PRIVATE_IP_MASK | cut -d"/" -f1`
|
632 |
richard |
211 |
PRIVATE_NETMASK=`/bin/ipcalc -m $PRIVATE_IP_MASK | cut -d"=" -f2`
|
628 |
richard |
212 |
private_network_calc
|
632 |
richard |
213 |
INSTALL_DATE=`grep INSTALL_DATE $CONF_FILE|cut -d"=" -f2`
|
|
|
214 |
ORGANISME=`grep ORGANISM $CONF_FILE|cut -d"=" -f2`
|
923 |
franck |
215 |
DOMAIN=`grep DOMAIN $CONF_FILE|cut -d"=" -f2`
|
862 |
richard |
216 |
DHCP_mode=`grep DHCP= $CONF_FILE|cut -d"=" -f2`
|
1060 |
richard |
217 |
if [ "$PARENT_SCRIPT" != "alcasar.sh" ] # don't launch on install stage
|
933 |
franck |
218 |
then
|
1890 |
franck |
219 |
if [ $DHCP_mode = "off" ] || [ $DHCP_mode = "Off" ] || [ $DHCP_mode = "OFF" ]
|
1060 |
richard |
220 |
then
|
1827 |
raphael.pi |
221 |
$DIR_BIN/alcasar-dhcp.sh --off
|
1890 |
franck |
222 |
else
|
|
|
223 |
$DIR_BIN/alcasar-dhcp.sh --on
|
1060 |
richard |
224 |
fi
|
1806 |
franck |
225 |
|
|
|
226 |
# Implementation of the local DNS
|
1890 |
franck |
227 |
if [ $INT_DNS_mode = "on" ] || [ $INT_DNS_mode = "On" ] || [ $INT_DNS_mode = "ON" ]
|
|
|
228 |
then
|
|
|
229 |
$DIR_BIN/alcasar-dns-local.sh --on
|
|
|
230 |
else
|
|
|
231 |
$DIR_BIN/alcasar-dns-local.sh --off
|
|
|
232 |
fi
|
1806 |
franck |
233 |
|
1694 |
franck |
234 |
# Implementation of the authentification LDAP
|
1890 |
franck |
235 |
# if [ LDAP_mode = "on" ] || [ $LDAP_mode = "On" ] || [ $LDAP_mode = "ON" ]
|
|
|
236 |
# then
|
|
|
237 |
# $DIR_BIN/alcasar-ldap.sh
|
|
|
238 |
# fi
|
1611 |
franck |
239 |
|
1585 |
richard |
240 |
# Logout everybody
|
1827 |
raphael.pi |
241 |
$DIR_BIN/alcasar-logout.sh all
|
1585 |
richard |
242 |
# Services stop
|
1521 |
richard |
243 |
echo -n "Stop services : "
|
1850 |
franck |
244 |
for i in ntpd tinyproxy dnsmasq dnsmasq-whitelist dnsmasq-blacklist dnsmasq-blackhole chilli network
|
1060 |
richard |
245 |
do
|
1574 |
richard |
246 |
/usr/bin/systemctl stop $i && echo -n "$i, "
|
1060 |
richard |
247 |
done
|
1827 |
raphael.pi |
248 |
/usr/bin/kill -s SIGSTOP $(pidof httpd)
|
1521 |
richard |
249 |
echo
|
1060 |
richard |
250 |
fi
|
628 |
richard |
251 |
|
|
|
252 |
# /etc/hosts
|
1583 |
richard |
253 |
$SED "/alcasar/s?.*?$PRIVATE_IP\talcasar alcasar.localdomain?g" /etc/hosts
|
1518 |
richard |
254 |
# EXTIF config
|
1585 |
richard |
255 |
if [ $PUBLIC_IP_MASK == "dhcp" ]
|
|
|
256 |
then
|
|
|
257 |
cat <<EOF > /etc/sysconfig/network-scripts/ifcfg-$EXTIF
|
|
|
258 |
DEVICE=$EXTIF
|
|
|
259 |
BOOTPROTO=dhcp
|
|
|
260 |
DNS1=127.0.0.1
|
|
|
261 |
PEERDNS=no
|
|
|
262 |
RESOLV_MODS=yes
|
|
|
263 |
ONBOOT=yes
|
|
|
264 |
METRIC=10
|
|
|
265 |
MII_NOT_SUPPORTED=yes
|
|
|
266 |
IPV6INIT=no
|
|
|
267 |
IPV6TO4INIT=no
|
|
|
268 |
ACCOUNTING=no
|
|
|
269 |
USERCTL=no
|
|
|
270 |
MTU=$MTU
|
1850 |
franck |
271 |
NOZEROCONF=yes
|
1585 |
richard |
272 |
EOF
|
|
|
273 |
else
|
|
|
274 |
cat <<EOF > /etc/sysconfig/network-scripts/ifcfg-$EXTIF
|
|
|
275 |
DEVICE=$EXTIF
|
|
|
276 |
BOOTPROTO=static
|
|
|
277 |
IPADDR=$PUBLIC_IP
|
|
|
278 |
NETMASK=$PUBLIC_NETMASK
|
|
|
279 |
GATEWAY=$PUBLIC_GATEWAY
|
|
|
280 |
DNS1=127.0.0.1
|
|
|
281 |
RESOLV_MODS=yes
|
|
|
282 |
ONBOOT=yes
|
|
|
283 |
METRIC=10
|
|
|
284 |
MII_NOT_SUPPORTED=yes
|
|
|
285 |
IPV6INIT=no
|
|
|
286 |
IPV6TO4INIT=no
|
|
|
287 |
ACCOUNTING=no
|
|
|
288 |
USERCTL=no
|
|
|
289 |
MTU=$MTU
|
1850 |
franck |
290 |
NOZEROCONF=yes
|
1585 |
richard |
291 |
EOF
|
|
|
292 |
fi
|
1518 |
richard |
293 |
# INTIF config (for bypass mode only)
|
1554 |
richard |
294 |
$SED "s?^IPADDR=.*?IPADDR=$PRIVATE_IP?" /etc/sysconfig/network-scripts/bypass-ifcfg-$INTIF
|
|
|
295 |
$SED "s?^NETMASK=.*?NETMASK=$PRIVATE_NETMASK?" /etc/sysconfig/network-scripts/bypass-ifcfg-$INTIF
|
628 |
richard |
296 |
# NTP server
|
632 |
richard |
297 |
$SED "/127.0.0.1/!s?^restrict.*?restrict $PRIVATE_NETWORK mask $PRIVATE_NETMASK nomodify notrap?g" /etc/ntp.conf
|
628 |
richard |
298 |
# host.allow
|
|
|
299 |
cat <<EOF > /etc/hosts.allow
|
|
|
300 |
ALL: LOCAL, 127.0.0.1, localhost, $PRIVATE_IP
|
|
|
301 |
sshd: ALL
|
|
|
302 |
ntpd: $PRIVATE_NETWORK_SHORT
|
|
|
303 |
EOF
|
632 |
richard |
304 |
# Alcasar Control Center
|
634 |
richard |
305 |
$SED "s?^Listen.*?Listen $PRIVATE_IP:80?g" /etc/httpd/conf/httpd.conf
|
1419 |
richard |
306 |
FIC_MOD_SSL=`find /etc/httpd/conf/ -type f -name ssl.conf`
|
634 |
richard |
307 |
$SED "s?^Listen.*?Listen $PRIVATE_IP:443?g" $FIC_MOD_SSL
|
|
|
308 |
$SED "/127.0.0.1/!s?Allow from .*?Allow from $PRIVATE_NETWORK_MASK?g" /etc/httpd/conf/webapps.d/alcasar.conf
|
632 |
richard |
309 |
# Dialup_Admin
|
634 |
richard |
310 |
$SED "s?^nas1_name:.*?nas1_name: alcasar-$ORGANISME?g" /etc/freeradius-web/naslist.conf
|
|
|
311 |
$SED "s?^nas1_ip:.*?nas1_ip: $PRIVATE_IP?g" /etc/freeradius-web/naslist.conf
|
632 |
richard |
312 |
# coova
|
634 |
richard |
313 |
$SED "s?^net.*?net\t\t$PRIVATE_NETWORK_MASK?g" /etc/chilli.conf
|
|
|
314 |
$SED "s?^dns1.*?dns1\t\t$PRIVATE_IP?g" /etc/chilli.conf
|
|
|
315 |
$SED "s?^dns2.*?dns2\t\t$PRIVATE_IP?g" /etc/chilli.conf
|
|
|
316 |
$SED "s?^uamlisten.*?uamlisten\t$PRIVATE_IP?g" /etc/chilli.conf
|
1581 |
richard |
317 |
# modify the DHCP static ip file. Reserve the second IP address for INTIF (the first one is for tun0). Keep previous entries
|
|
|
318 |
$SED "s?^$PRIVATE_MAC.*?$PRIVATE_MAC $PRIVATE_SECOND_IP?" $DIR_ETC/alcasar-ethers
|
632 |
richard |
319 |
# dnsmasq
|
1795 |
franck |
320 |
$SED "/127.0.0.1/!s?^listen-address=.*?listen-address=$PRIVATE_IP?g" /etc/dnsmasq.conf /etc/dnsmasq-blacklist.conf /etc/dnsmasq-whitelist.conf /etc/dnsmasq-blackhole.conf
|
1377 |
richard |
321 |
for i in /etc/dnsmasq.conf /etc/dnsmasq-blacklist.conf
|
673 |
richard |
322 |
do
|
|
|
323 |
$SED "/^server=/d" $i
|
|
|
324 |
echo "server=$DNS1" >> $i
|
|
|
325 |
echo "server=$DNS2" >> $i
|
|
|
326 |
done
|
1060 |
richard |
327 |
$SED "s?^dhcp-range=.*?dhcp-range=$PRIVATE_SECOND_IP,$PRIVATE_LAST_IP,$PRIVATE_NETMASK,12h?g" /etc/dnsmasq.conf
|
634 |
richard |
328 |
$SED "s?^dhcp-option=option:router.*?dhcp-option=option:router,$PRIVATE_IP?g" /etc/dnsmasq.conf
|
1518 |
richard |
329 |
# tinyproxy
|
|
|
330 |
$SED "s?^Listen.*?Listen $PRIVATE_IP?g" /etc/tinyproxy/tinyproxy.conf
|
634 |
richard |
331 |
# DG + BL
|
|
|
332 |
$SED "s?^filterip.*?filterip = $PRIVATE_IP?g" /etc/dansguardian/dansguardian.conf
|
|
|
333 |
# Watchdog
|
|
|
334 |
$SED "s?^PRIVATE_IP=.*?PRIVATE_IP=\"$PRIVATE_IP\"?g" $DIR_BIN/alcasar-watchdog.sh
|
|
|
335 |
# Prompts
|
|
|
336 |
$SED "s?^ORGANISME.*?ORGANISME=$ORGANISME?g" /etc/bashrc
|
|
|
337 |
# sudoers
|
|
|
338 |
$SED "s?^Host_Alias.*?Host_Alias LAN_ORG=$PRIVATE_NETWORK/$PRIVATE_NETMASK,localhost #réseau de l'organisme?g" /etc/sudoers
|
1060 |
richard |
339 |
if [ "$PARENT_SCRIPT" != "alcasar.sh" ] # don't launch on install stage
|
|
|
340 |
then
|
634 |
richard |
341 |
# Services start
|
1574 |
richard |
342 |
/usr/bin/systemctl start network && echo -n "Start service : network" && sleep 1
|
1827 |
raphael.pi |
343 |
$DIR_BIN/alcasar-dhcp.sh -$DHCP_mode && echo -n ", coova" # apply DHCP mode and start coova
|
|
|
344 |
for i in dnsmasq tinyproxy ntpd
|
1521 |
richard |
345 |
do
|
|
|
346 |
sleep 1
|
1574 |
richard |
347 |
/usr/bin/systemctl start $i && echo -n ", $i"
|
1521 |
richard |
348 |
done
|
1827 |
raphael.pi |
349 |
$DIR_BIN/alcasar-bl.sh -reload && echo ", dnsmasq-blacklist, dnsmasq-whitelist, iptables,"
|
|
|
350 |
/usr/bin/kill -s SIGCONT $(pidof httpd)
|
|
|
351 |
/usr/bin/systemctl reload httpd && echo -n ", httpd"
|
1060 |
richard |
352 |
fi
|
628 |
richard |
353 |
# Start / Stop SSH Daemon
|
1065 |
richard |
354 |
ssh_active=`grep SSH= $CONF_FILE|cut -d"=" -f2`
|
634 |
richard |
355 |
if [ $ssh_active = "on" ]
|
|
|
356 |
then
|
1574 |
richard |
357 |
/usr/bin/systemctl enable sshd.service
|
1060 |
richard |
358 |
if [ "$PARENT_SCRIPT" != "alcasar.sh" ] # don't launch on install stage
|
|
|
359 |
then
|
1574 |
richard |
360 |
/usr/bin/systemctl start sshd.service
|
1060 |
richard |
361 |
fi
|
634 |
richard |
362 |
else
|
1574 |
richard |
363 |
/usr/bin/systemctl disable sshd.service
|
1060 |
richard |
364 |
if [ "$PARENT_SCRIPT" != "alcasar.sh" ] # don't launch on install stage
|
|
|
365 |
then
|
1574 |
richard |
366 |
/usr/bin/systemctl stop sshd.service
|
1060 |
richard |
367 |
fi
|
634 |
richard |
368 |
fi
|
628 |
richard |
369 |
;;
|
8 |
franck |
370 |
*)
|
|
|
371 |
echo "Argument inconnu :$1";
|
|
|
372 |
echo "$usage"
|
|
|
373 |
exit 1
|
|
|
374 |
;;
|
|
|
375 |
esac
|
|
|
376 |
|