Line 1... |
Line 1... |
1 |
#/bin/bash
|
1 |
#/bin/bash
|
2 |
# $Id: alcasar-conf.sh 1157 2013-07-16 10:48:11Z stephane $
|
2 |
# $Id: alcasar-conf.sh 1249 2013-10-22 22:09:01Z richard $
|
3 |
|
3 |
|
4 |
# alcasar-conf.sh
|
4 |
# alcasar-conf.sh
|
5 |
# by REXY
|
5 |
# by REXY
|
6 |
# This script is distributed under the Gnu General Public License (GPL)
|
6 |
# This script is distributed under the Gnu General Public License (GPL)
|
7 |
|
7 |
|
Line 83... |
Line 83... |
83 |
cp -rf /etc/dansguardian/lists/blacklists/ossi $DIR_UPDATE
|
83 |
cp -rf /etc/dansguardian/lists/blacklists/ossi $DIR_UPDATE
|
84 |
# sauvegarde des fichiers : de conf, de filtrage, d'exception, digest, etc.
|
84 |
# sauvegarde des fichiers : de conf, de filtrage, d'exception, digest, etc.
|
85 |
mkdir $DIR_UPDATE/etc/
|
85 |
mkdir $DIR_UPDATE/etc/
|
86 |
cp -rf $DIR_ETC/* $DIR_UPDATE/etc/
|
86 |
cp -rf $DIR_ETC/* $DIR_UPDATE/etc/
|
87 |
# particularité des versions
|
87 |
# particularité des versions
|
88 |
# si version <= 2.0
|
88 |
# si version <= 2.8
|
89 |
if [ $MAJ_RUNNING_VERSION -lt 2 ] || ([ $MAJ_RUNNING_VERSION -eq 2 ] && [ $MIN_RUNNING_VERSION -eq 0 ])
|
89 |
if [ $MAJ_RUNNING_VERSION -lt 2 ] || ([ $MAJ_RUNNING_VERSION -eq 2 ] && [ $MIN_RUNNING_VERSION -lt 8 ])
|
90 |
then
|
90 |
then
|
91 |
rm -f $DIR_UPDATE/etc/alcasar-dns-name # changement de format
|
- |
|
92 |
rm -rf $DIR_UPDATE/etc/digest # hostname=alcasar
|
91 |
rm -rf $DIR_UPDATE/etc/digest # hostname=alcasar.$DOMAIN (add the domain name)
|
93 |
if [ -e $DIR_UPDATE/etc/alcasar-uamallowed ]; then
|
- |
|
94 |
uamallowed=`cat $DIR_UPDATE/etc/alcasar-uamallowed`
|
- |
|
95 |
if [ $uamallowed == "uamallowed=\"\"" ]
|
- |
|
96 |
then rm -f $DIR_UPDATE/etc/alcasar-uamallowed # un uamallowed 'vide' perturbe coova
|
- |
|
97 |
fi
|
- |
|
98 |
fi
|
- |
|
99 |
if [ -e $DIR_UPDATE/etc/alcasar-uamdomain ]; then
|
- |
|
100 |
uamdomain=`cat $DIR_UPDATE/etc/alcasar-uamdomain`
|
- |
|
101 |
if [ $uamdomain == "uamdomain=\"\"" ]
|
- |
|
102 |
then rm -f $DIR_UPDATE/etc/alcasar-uamdomain # un uamdomain 'vide' perturbe coova
|
- |
|
103 |
fi
|
- |
|
104 |
fi
|
- |
|
105 |
else
|
92 |
else
|
106 |
# si version >= 2.1 : sauvegarde des certificats (serveur et CA)
|
93 |
# si version > 2.8 : sauvegarde des certificats (serveur et CA)
|
107 |
cert_date=`/usr/bin/openssl x509 -noout -in /etc/pki/tls/certs/alcasar.crt -dates|grep After|cut -d"=" -f2`
|
94 |
cert_date=`/usr/bin/openssl x509 -noout -in /etc/pki/tls/certs/alcasar.crt -dates|grep After|cut -d"=" -f2`
|
108 |
cp -f /etc/pki/tls/certs/alcasar.crt $DIR_UPDATE
|
95 |
cp -f /etc/pki/tls/certs/alcasar.crt $DIR_UPDATE
|
109 |
cp -f /etc/pki/tls/private/alcasar.key $DIR_UPDATE
|
96 |
cp -f /etc/pki/tls/private/alcasar.key $DIR_UPDATE
|
110 |
cp -f /etc/pki/CA/alcasar-ca.crt $DIR_UPDATE
|
97 |
cp -f /etc/pki/CA/alcasar-ca.crt $DIR_UPDATE
|
111 |
cp -f /etc/pki/CA/private/alcasar-ca.key $DIR_UPDATE
|
98 |
cp -f /etc/pki/CA/private/alcasar-ca.key $DIR_UPDATE
|
Line 113... |
Line 100... |
113 |
cp -f /etc/pki/tls/certs/server-chain.crt $DIR_UPDATE
|
100 |
cp -f /etc/pki/tls/certs/server-chain.crt $DIR_UPDATE
|
114 |
else
|
101 |
else
|
115 |
cp -f /etc/pki/tls/certs/alcasar.crt $DIR_UPDATE/server-chain.crt
|
102 |
cp -f /etc/pki/tls/certs/alcasar.crt $DIR_UPDATE/server-chain.crt
|
116 |
fi
|
103 |
fi
|
117 |
fi
|
104 |
fi
|
118 |
# si version < 2.2
|
- |
|
119 |
if [ $MAJ_RUNNING_VERSION -lt 2 ] || ([ $MAJ_RUNNING_VERSION -eq 2 ] && [ $MIN_RUNNING_VERSION -lt 2 ])
|
- |
|
120 |
then
|
- |
|
121 |
ORGANISM=`cat $DIR_WEB/intercept.php|grep '$organisme =' | cut -d"=" -f2|tr -d ";\" "` # Sauvegarde du nom d'organisme
|
- |
|
122 |
rm -f $DIR_UPDATE/etc/alcasar-ethers # This file doesn't contain comments
|
- |
|
123 |
rm -f $DIR_UPDATE/exceptionurllist # This file was not empty (comments)
|
- |
|
124 |
# Create the initial conf file (doesn't exist in earlier versions)
|
- |
|
125 |
cat <<EOF > $CONF_FILE
|
- |
|
126 |
##########################################
|
- |
|
127 |
## ##
|
- |
|
128 |
## ALCASAR Parameters ##
|
- |
|
129 |
## ##
|
- |
|
130 |
##########################################
|
- |
|
131 |
|
- |
|
132 |
INSTALL_DATE=$DATE
|
- |
|
133 |
VERSION=$RUNNING_VERSION
|
- |
|
134 |
ORGANISM=$ORGANISM
|
- |
|
135 |
DOMAIN=$DOMAIN
|
- |
|
136 |
EOF
|
- |
|
137 |
PUBLIC_IP=`grep IPADDR /etc/sysconfig/network-scripts/ifcfg-$EXTIF|cut -d"=" -f2` # @ip du portail (côté Internet)
|
- |
|
138 |
PUBLIC_NETMASK=`grep NETMASK /etc/sysconfig/network-scripts/ifcfg-$EXTIF|cut -d"=" -f2`
|
- |
|
139 |
PUBLIC_PREFIX=`/bin/ipcalc -p $PUBLIC_IP $PUBLIC_NETMASK |cut -d"=" -f2` # prefixe du réseau (ex. 24)
|
- |
|
140 |
PUBLIC_GATEWAY=`grep GATEWAY /etc/sysconfig/network-scripts/default-ifcfg-$EXTIF|cut -d"=" -f2`
|
- |
|
141 |
DNS1=`grep DNS1 /etc/sysconfig/network-scripts/default-ifcfg-$EXTIF|cut -d"=" -f2` # @ip 1er DNS
|
- |
|
142 |
DNS2=`grep DNS2 /etc/sysconfig/network-scripts/default-ifcfg-$EXTIF|cut -d"=" -f2` # @ip 2ème DNS
|
- |
|
143 |
DNS1=${DNS1:=208.67.220.220}
|
- |
|
144 |
DNS2=${DNS2:=208.67.222.222}
|
- |
|
145 |
PRIVATE_IP=`grep IPADDR /etc/sysconfig/network-scripts/ifcfg-$INTIF|cut -d"=" -f2` # @ip du portail (côté LAN)
|
- |
|
146 |
PRIVATE_NETMASK=`grep NETMASK /etc/sysconfig/network-scripts/ifcfg-$INTIF|cut -d"=" -f2`
|
- |
|
147 |
private_network_calc
|
- |
|
148 |
echo "PUBLIC_IP=$PUBLIC_IP/$PUBLIC_PREFIX" >> $CONF_FILE
|
- |
|
149 |
echo "GW=$PUBLIC_GATEWAY" >> $CONF_FILE
|
- |
|
150 |
echo "DNS1=$DNS1" >> $CONF_FILE
|
- |
|
151 |
echo "DNS2=$DNS2" >> $CONF_FILE
|
- |
|
152 |
echo "PRIVATE_IP=$PRIVATE_IP/$PRIVATE_PREFIX" >> $CONF_FILE
|
- |
|
153 |
echo "DHCP=full" >> $CONF_FILE
|
- |
|
154 |
echo "EXT_DHCP_IP=none" >> $CONF_FILE
|
- |
|
155 |
echo "RELAY_DHCP_IP=none" >> $CONF_FILE
|
- |
|
156 |
echo "RELAY_DHCP_PORT=none" >> $CONF_FILE
|
- |
|
157 |
|
- |
|
158 |
if [ -r /var/run/sshd.pid ]; then
|
- |
|
159 |
echo "SSH=on" >> $CONF_FILE
|
- |
|
160 |
else
|
- |
|
161 |
echo "SSH=off" >> $CONF_FILE
|
- |
|
162 |
fi
|
- |
|
163 |
echo "SSH_ADMIN_FROM=0.0.0.0/0.0.0.0" >> $CONF_FILE
|
- |
|
164 |
echo "QOS=off" >> $CONF_FILE
|
- |
|
165 |
echo "WEB_ANTIVIRUS=on" >> $CONF_FILE
|
- |
|
166 |
if [ `grep ^ldap /etc/raddb/sites-available/alcasar | wc -l` -eq "0" ]; then
|
- |
|
167 |
echo "LDAP=off" >> $CONF_FILE
|
- |
|
168 |
else
|
- |
|
169 |
echo "LDAP=on" >> $CONF_FILE
|
- |
|
170 |
fi
|
- |
|
171 |
echo "LDAP_IP=0.0.0.0/0.0.0.0" >> $CONF_FILE
|
- |
|
172 |
PROTOCOLS_FILTERING=`grep ^PROTO_FILTERING /usr/local/bin/alcasar-iptables.sh | cut -d"=" -f2`
|
- |
|
173 |
PROTOCOLS_FILTERING=${PROTOCOLS_FILTERING:="no"}
|
- |
|
174 |
if [ $PROTOCOLS_FILTERING = "no" ]; then
|
- |
|
175 |
echo "PROTOCOLS_FILTERING=off" >> $CONF_FILE
|
- |
|
176 |
else
|
- |
|
177 |
echo "PROTOCOLS_FILTERING=on" >> $CONF_FILE
|
- |
|
178 |
fi
|
- |
|
179 |
DNS_FILTERING=`grep ^reportinglevel /etc/dansguardian/dansguardian.conf | cut -d"=" -f2 | tr -d " "`
|
- |
|
180 |
DNS_FILTERING=${DNS_FILTERING:="-1"}
|
- |
|
181 |
if [ $DNS_FILTERING -eq "-1" ]; then
|
- |
|
182 |
echo "DNS_FILTERING=off" >> $CONF_FILE
|
- |
|
183 |
else
|
- |
|
184 |
echo "DNS_FILTERING=on" >> $CONF_FILE
|
- |
|
185 |
fi
|
- |
|
186 |
fi
|
- |
|
187 |
# since V2.6
|
105 |
# Changes since V2.6
|
188 |
# SSH_ADMIN_FROM is redefined
|
106 |
# SSH_ADMIN_FROM is redefined
|
189 |
$SED "s?^Admin_from_IP=.*?SSH_ADMIN_FROM=0.0.0.0/0.0.0.0?" $CONF_FILE
|
107 |
$SED "s?^Admin_from_IP=.*?SSH_ADMIN_FROM=0.0.0.0/0.0.0.0?" $CONF_FILE
|
190 |
# macallowed is replaced with macauth
|
108 |
# macallowed is replaced with macauth
|
191 |
rm -f $DIR_UPDATE/etc/alcasar-macallowed
|
109 |
rm -f $DIR_UPDATE/etc/alcasar-macallowed
|
192 |
# DHCP mode can be "off/half/full"
|
110 |
# DHCP mode can be "off/half/full"
|