Line 1... |
Line 1... |
1 |
#!/bin/bash
|
1 |
#!/bin/bash
|
2 |
# $Id: alcasar-conf.sh 2664 2018-11-19 17:35:12Z tom.houdayer $
|
2 |
# $Id: alcasar-conf.sh 2665 2018-12-06 21:03:45Z tom.houdayer $
|
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 116... |
Line 116... |
116 |
PREVIOUS_VERSION=`grep ^VERSION= $DIR_UPDATE/etc/alcasar.conf|cut -d"=" -f2`
|
116 |
PREVIOUS_VERSION=`grep ^VERSION= $DIR_UPDATE/etc/alcasar.conf|cut -d"=" -f2`
|
117 |
MAJ_PREVIOUS_VERSION=`echo $PREVIOUS_VERSION|cut -d"." -f1`
|
117 |
MAJ_PREVIOUS_VERSION=`echo $PREVIOUS_VERSION|cut -d"." -f1`
|
118 |
MIN_PREVIOUS_VERSION=`echo $PREVIOUS_VERSION|cut -d"." -f2`
|
118 |
MIN_PREVIOUS_VERSION=`echo $PREVIOUS_VERSION|cut -d"." -f2`
|
119 |
UPD_PREVIOUS_VERSION=`echo $PREVIOUS_VERSION|cut -d"." -f3|cut -c1`
|
119 |
UPD_PREVIOUS_VERSION=`echo $PREVIOUS_VERSION|cut -d"." -f3|cut -c1`
|
120 |
## From 3.2.0 & 3.2.1 ##
|
120 |
## From 3.2.0 & 3.2.1 ##
|
121 |
if [ $MAJ_PREVIOUS_VERSION == "3" ] && [ $MIN_PREVIOUS_VERSION == "2" ]
|
- |
|
122 |
then
|
- |
|
123 |
## rewrite /etc/hosts file managing hostname resolution
|
121 |
## rewrite /etc/hosts file managing hostname resolution
|
124 |
PRIVATE_IP=`grep ^PRIVATE_IP= $CONF_FILE|cut -d"=" -f2|cut -d"/" -f1`
|
122 |
PRIVATE_IP=`grep ^PRIVATE_IP= $CONF_FILE|cut -d"=" -f2|cut -d"/" -f1`
|
125 |
HOSTNAME=`grep ^HOSTNAME= $CONF_FILE|cut -d"=" -f2`
|
123 |
HOSTNAME=`grep ^HOSTNAME= $CONF_FILE|cut -d"=" -f2-`
|
126 |
domainNames="$HOSTNAME $HOSTNAME.$DOMAIN"
|
124 |
domainNames="$HOSTNAME $HOSTNAME.$DOMAIN"
|
127 |
[ "$HOSTNAME" != 'alcasar' ] && domainNames="alcasar $domainNames"
|
125 |
[ "$HOSTNAME" != 'alcasar' ] && domainNames="alcasar $domainNames"
|
- |
|
126 |
if [ $(grep -c "$PRIVATE_IP\s$domainNames" $DIR_UPDATE/etc/hosts ) -eq 0 ]; then
|
128 |
cat << EOF > $DIR_UPDATE/etc/hosts
|
127 |
cat << EOF > $DIR_UPDATE/etc/hosts
|
129 |
127.0.0.1 localhost
|
128 |
127.0.0.1 localhost
|
130 |
$PRIVATE_IP $domainNames
|
129 |
$PRIVATE_IP $domainNames
|
131 |
EOF
|
130 |
EOF
|
- |
|
131 |
fi
|
132 |
## apache & dansguardian are replaced with lighttpd & EĀ²guardian
|
132 |
## apache & dansguardian are replaced with lighttpd & EĀ²guardian
|
- |
|
133 |
if [ $(rpm -qa | grep '^\(apache\|apache-mod_php\|apache-mod_ssl\|dansguardian\)-' | wc -l) -ne 0 ]; then
|
133 |
rm_rpm="apache apache-mod_php apache-mod_ssl dansguardian"
|
134 |
rm_rpm="apache apache-mod_php apache-mod_ssl dansguardian"
|
134 |
/usr/sbin/urpme --auto -a $rm_rpm 2>/dev/null
|
135 |
/usr/sbin/urpme --auto -a $rm_rpm 2>/dev/null
|
135 |
/usr/sbin/urpme --auto --auto-orphans
|
136 |
/usr/sbin/urpme --auto --auto-orphans
|
136 |
rm -rf /etc/httpd/ /var/log/httpd/ /var/dansguardian/ /etc/dansguardian/
|
137 |
rm -rf /etc/httpd/ /var/log/httpd/ /var/dansguardian/ /etc/dansguardian/
|
137 |
## lighttpd need a .pem certificate (aggregation with private key & server crt)
|
- |
|
138 |
(cat $DIR_UPDATE/alcasar.key; echo; cat $DIR_UPDATE/alcasar.crt) > $DIR_UPDATE/alcasar.pem
|
- |
|
139 |
fi
|
138 |
fi
|
- |
|
139 |
## lighttpd need a .pem certificate (aggregation with private key & server crt)
|
- |
|
140 |
[ ! -f $DIR_UPDATE/alcasar.pem ] && (cat $DIR_UPDATE/alcasar.key; echo; cat $DIR_UPDATE/alcasar.crt) > $DIR_UPDATE/alcasar.pem
|
140 |
## From 3.3.0 ##
|
141 |
## From 3.3.0 ##
|
141 |
if [ $MAJ_PREVIOUS_VERSION == "3" ] && [ $MIN_PREVIOUS_VERSION == "3" ] && [ $UPD_PREVIOUS_VERSION == "0" ]
|
- |
|
142 |
then
|
- |
|
143 |
# add "SMS=off" in conf file
|
142 |
# add "SMS=off" in conf file
|
144 |
if [ $(grep -c '^SMS=' $DIR_UPDATE/etc/alcasar.conf) -eq 0 ]; then
|
143 |
if [ $(grep -c '^SMS=' $DIR_UPDATE/etc/alcasar.conf) -eq 0 ]; then
|
145 |
echo "SMS=off" >> $DIR_UPDATE/etc/alcasar.conf
|
144 |
echo "SMS=off" >> $DIR_UPDATE/etc/alcasar.conf
|
146 |
fi
|
145 |
fi
|
147 |
if [ $(grep -c '^SMS_NUM=' $DIR_UPDATE/etc/alcasar.conf) -eq 0 ]; then
|
146 |
if [ $(grep -c '^SMS_NUM=' $DIR_UPDATE/etc/alcasar.conf) -eq 0 ]; then
|
148 |
echo "SMS_NUM=" >> $DIR_UPDATE/etc/alcasar.conf
|
147 |
echo "SMS_NUM=" >> $DIR_UPDATE/etc/alcasar.conf
|
149 |
fi
|
- |
|
150 |
fi
|
148 |
fi
|
151 |
###################### End of modifications between versions #######################
|
149 |
###################### End of modifications between versions #######################
|
152 |
# Retrieve the logo
|
150 |
# Retrieve the logo
|
153 |
[ -e $DIR_UPDATE/organisme.png ] && cp -f $DIR_UPDATE/organisme.png $DIR_WEB/images/
|
151 |
[ -e $DIR_UPDATE/organisme.png ] && cp -f $DIR_UPDATE/organisme.png $DIR_WEB/images/
|
154 |
chown apache:apache $DIR_WEB/images/organisme.png $DIR_WEB/intercept.php
|
152 |
chown apache:apache $DIR_WEB/images/organisme.png $DIR_WEB/intercept.php
|