Line 1... |
Line 1... |
1 |
#/bin/bash
|
1 |
#/bin/bash
|
2 |
# $Id: alcasar-conf.sh 885 2012-06-11 21:33:50Z richard $
|
2 |
# $Id: alcasar-conf.sh 923 2012-07-03 06:34:18Z franck $
|
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 30... |
Line 30... |
30 |
SED="/bin/sed -i"
|
30 |
SED="/bin/sed -i"
|
31 |
RUNNING_VERSION=`cat $VERSION|cut -d" " -f1`
|
31 |
RUNNING_VERSION=`cat $VERSION|cut -d" " -f1`
|
32 |
MAJ_RUNNING_VERSION=`echo $RUNNING_VERSION|cut -d"." -f1`
|
32 |
MAJ_RUNNING_VERSION=`echo $RUNNING_VERSION|cut -d"." -f1`
|
33 |
MIN_RUNNING_VERSION=`echo $RUNNING_VERSION|cut -d"." -f2|cut -c1`
|
33 |
MIN_RUNNING_VERSION=`echo $RUNNING_VERSION|cut -d"." -f2|cut -c1`
|
34 |
UPD_RUNNING_VERSION=`echo $RUNNING_VERSION|cut -d"." -f3`
|
34 |
UPD_RUNNING_VERSION=`echo $RUNNING_VERSION|cut -d"." -f3`
|
- |
|
35 |
DOMAIN=`grep DOMAIN $CONF_FILE|cut -d"=" -f2`
|
- |
|
36 |
DOMAIN=${DOMAIN:=localdomain}
|
35 |
DATE=`date '+%d %B %Y - %Hh%M'`
|
37 |
DATE=`date '+%d %B %Y - %Hh%M'`
|
36 |
private_network_calc ()
|
38 |
private_network_calc ()
|
37 |
{
|
39 |
{
|
38 |
PRIVATE_PREFIX=`/bin/ipcalc -p $PRIVATE_IP $PRIVATE_NETMASK |cut -d"=" -f2` # prefixe du réseau (ex. 24)
|
40 |
PRIVATE_PREFIX=`/bin/ipcalc -p $PRIVATE_IP $PRIVATE_NETMASK |cut -d"=" -f2` # prefixe du réseau (ex. 24)
|
39 |
PRIVATE_NETWORK=`/bin/ipcalc -n $PRIVATE_IP $PRIVATE_NETMASK| cut -d"=" -f2` # @ réseau de consultation (ex.: 192.168.182.0)
|
41 |
PRIVATE_NETWORK=`/bin/ipcalc -n $PRIVATE_IP $PRIVATE_NETMASK| cut -d"=" -f2` # @ réseau de consultation (ex.: 192.168.182.0)
|
Line 122... |
Line 124... |
122 |
##########################################
|
124 |
##########################################
|
123 |
|
125 |
|
124 |
INSTALL_DATE=$DATE
|
126 |
INSTALL_DATE=$DATE
|
125 |
VERSION=$RUNNING_VERSION
|
127 |
VERSION=$RUNNING_VERSION
|
126 |
ORGANISM=$ORGANISM
|
128 |
ORGANISM=$ORGANISM
|
- |
|
129 |
DOMAIN=$DOMAIN
|
127 |
EOF
|
130 |
EOF
|
128 |
PUBLIC_IP=`grep IPADDR /etc/sysconfig/network-scripts/ifcfg-$EXTIF|cut -d"=" -f2` # @ip du portail (côté Internet)
|
131 |
PUBLIC_IP=`grep IPADDR /etc/sysconfig/network-scripts/ifcfg-$EXTIF|cut -d"=" -f2` # @ip du portail (côté Internet)
|
129 |
PUBLIC_NETMASK=`grep NETMASK /etc/sysconfig/network-scripts/ifcfg-$EXTIF|cut -d"=" -f2`
|
132 |
PUBLIC_NETMASK=`grep NETMASK /etc/sysconfig/network-scripts/ifcfg-$EXTIF|cut -d"=" -f2`
|
130 |
PUBLIC_PREFIX=`/bin/ipcalc -p $PUBLIC_IP $PUBLIC_NETMASK |cut -d"=" -f2` # prefixe du réseau (ex. 24)
|
133 |
PUBLIC_PREFIX=`/bin/ipcalc -p $PUBLIC_IP $PUBLIC_NETMASK |cut -d"=" -f2` # prefixe du réseau (ex. 24)
|
131 |
PUBLIC_GATEWAY=`grep GATEWAY /etc/sysconfig/network-scripts/default-ifcfg-$EXTIF|cut -d"=" -f2`
|
134 |
PUBLIC_GATEWAY=`grep GATEWAY /etc/sysconfig/network-scripts/default-ifcfg-$EXTIF|cut -d"=" -f2`
|
Line 140... |
Line 143... |
140 |
echo "GW=$PUBLIC_GATEWAY" >> $CONF_FILE
|
143 |
echo "GW=$PUBLIC_GATEWAY" >> $CONF_FILE
|
141 |
echo "DNS1=$DNS1" >> $CONF_FILE
|
144 |
echo "DNS1=$DNS1" >> $CONF_FILE
|
142 |
echo "DNS2=$DNS2" >> $CONF_FILE
|
145 |
echo "DNS2=$DNS2" >> $CONF_FILE
|
143 |
echo "PRIVATE_IP=$PRIVATE_IP/$PRIVATE_PREFIX" >> $CONF_FILE
|
146 |
echo "PRIVATE_IP=$PRIVATE_IP/$PRIVATE_PREFIX" >> $CONF_FILE
|
144 |
echo "DHCP=half" >> $CONF_FILE
|
147 |
echo "DHCP=half" >> $CONF_FILE
|
- |
|
148 |
echo "EXT_DHCP_IP=none" >> $CONF_FILE
|
- |
|
149 |
echo "RELAY_DHCP_IP=none" >> $CONF_FILE
|
- |
|
150 |
echo "RELAY_DHCP_PORT=none" >> $CONF_FILE
|
145 |
|
151 |
|
146 |
if [ -r /var/run/sshd.pid ]; then
|
152 |
if [ -r /var/run/sshd.pid ]; then
|
147 |
echo "SSH=on" >> $CONF_FILE
|
153 |
echo "SSH=on" >> $CONF_FILE
|
148 |
else
|
154 |
else
|
149 |
echo "SSH=off" >> $CONF_FILE
|
155 |
echo "SSH=off" >> $CONF_FILE
|
150 |
fi
|
156 |
fi
|
Line 306... |
Line 312... |
306 |
PRIVATE_NETMASK=`/bin/ipcalc -m $PRIVATE_IP_MASK | cut -d"=" -f2`
|
312 |
PRIVATE_NETMASK=`/bin/ipcalc -m $PRIVATE_IP_MASK | cut -d"=" -f2`
|
307 |
private_network_calc
|
313 |
private_network_calc
|
308 |
VERSION=`grep VERSION $CONF_FILE|cut -d"=" -f2`
|
314 |
VERSION=`grep VERSION $CONF_FILE|cut -d"=" -f2`
|
309 |
INSTALL_DATE=`grep INSTALL_DATE $CONF_FILE|cut -d"=" -f2`
|
315 |
INSTALL_DATE=`grep INSTALL_DATE $CONF_FILE|cut -d"=" -f2`
|
310 |
ORGANISME=`grep ORGANISM $CONF_FILE|cut -d"=" -f2`
|
316 |
ORGANISME=`grep ORGANISM $CONF_FILE|cut -d"=" -f2`
|
- |
|
317 |
DOMAIN=`grep DOMAIN $CONF_FILE|cut -d"=" -f2`
|
311 |
DHCP_mode=`grep DHCP= $CONF_FILE|cut -d"=" -f2`
|
318 |
DHCP_mode=`grep DHCP= $CONF_FILE|cut -d"=" -f2`
|
312 |
# Logout everybody
|
319 |
# Logout everybody
|
313 |
$DIR_SBIN/alcasar-logout.sh all
|
320 |
$DIR_SBIN/alcasar-logout.sh all
|
314 |
# Services stop
|
321 |
# Services stop
|
315 |
for i in squid ntpd chilli httpd sshd network
|
322 |
for i in squid ntpd chilli httpd network
|
316 |
do
|
323 |
do
|
317 |
[ -e /etc/init.d/$i ] && /etc/init.d/$i stop && killall $i 2>/dev/null
|
324 |
[ -e /etc/init.d/$i ] && /etc/init.d/$i stop && killall $i 2>/dev/null
|
318 |
done
|
325 |
done
|
319 |
|
326 |
|
320 |
# /etc/hosts
|
327 |
# /etc/hosts
|
321 |
cat <<EOF > /etc/hosts
|
328 |
cat <<EOF > /etc/hosts
|
322 |
127.0.0.1 localhost
|
329 |
127.0.0.1 localhost
|
323 |
$PRIVATE_IP $HOSTNAME
|
330 |
$PRIVATE_IP $HOSTNAME $HOSTNAME.$DOMAIN
|
324 |
EOF
|
331 |
EOF
|
325 |
|
332 |
|
326 |
# Ext Network Card config
|
333 |
# Ext Network Card config
|
327 |
$SED "s?^IPADDR=.*?IPADDR=$PUBLIC_IP?" /etc/sysconfig/network-scripts/ifcfg-$EXTIF
|
334 |
$SED "s?^IPADDR=.*?IPADDR=$PUBLIC_IP?" /etc/sysconfig/network-scripts/ifcfg-$EXTIF
|
328 |
$SED "s?^NETMASK=.*?NETMASK=$PUBLIC_NETMASK?" /etc/sysconfig/network-scripts/ifcfg-$EXTIF
|
335 |
$SED "s?^NETMASK=.*?NETMASK=$PUBLIC_NETMASK?" /etc/sysconfig/network-scripts/ifcfg-$EXTIF
|
Line 386... |
Line 393... |
386 |
then
|
393 |
then
|
387 |
/sbin/chkconfig --add sshd
|
394 |
/sbin/chkconfig --add sshd
|
388 |
/etc/init.d/sshd start
|
395 |
/etc/init.d/sshd start
|
389 |
else
|
396 |
else
|
390 |
/sbin/chkconfig --del sshd
|
397 |
/sbin/chkconfig --del sshd
|
- |
|
398 |
echo "Au redémarrage du serveur, le service SSH sera désactivé !!! ; au besoin l'activer dans l'interface de gestion."
|
- |
|
399 |
sleep 2
|
391 |
fi
|
400 |
fi
|
392 |
# Reload BL (restart DG, dnsmasq & iptables)
|
401 |
# Reload BL (restart DG, dnsmasq & iptables)
|
393 |
$DIR_SBIN/alcasar-bl.sh -reload
|
402 |
$DIR_SBIN/alcasar-bl.sh -reload
|
394 |
;;
|
403 |
;;
|
395 |
*)
|
404 |
*)
|