Subversion Repositories ALCASAR

Rev

Rev 2175 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log

Rev Author Line No. Line
872 richard 1
#!/bin/bash
859 richard 2
 
870 richard 3
# alcasar-file-clean.sh
859 richard 4
# by Rexy
5
# This script is distributed under the Gnu General Public License (GPL)
6
 
7
# clean alcasar conf files (remove empty lines, sort and control)
8
# nettoie les fichiers de conf d'alcasar (suppression des lignes vides, tri et contrôle)
9
 
10
SED="/bin/sed -i"
11
DIR_CONF="/usr/local/etc"
12
ALCASAR_SERVICES="$DIR_CONF/alcasar-services"
13
ALCASAR_IP_BLOCKED="$DIR_CONF/alcasar-ip-blocked"
870 richard 14
ALCASAR_UAMDOMAIN="$DIR_CONF/alcasar-uamdomain"
15
ALCASAR_UAMALLOWED="$DIR_CONF/alcasar-uamallowed"
859 richard 16
ALCASAR_CONF="$DIR_CONF/alcasar.conf"
17
 
18
# sort file content
870 richard 19
for file in $ALCASAR_SERVICES $ALCASAR_IP_BLOCKED $ALCASAR_UAMDOMAIN $ALCASAR_UAMALLOWED
859 richard 20
do
21
	sort -k2n $file > /tmp/alcasar-tmp-sort
22
	mv -f /tmp/alcasar-tmp-sort $file
23
done
24
 
25
# remove empty lines and put rights
2175 richard 26
for file in $ALCASAR_SERVICES $ALCASAR_IP_BLOCKED $ALCASAR_CONF $ALCASAR_UAMDOMAIN $ALCASAR_UAMALLOWED
859 richard 27
do
2454 tom.houday 28
	$SED "/^$/d" $file
859 richard 29
	chown root:apache $file
30
	chmod 660 $file
31
done
2044 raphael.pi 32
 
2175 richard 33
#update dnsmasq-blackhole with uamallowed domains ($ALCASAR_UAMDOMAIN)
2044 raphael.pi 34
#remove old configuration
35
sed -i '/^server=/d' /etc/dnsmasq-blackhole.conf
36
 
37
for domain in $(cat $ALCASAR_UAMDOMAIN | cut -d' ' -f1)
38
do
2454 tom.houday 39
	domain_exception="server=/$(echo $domain | cut -d'"' -f2)/#"
40
	sed -i "/conf-file/a$domain_exception" /etc/dnsmasq-blackhole.conf
2044 raphael.pi 41
done
2175 richard 42
if [ "$PARENT_SCRIPT" != "alcasar.sh" ] # don't restart on install stage
43
then
44
	systemctl restart dnsmasq-blackhole
2454 tom.houday 45
fi