Subversion Repositories ALCASAR

Rev

Rev 2324 | Rev 2332 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log

Rev 2324 Rev 2327
Line 1... Line 1...
1
#!/bin/bash
1
#!/bin/bash
2
# $Id: alcasar-conf.sh 2324 2017-07-10 10:18:59Z tom.houdayer $
2
# $Id: alcasar-conf.sh 2327 2017-07-10 22:29:15Z 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
 
8
# Ce script permet la mise à jour ALCASAR 
8
# Ce script permet la mise à jour ALCASAR 
9
#	- création de l'archive des fichiers de configuration dans "/tmp/alcasar-conf.tar.gz" (alcasar-conf.sh -create)
9
#	- création de l'archive des fichiers de configuration dans "/tmp/alcasar-conf.tar.gz" (alcasar-conf.sh -create)
10
#	- chargement de l'archive de fichiers de configuration lors de la mise à jour d'un alcasar (alcasar-conf -load)
10
#	- chargement de l'archive de fichiers de configuration lors de la mise à jour d'un alcasar (alcasar-conf -load). Le cas échéant, c'est ici qu'on met à jour les fichiers entre versions 
11
#	- application des directives du fichier de conf central "/usr/local/etc/alcasar.conf" lors d'un changement de conf réseau à chaud (alcasar-conf -apply) 
11
#	- application des directives du fichier de conf central "/usr/local/etc/alcasar.conf" lors d'un changement de conf réseau à chaud (alcasar-conf -apply) 
12
# This script allows ALCASAR update 
12
# This script allows ALCASAR update 
13
#	- create the configuration files backup "/tmp/alcasar-conf.tar.gz" (alcasar-conf.sh -create)
13
#	- create the configuration files backup "/tmp/alcasar-conf.tar.gz" (alcasar-conf.sh -create)
14
#	- load the backup of configuration files during the update process (alcasar-conf -load)
14
#	- load the backup of configuration files during the update process (alcasar-conf -load). If needed, it's here we update files between versions
15
#	- apply ALCASAR central configuration file "/usr/local/etc/alcasar.conf" when hot modification is needed (alcasar-conf -apply)
15
#	- apply ALCASAR central configuration file "/usr/local/etc/alcasar.conf" when hot modification is needed (alcasar-conf -apply)
16
 
16
 
17
new="$(date +%G%m%d-%Hh%M)"  				# date et heure des fichiers
17
new="$(date +%G%m%d-%Hh%M)"  				# date et heure des fichiers
18
fichier="alcasar-conf-$new.tar.gz"			# nom du fichier de sauvegarde
18
fichier="alcasar-conf-$new.tar.gz"			# nom du fichier de sauvegarde
19
DIR_UPDATE="/tmp/conf"					# répertoire de stockage des fichier de conf pour une mise à jour
19
DIR_UPDATE="/tmp/conf"					# répertoire de stockage des fichier de conf pour une mise à jour
Line 153... Line 153...
153
		&& chown root.root /etc/sysconfig/dnsmasq \
153
		&& chown root.root /etc/sysconfig/dnsmasq \
154
		&& chmod 644 /etc/sysconfig/dnsmasq
154
		&& chmod 644 /etc/sysconfig/dnsmasq
155
# admin profile update (admin + manager + backup)
155
# admin profile update (admin + manager + backup)
156
		$DIR_BIN/alcasar-profil.sh --list
156
		$DIR_BIN/alcasar-profil.sh --list
157
# Start / Stop SSH Daemon
157
# Start / Stop SSH Daemon
158
		ssh_active=`grep SSH= $CONF_FILE|cut -d"=" -f2`
158
		ssh_active=`grep "^SSH=" $CONF_FILE|cut -d"=" -f2`
159
		if [ $ssh_active = "on" ]
159
		if [ $ssh_active = "on" ]
160
		then
160
		then
161
			/usr/bin/systemctl -q enable sshd.service
161
			/usr/bin/systemctl -q enable sshd.service
162
		else
162
		else
163
			/usr/bin/systemctl -q disable sshd.service
163
			/usr/bin/systemctl -q disable sshd.service
164
		fi
164
		fi
165
# Remove the update folder
165
# Remove the update folder
166
		rm -rf $DIR_UPDATE
166
		rm -rf $DIR_UPDATE
-
 
167
# If needed : write modifications between version
-
 
168
# V3.1.3
-
 
169
	# add "HTTPS_LOGIN=on" in conf file
-
 
170
		HTTPS_LOGIN=`grep -c "^HTTPS_LOGIN=" $CONF_FILE`
-
 
171
		if [ $HTTPS_LOGIN != "1" ]
-
 
172
		then
-
 
173
			echo "HTTPS_LOGIN=on" >> $CONF_FILE
-
 
174
		fi
167
		;;
175
		;;
168
	--apply|-apply)
176
	--apply|-apply)
169
		PTN="\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\/([012]?[0-9]|3[0-2])\b"
177
		PTN="\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\/([012]?[0-9]|3[0-2])\b"
170
		PRIVATE_IP_MASK=`grep ^PRIVATE_IP $CONF_FILE|cut -d"=" -f2`
178
		PRIVATE_IP_MASK=`grep ^PRIVATE_IP $CONF_FILE|cut -d"=" -f2`
171
		check=$(echo $PRIVATE_IP_MASK | egrep $PTN)
179
		check=$(echo $PRIVATE_IP_MASK | egrep $PTN)