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