Line 1... |
Line 1... |
1 |
#/bin/sh
|
1 |
#/bin/sh
|
2 |
# $Id: alcasar-conf.sh 632 2011-06-12 17:48:40Z richard $
|
2 |
# $Id: alcasar-conf.sh 634 2011-06-13 17:23:46Z richard $
|
3 |
# $Author: richard $
|
3 |
# $Author: richard $
|
4 |
# by rexy
|
4 |
# by rexy
|
5 |
# Ce script permet de créer ou de charger l'archive des fichiers de configuration (/tmp/alcasar-conf.tar.gz)
|
5 |
# Ce script permet de créer ou de charger l'archive des fichiers de configuration (/tmp/alcasar-conf.tar.gz)
|
6 |
DIR_UPDATE="/tmp/conf" # répertoire de stockage des fichier de conf pour une mise à jour
|
6 |
DIR_UPDATE="/tmp/conf" # répertoire de stockage des fichier de conf pour une mise à jour
|
7 |
DIR_WEB="/var/www/html" # répertoire du centre de gestion
|
7 |
DIR_WEB="/var/www/html" # répertoire du centre de gestion
|
Line 131... |
Line 131... |
131 |
echo "GW=$PUBLIC_GATEWAY" >> $CONF_FILE
|
131 |
echo "GW=$PUBLIC_GATEWAY" >> $CONF_FILE
|
132 |
echo "DNS1=$DNS1" >> $CONF_FILE
|
132 |
echo "DNS1=$DNS1" >> $CONF_FILE
|
133 |
echo "DNS2=$DNS2" >> $CONF_FILE
|
133 |
echo "DNS2=$DNS2" >> $CONF_FILE
|
134 |
echo "PRIVATE_IP=$PRIVATE_IP/$PRIVATE_PREFIX" >> $CONF_FILE
|
134 |
echo "PRIVATE_IP=$PRIVATE_IP/$PRIVATE_PREFIX" >> $CONF_FILE
|
135 |
echo "DHCP=on" >> $CONF_FILE
|
135 |
echo "DHCP=on" >> $CONF_FILE
|
136 |
echo "DHCP_FIRST=$PRIVATE_DYN_FIRST_IP" >> $CONF_FILE
|
- |
|
137 |
echo "DHCP_LAST=$PRIVATE_DYN_LAST_IP" >> $CONF_FILE
|
- |
|
138 |
if [ -r /var/run/sshd.pid ]; then
|
136 |
if [ -r /var/run/sshd.pid ]; then
|
139 |
echo "SSH=on" >> $CONF_FILE
|
137 |
echo "SSH=on" >> $CONF_FILE
|
140 |
else
|
138 |
else
|
141 |
echo "SSH=off" >> $CONF_FILE
|
139 |
echo "SSH=off" >> $CONF_FILE
|
142 |
fi
|
140 |
fi
|
Line 181... |
Line 179... |
181 |
[ -e $DIR_UPDATE/exceptionurllist ] && cp -f $DIR_UPDATE/exceptionurllist /etc/dansguardian/lists/
|
179 |
[ -e $DIR_UPDATE/exceptionurllist ] && cp -f $DIR_UPDATE/exceptionurllist /etc/dansguardian/lists/
|
182 |
[ -e $DIR_UPDATE/bannedurllist ] && cp -f $DIR_UPDATE/bannedurllist /etc/dansguardian/lists/
|
180 |
[ -e $DIR_UPDATE/bannedurllist ] && cp -f $DIR_UPDATE/bannedurllist /etc/dansguardian/lists/
|
183 |
[ -d $DIR_UPDATE/ossi ] && cp -rf $DIR_UPDATE/ossi /etc/dansguardian/lists/blacklists/
|
181 |
[ -d $DIR_UPDATE/ossi ] && cp -rf $DIR_UPDATE/ossi /etc/dansguardian/lists/blacklists/
|
184 |
chown -R dansguardian:apache /etc/dansguardian/lists
|
182 |
chown -R dansguardian:apache /etc/dansguardian/lists
|
185 |
chmod -R g+rw /etc/dansguardian/lists
|
183 |
chmod -R g+rw /etc/dansguardian/lists
|
186 |
# On active/désactive la BL
|
184 |
# Start / Stop DNS/URL filtering
|
187 |
$DIR_SBIN/alcasar-bl.sh -conf
|
185 |
$DIR_SBIN/alcasar-bl.sh
|
188 |
# Prise en compte des comptes de gestion (admin + manager + backup)
|
186 |
# Prise en compte des comptes de gestion (admin + manager + backup)
|
189 |
$DIR_SBIN/alcasar-profil.sh --list
|
187 |
$DIR_SBIN/alcasar-profil.sh --list
|
- |
|
188 |
# Start / Stop SSH Daemon
|
- |
|
189 |
ssh_active=`grep SSH $CONF_FILE|cut -d"=" -f2`
|
- |
|
190 |
if [ $ssh_active = "on" ]
|
- |
|
191 |
then
|
- |
|
192 |
/sbin/chkconfig --add sshd
|
- |
|
193 |
else
|
- |
|
194 |
/sbin/chkconfig --del sshd
|
- |
|
195 |
fi
|
- |
|
196 |
# Start / Stop network filtering
|
- |
|
197 |
$DIR_BIN/alcasar-iptables.sh
|
190 |
# Effacement du répertoire d'update
|
198 |
# Effacement du répertoire d'update
|
191 |
rm -rf $DIR_UPDATE
|
199 |
rm -rf $DIR_UPDATE
|
192 |
;;
|
200 |
;;
|
193 |
--apply|-apply)
|
201 |
--apply|-apply)
|
194 |
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]\b"
|
202 |
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]\b"
|
Line 234... |
Line 242... |
234 |
PRIVATE_NETMASK=`/bin/ipcalc -m $PRIVATE_IP_MASK | cut -d"=" -f2`
|
242 |
PRIVATE_NETMASK=`/bin/ipcalc -m $PRIVATE_IP_MASK | cut -d"=" -f2`
|
235 |
private_network_calc
|
243 |
private_network_calc
|
236 |
VERSION=`grep VERSION $CONF_FILE|cut -d"=" -f2`
|
244 |
VERSION=`grep VERSION $CONF_FILE|cut -d"=" -f2`
|
237 |
INSTALL_DATE=`grep INSTALL_DATE $CONF_FILE|cut -d"=" -f2`
|
245 |
INSTALL_DATE=`grep INSTALL_DATE $CONF_FILE|cut -d"=" -f2`
|
238 |
ORGANISME=`grep ORGANISM $CONF_FILE|cut -d"=" -f2`
|
246 |
ORGANISME=`grep ORGANISM $CONF_FILE|cut -d"=" -f2`
|
- |
|
247 |
# Logout everybody
|
- |
|
248 |
$DIR_SBIN/alcasar-logout.sh all
|
- |
|
249 |
# Services stop
|
- |
|
250 |
for i in squid ntpd chilli httpd sshd network
|
- |
|
251 |
do
|
- |
|
252 |
[ -e /etc/init.d/$i ] && /etc/init.d/$i stop && killall $i 2>/dev/null
|
- |
|
253 |
done
|
239 |
|
254 |
|
240 |
# /etc/hosts
|
255 |
# /etc/hosts
|
241 |
cat <<EOF > /etc/hosts
|
256 |
cat <<EOF > /etc/hosts
|
242 |
127.0.0.1 localhost
|
257 |
127.0.0.1 localhost
|
243 |
$PRIVATE_IP $HOSTNAME
|
258 |
$PRIVATE_IP $HOSTNAME
|
Line 256... |
Line 271... |
256 |
ALL: LOCAL, 127.0.0.1, localhost, $PRIVATE_IP
|
271 |
ALL: LOCAL, 127.0.0.1, localhost, $PRIVATE_IP
|
257 |
sshd: ALL
|
272 |
sshd: ALL
|
258 |
ntpd: $PRIVATE_NETWORK_SHORT
|
273 |
ntpd: $PRIVATE_NETWORK_SHORT
|
259 |
EOF
|
274 |
EOF
|
260 |
# Alcasar Control Center
|
275 |
# Alcasar Control Center
|
261 |
echo "$VERSION du $INSTALL_DATE" > /var/www/html/VERSION; chown apache:apache /var/www/html/VERSION
|
276 |
echo "$VERSION du $INSTALL_DATE" > /var/www/html/VERSION; chown apache:apache /var/www/html/VERSION
|
262 |
$SED "s?^Listen.*?Listen $PRIVATE_IP:80?g" /etc/httpd/conf/httpd.conf
|
277 |
$SED "s?^Listen.*?Listen $PRIVATE_IP:80?g" /etc/httpd/conf/httpd.conf
|
263 |
FIC_MOD_SSL=`find /etc/httpd/modules.d/ -type f -name *mod_ssl.conf`
|
278 |
FIC_MOD_SSL=`find /etc/httpd/modules.d/ -type f -name *mod_ssl.conf`
|
264 |
$SED "s?^Listen.*?Listen $PRIVATE_IP:443?g" $FIC_MOD_SSL
|
279 |
$SED "s?^Listen.*?Listen $PRIVATE_IP:443?g" $FIC_MOD_SSL
|
265 |
$SED "/127.0.0.1/!s?Allow from .*?Allow from $PRIVATE_NETWORK_MASK?g" /etc/httpd/conf/webapps.d/alcasar.conf
|
280 |
$SED "/127.0.0.1/!s?Allow from .*?Allow from $PRIVATE_NETWORK_MASK?g" /etc/httpd/conf/webapps.d/alcasar.conf
|
266 |
# Dialup_Admin
|
281 |
# Dialup_Admin
|
267 |
$SED "s?^nas1_name:.*?nas1_name: alcasar-$ORGANISME?g" /etc/freeradius-web/naslist.conf
|
282 |
$SED "s?^nas1_name:.*?nas1_name: alcasar-$ORGANISME?g" /etc/freeradius-web/naslist.conf
|
268 |
$SED "s?^nas1_ip:.*?nas1_ip: $PRIVATE_IP?g" /etc/freeradius-web/naslist.conf
|
283 |
$SED "s?^nas1_ip:.*?nas1_ip: $PRIVATE_IP?g" /etc/freeradius-web/naslist.conf
|
269 |
# coova
|
284 |
# coova
|
270 |
$SED "s?ifconfig.*?ifconfig \$HS_LANIF $PRIVATE_IP?g" /etc/init.d/chilli
|
285 |
$SED "s?ifconfig.*?ifconfig \$HS_LANIF $PRIVATE_IP?g" /etc/init.d/chilli
|
271 |
$SED "s?^net.*?net\t\t$PRIVATE_NETWORK_MASK?g" /etc/chilli.conf
|
286 |
$SED "s?^net.*?net\t\t$PRIVATE_NETWORK_MASK?g" /etc/chilli.conf
|
272 |
$SED "s?^dynip.*?dynip\t\t$PRIVATE_DYN_IP?g" /etc/chilli.conf
|
287 |
$SED "s?^dynip.*?dynip\t\t$PRIVATE_DYN_IP?g" /etc/chilli.conf
|
273 |
$SED "s?^statip.*?statip\t\t$PRIVATE_STAT_IP?g" /etc/chilli.conf
|
288 |
$SED "s?^statip.*?statip\t\t$PRIVATE_STAT_IP?g" /etc/chilli.conf
|
274 |
$SED "s?^dns1.*?dns1\t\t$PRIVATE_IP?g" /etc/chilli.conf
|
289 |
$SED "s?^dns1.*?dns1\t\t$PRIVATE_IP?g" /etc/chilli.conf
|
275 |
$SED "s?^dns2.*?dns2\t\t$PRIVATE_IP?g" /etc/chilli.conf
|
290 |
$SED "s?^dns2.*?dns2\t\t$PRIVATE_IP?g" /etc/chilli.conf
|
276 |
$SED "s?^uamlisten.*?uamlisten\t$PRIVATE_IP?g" /etc/chilli.conf
|
291 |
$SED "s?^uamlisten.*?uamlisten\t$PRIVATE_IP?g" /etc/chilli.conf
|
277 |
$SED "s?^\$organisme = .*?\$organisme = \"$ORGANISME\";?g" /var/www/html/intercept.php /var/www/html/status.php
|
292 |
$SED "s?^\$organisme = .*?\$organisme = \"$ORGANISME\";?g" /var/www/html/intercept.php /var/www/html/status.php
|
278 |
# awstat
|
293 |
# awstat
|
279 |
$SED "s?^HostAliases=.*?HostAliases=\"$PRIVATE_IP\"?g" /etc/awstats/awstats.conf
|
294 |
$SED "s?^HostAliases=.*?HostAliases=\"$PRIVATE_IP\"?g" /etc/awstats/awstats.conf
|
280 |
# dnsmasq
|
295 |
# dnsmasq
|
281 |
$SED "/127.0.0.1/!s?^listen-address=.*?listen-address=$PRIVATE_IP?g" /etc/dnsmasq.conf /etc/dnsmasq-blackhole.conf
|
296 |
$SED "/127.0.0.1/!s?^listen-address=.*?listen-address=$PRIVATE_IP?g" /etc/dnsmasq.conf /etc/dnsmasq-blackhole.conf
|
282 |
$SED "s?^server=.*?server=$DNS1?g" /etc/dnsmasq.conf /etc/dnsmasq-blackhole.conf
|
297 |
$SED "s?^server=.*?server=$DNS1?g" /etc/dnsmasq.conf /etc/dnsmasq-blackhole.conf
|
283 |
$SED "/$DNS1/!s?^server=.*?server=$DNS2?g" /etc/dnsmasq.conf /etc/dnsmasq-blackhole.conf
|
298 |
$SED "/$DNS1/!s?^server=.*?server=$DNS2?g" /etc/dnsmasq.conf /etc/dnsmasq-blackhole.conf
|
284 |
$SED "s?^dhcp-range=.*?dhcp-range=$PRIVATE_DYN_FIRST_IP,$PRIVATE_DYN_LAST_IP,$PRIVATE_NETMASK,12h?g" /etc/dnsmasq.conf
|
299 |
$SED "s?^dhcp-range=.*?dhcp-range=$PRIVATE_DYN_FIRST_IP,$PRIVATE_DYN_LAST_IP,$PRIVATE_NETMASK,12h?g" /etc/dnsmasq.conf
|
285 |
$SED "s?^dhcp-option=option:router.*?dhcp-option=option:router,$PRIVATE_IP?g" /etc/dnsmasq.conf
|
300 |
$SED "s?^dhcp-option=option:router.*?dhcp-option=option:router,$PRIVATE_IP?g" /etc/dnsmasq.conf
|
- |
|
301 |
# DG + BL
|
- |
|
302 |
$SED "s?^IP_RETOUR=.*?IP_RETOUR=\"$PRIVATE_IP\"?g" $DIR_SBIN/alcasar-bl.sh
|
- |
|
303 |
$SED "s?^filterip.*?filterip = $PRIVATE_IP?g" /etc/dansguardian/dansguardian.conf
|
- |
|
304 |
# Watchdog
|
- |
|
305 |
$SED "s?^PRIVATE_IP=.*?PRIVATE_IP=\"$PRIVATE_IP\"?g" $DIR_BIN/alcasar-watchdog.sh
|
- |
|
306 |
# SSHD
|
- |
|
307 |
$SED "s?^#ListenAddress 0\.0\.0\.0?ListenAddress $PRIVATE_IP?g" /etc/ssh/sshd_config
|
- |
|
308 |
$SED "/^ListenAddress $PRIVATE_IP/a\ListenAddress $PUBLIC_IP" /etc/ssh/sshd_config
|
- |
|
309 |
# Prompts
|
- |
|
310 |
$SED "s?^ORGANISME.*?ORGANISME=$ORGANISME?g" /etc/bashrc
|
- |
|
311 |
# sudoers
|
- |
|
312 |
$SED "s?^Host_Alias.*?Host_Alias LAN_ORG=$PRIVATE_NETWORK/$PRIVATE_NETMASK,localhost #réseau de l'organisme?g" /etc/sudoers
|
- |
|
313 |
# Services start
|
- |
|
314 |
for i in network squid ntpd chilli httpd
|
286 |
|
315 |
do
|
- |
|
316 |
[ -e /etc/init.d/$i ] && /etc/init.d/$i start 2>/dev/null
|
- |
|
317 |
done
|
287 |
# Start / Stop SSH Daemon
|
318 |
# Start / Stop SSH Daemon
|
288 |
ssh_active=`grep SSH $CONF_FILE|cut -d"=" -f2`
|
319 |
ssh_active=`grep SSH $CONF_FILE|cut -d"=" -f2`
|
289 |
if [ $ssh_active = "on" ]
|
320 |
if [ $ssh_active = "on" ]
|
290 |
then
|
321 |
then
|
291 |
/sbin/chkconfig --add sshd
|
322 |
/sbin/chkconfig --add sshd
|
- |
|
323 |
/etc/init.d/sshd start
|
292 |
else
|
324 |
else
|
293 |
/sbin/chkconfig --del sshd
|
325 |
/sbin/chkconfig --del sshd
|
294 |
fi
|
326 |
fi
|
295 |
|
- |
|
296 |
|
- |
|
- |
|
327 |
# Reload BL (restart DG, dnsmasq & iptables)
|
297 |
$DIR_BIN/alcasar-iptables.sh
|
328 |
$DIR_SBIN/alcasar-bl.sh -reload
|
298 |
;;
|
329 |
;;
|
299 |
*)
|
330 |
*)
|
300 |
echo "Argument inconnu :$1";
|
331 |
echo "Argument inconnu :$1";
|
301 |
echo "$usage"
|
332 |
echo "$usage"
|
302 |
exit 1
|
333 |
exit 1
|