Line 1... |
Line 1... |
1 |
#!/bin/bash
|
1 |
#!/bin/bash
|
2 |
# $Id: alcasar-conf.sh 2874 2020-10-31 13:54:28Z rexy $
|
2 |
# $Id: alcasar-conf.sh 2875 2020-11-01 10:50:57Z rexy $
|
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 24... |
Line 24... |
24 |
EXTIF=`grep ^EXTIF= $CONF_FILE|cut -d"=" -f2` # EXTernal InterFace
|
24 |
EXTIF=`grep ^EXTIF= $CONF_FILE|cut -d"=" -f2` # EXTernal InterFace
|
25 |
INTIF=`grep ^INTIF= $CONF_FILE|cut -d"=" -f2` # INTernal InterFace
|
25 |
INTIF=`grep ^INTIF= $CONF_FILE|cut -d"=" -f2` # INTernal InterFace
|
26 |
MTU=`grep ^PUBLIC_MTU= $CONF_FILE|cut -d"=" -f2`
|
26 |
MTU=`grep ^PUBLIC_MTU= $CONF_FILE|cut -d"=" -f2`
|
27 |
DHCP_mode=`grep ^DHCP= $CONF_FILE|cut -d"=" -f2`
|
27 |
DHCP_mode=`grep ^DHCP= $CONF_FILE|cut -d"=" -f2`
|
28 |
INT_DNS_mode=`grep ^INT_DNS_ACTIVE= $CONF_FILE|cut -d"=" -f2`
|
28 |
INT_DNS_mode=`grep ^INT_DNS_ACTIVE= $CONF_FILE|cut -d"=" -f2`
|
29 |
LDAP_mode=`grep ^LDAP= $CONF_FILE|cut -d"=" -f2`
|
- |
|
30 |
HOSTNAME=`grep ^HOSTNAME= $CONF_FILE|cut -d"=" -f2`
|
29 |
HOSTNAME=`grep ^HOSTNAME= $CONF_FILE|cut -d"=" -f2`
|
31 |
DOMAIN=`grep ^DOMAIN= $CONF_FILE|cut -d"=" -f2`
|
30 |
DOMAIN=`grep ^DOMAIN= $CONF_FILE|cut -d"=" -f2`
|
32 |
SED="/bin/sed -i"
|
31 |
SED="/bin/sed -i"
|
33 |
DNS1=`grep ^DNS1= $CONF_FILE | cut -d'=' -f2` # server DNS1 (for WL domain names)
|
32 |
DNS1=`grep ^DNS1= $CONF_FILE | cut -d'=' -f2` # server DNS1 (for WL domain names)
|
34 |
DOMAIN=${DOMAIN:=localdomain}
|
33 |
DOMAIN=${DOMAIN:=localdomain}
|
Line 97... |
Line 96... |
97 |
if [ -e /etc/pki/tls/certs/server-chain.pem ]; then
|
96 |
if [ -e /etc/pki/tls/certs/server-chain.pem ]; then
|
98 |
cp -f /etc/pki/tls/certs/server-chain.pem $DIR_UPDATE # autosigned and official if exist
|
97 |
cp -f /etc/pki/tls/certs/server-chain.pem $DIR_UPDATE # autosigned and official if exist
|
99 |
else
|
98 |
else
|
100 |
cp -f /etc/pki/tls/certs/alcasar.crt $DIR_UPDATE/server-chain.pem
|
99 |
cp -f /etc/pki/tls/certs/alcasar.crt $DIR_UPDATE/server-chain.pem
|
101 |
fi
|
100 |
fi
|
- |
|
101 |
# backup gammu conf file (if necessary)
|
- |
|
102 |
SMS=`grep ^SMS= $CONF_FILE|cut -d"=" -f2`
|
- |
|
103 |
if [ "$SMS" == "on" ]
|
- |
|
104 |
then
|
- |
|
105 |
cp -f /etc/gammurc $DIR_UPDATE
|
- |
|
106 |
cp -f /etc/gammu_smsd_conf $DIR_UPDATE
|
- |
|
107 |
fi
|
102 |
# archive file creation
|
108 |
# archive file creation
|
103 |
cd /var/tmp || { echo "Unable to find /var/tmp directory"; }
|
109 |
cd /var/tmp || { echo "Unable to find /var/tmp directory"; }
|
104 |
tar -cf alcasar-conf.tar conf/
|
110 |
tar -cf alcasar-conf.tar conf/
|
105 |
gzip -f alcasar-conf.tar
|
111 |
gzip -f alcasar-conf.tar
|
106 |
cp alcasar-conf.tar.gz /var/www/html/acc/backup/alcasar-conf.tar.gz
|
112 |
cp alcasar-conf.tar.gz /var/www/html/acc/backup/alcasar-conf.tar.gz
|
Line 117... |
Line 123... |
117 |
# copy alcasar.conf parameters
|
123 |
# copy alcasar.conf parameters
|
118 |
PREVIOUS_VERSION=`grep ^VERSION= $DIR_UPDATE/etc/alcasar.conf|cut -d"=" -f2`
|
124 |
PREVIOUS_VERSION=`grep ^VERSION= $DIR_UPDATE/etc/alcasar.conf|cut -d"=" -f2`
|
119 |
MAJ_PREVIOUS_VERSION=`echo $PREVIOUS_VERSION|cut -d"." -f1`
|
125 |
MAJ_PREVIOUS_VERSION=`echo $PREVIOUS_VERSION|cut -d"." -f1`
|
120 |
MIN_PREVIOUS_VERSION=`echo $PREVIOUS_VERSION|cut -d"." -f2`
|
126 |
MIN_PREVIOUS_VERSION=`echo $PREVIOUS_VERSION|cut -d"." -f2`
|
121 |
UPD_PREVIOUS_VERSION=`echo $PREVIOUS_VERSION|cut -d"." -f3|cut -c1`
|
127 |
UPD_PREVIOUS_VERSION=`echo $PREVIOUS_VERSION|cut -d"." -f3|cut -c1`
|
122 |
for line in `cat $DIR_UPDATE/etc/alcasar.conf | grep "=" | grep -Ev "^#| |VERSION|INSTALL_DATE|PUBLIC|GW|SMS|EXTIF|INTIF"`
|
128 |
for line in `cat $DIR_UPDATE/etc/alcasar.conf | grep "=" | grep -Ev "^#| |VERSION|INSTALL_DATE|PUBLIC|GW|EXTIF|INTIF"`
|
123 |
do
|
129 |
do
|
124 |
key=`echo $line | cut -d"=" -f1`
|
130 |
key=`echo $line | cut -d"=" -f1`
|
125 |
key=$key=
|
131 |
key=$key=
|
126 |
value=`echo $line|cut -d"=" -f2-`
|
132 |
value=`echo $line|cut -d"=" -f2-`
|
127 |
if [ "$value" != "" ]
|
133 |
if [ "$value" != "" ]
|
Line 160... |
Line 166... |
160 |
[ -e $DIR_UPDATE/etc/alcasar-ethers ] && cp -f $DIR_UPDATE/etc/alcasar-ethers $DIR_ETC/ # DHCP static hosts
|
166 |
[ -e $DIR_UPDATE/etc/alcasar-ethers ] && cp -f $DIR_UPDATE/etc/alcasar-ethers $DIR_ETC/ # DHCP static hosts
|
161 |
[ -e $DIR_UPDATE/etc/alcasar-ethers-info ] && cp -f $DIR_UPDATE/etc/alcasar-ethers-info $DIR_ETC/ # DHCP static hosts information
|
167 |
[ -e $DIR_UPDATE/etc/alcasar-ethers-info ] && cp -f $DIR_UPDATE/etc/alcasar-ethers-info $DIR_ETC/ # DHCP static hosts information
|
162 |
[ -e $DIR_UPDATE/etc/hosts ] && cp -f $DIR_UPDATE/etc/hosts /etc/ # local host name resolution
|
168 |
[ -e $DIR_UPDATE/etc/hosts ] && cp -f $DIR_UPDATE/etc/hosts /etc/ # local host name resolution
|
163 |
[ -e $DIR_UPDATE/etc/alcasar-letsencrypt ] && cp -f $DIR_UPDATE/etc/alcasar-letsencrypt $DIR_ETC/ # Letsencrypt local conf
|
169 |
[ -e $DIR_UPDATE/etc/alcasar-letsencrypt ] && cp -f $DIR_UPDATE/etc/alcasar-letsencrypt $DIR_ETC/ # Letsencrypt local conf
|
164 |
[ -d $DIR_UPDATE/etc/letsencrypt ] && cp -rf $DIR_UPDATE/etc/letsencrypt $DIR_ETC/ # Letsencrypt local conf files
|
170 |
[ -d $DIR_UPDATE/etc/letsencrypt ] && cp -rf $DIR_UPDATE/etc/letsencrypt $DIR_ETC/ # Letsencrypt local conf files
|
- |
|
171 |
[ -e $DIR_UPDATE/gammurc ] && cp -f $DIR_UPDATE/gammurc /etc/ # Gammu conf file
|
- |
|
172 |
[ -e $DIR_UPDATE/gammu_smsd_conf ] && cp -f $DIR_UPDATE/gammu_smsd_conf /etc/ # Gammu_smsd conf file
|
165 |
# Retrieve BL/WL custom files
|
173 |
# Retrieve BL/WL custom files
|
166 |
cp -f $DIR_UPDATE/custom_bl/exceptioniplist $DIR_E2G/
|
174 |
cp -f $DIR_UPDATE/custom_bl/exceptioniplist $DIR_E2G/
|
167 |
cp -f $DIR_UPDATE/custom_bl/exceptionsitelist $DIR_E2G/
|
175 |
cp -f $DIR_UPDATE/custom_bl/exceptionsitelist $DIR_E2G/
|
168 |
cp -f $DIR_UPDATE/custom_bl/urlregexplist $DIR_E2G/
|
176 |
cp -f $DIR_UPDATE/custom_bl/urlregexplist $DIR_E2G/
|
169 |
cp -f $DIR_UPDATE/custom_bl/bannedsitelist $DIR_E2G/
|
177 |
cp -f $DIR_UPDATE/custom_bl/bannedsitelist $DIR_E2G/
|
Line 494... |
Line 502... |
494 |
then
|
502 |
then
|
495 |
/usr/bin/systemctl stop sshd.service
|
503 |
/usr/bin/systemctl stop sshd.service
|
496 |
fi
|
504 |
fi
|
497 |
fi
|
505 |
fi
|
498 |
# Start / Stop LDAP authentification
|
506 |
# Start / Stop LDAP authentification
|
499 |
if [ $LDAP_mode = "on" ] || [ $LDAP_mode = "On" ] || [ $LDAP_mode = "ON" ]
|
507 |
if [ "$PARENT_SCRIPT" != "alcasar.sh" ] # don't launch on install stage
|
500 |
then
|
508 |
then
|
- |
|
509 |
LDAP_mode=`grep ^LDAP= $CONF_FILE|cut -d"=" -f2`
|
- |
|
510 |
if [ $LDAP_mode = "on" ]
|
- |
|
511 |
then
|
501 |
$DIR_BIN/alcasar-ldap.sh --on
|
512 |
$DIR_BIN/alcasar-ldap.sh --on
|
502 |
else
|
513 |
else
|
503 |
$DIR_BIN/alcasar-ldap.sh --off
|
514 |
$DIR_BIN/alcasar-ldap.sh --off
|
- |
|
515 |
fi
|
- |
|
516 |
fi
|
- |
|
517 |
# Start / Stop Gammu-smsd (SMS)
|
- |
|
518 |
if [ "$PARENT_SCRIPT" != "alcasar.sh" ] # don't launch on install stage
|
- |
|
519 |
then
|
- |
|
520 |
SMS_mode=`grep ^SMS= $CONF_FILE|cut -d"=" -f2`
|
- |
|
521 |
if [ $SMS_mode = "on" ]
|
- |
|
522 |
then
|
- |
|
523 |
$DIR_BIN/alcasar-sms.sh --start
|
- |
|
524 |
fi
|
504 |
fi
|
525 |
fi
|
505 |
echo
|
526 |
echo
|
506 |
;;
|
527 |
;;
|
507 |
*)
|
528 |
*)
|
508 |
echo "Argument inconnu : $1";
|
529 |
echo "Argument inconnu : $1";
|