From 9f8d13802bc60deda24e2de9058bfa1a635a93cb Mon Sep 17 00:00:00 2001
From: David Beniamine <david.beniamine@tetras-libre.fr>
Date: Mon, 18 Feb 2019 23:10:54 +0100
Subject: [PATCH] Update server name on configuration import

---
 do_postinstall.sh |  6 +-----
 do_preinstall.sh  |  4 +++-
 eole/config.eol   |  3 +--
 import_config.sh  | 17 +++++++++++++++++
 4 files changed, 22 insertions(+), 8 deletions(-)
 create mode 100755 import_config.sh

diff --git a/do_postinstall.sh b/do_postinstall.sh
index 7050709..c107016 100755
--- a/do_postinstall.sh
+++ b/do_postinstall.sh
@@ -38,12 +38,8 @@ echo "Updating eole"
 Maj-Auto
 
 # Configure
-echo "Copying configuration"
-cp -v $DIR/eole/config.eol /etc/eole/
-cp -v $DIR/eole/creole/* /usr/share/eole/creole/modif
-cp -v $DIR/eole/era/* /usr/share/era/modeles
+$DIR/import_config.sh
 
-gen_patch
 echo "Please set the school network IP, save and quit the configurator"
 gen_config
 echo "Configuring server"
diff --git a/do_preinstall.sh b/do_preinstall.sh
index f00b43f..0f1550b 100755
--- a/do_preinstall.sh
+++ b/do_preinstall.sh
@@ -49,7 +49,9 @@ safe_run Maj-Auto
 echo "Generating containers"
 safe_run gen_conteneurs
 
-cp -v $DIR/eole/config.eol /etc/eole/
+
+$DIR/import_config.sh
+
 echo "Generating initial config"
 safe_run gen_config
 
diff --git a/eole/config.eol b/eole/config.eol
index ea9867d..58d552e 100644
--- a/eole/config.eol
+++ b/eole/config.eol
@@ -1,2 +1 @@
-{"bareos_dir_name": {"owner": "forced", "val": "amonecole-dir"}, "type_amon": {"owner": "gen_config", "val": "2zones-amonecole-cuques"}, "adresse_ip_eth1_proxy_link": {"owner": "gen_config", "val": "10.20.1.2"}, "activer_ajout_hosts": {"owner": "gen_config", "val": "oui"}, "nom_domaine_local": {"owner": "gen_config", "val": "ecoletest.plandecuques.fr"}, "nom_court_hosts": {"owner": {"0": "gen_config"}, "val": {"0": "dnsproxy"}}, "activer_squid_auth": {"owner": "gen_config", "val": "non"}, "bareos_sd_password": {"owner": "forced", "val": "01006d73c6f13edbff49539ea6a50b744c26d4f1380cfad072df4daf"}, "adresse_ip_hosts": {"owner": "gen_config", "val": ["10.20.1.2"]}, "bareos_db_mysql_password": {"owner": "gen_config", "val": "38a0a5ed7180cb6fc3660b4049dc111deecf5e67aed721e839e88536"}, "adresse_ip_fichier_link": {"owner": "gen_config", "val": "10.20.1.3"}, "nom_machine": {"owner": "gen_config", "val": "ecoletest"}, "bareos_dir_password": {"owner": "forced", "val": "548c71a8e99ce2452009f2d21d225da30e6f2bba95cb05bfc8cf7b98"}, "ip_haute_dhcp": {"owner":
- {"0": "gen_config"}, "val": {"0": "10.20.1.254"}}, "domaine_messagerie_etab": {"owner": "gen_config", "val": "test.ac-marseille.fr"}, "___version___": "2.6.2", "nom_long_hosts": {"owner": {"0": "gen_config"}, "val": {"0": "dnsproxy.ecoletest.plandecuques.fr"}}, "activer_dhcp": {"owner": "gen_config", "val": "oui"}, "ip_basse_dhcp": {"owner": {"0": "gen_config"}, "val": {"0": "10.20.1.20"}}, "activer_tftp": {"owner": "gen_config", "val": "oui"}, "bareos_fd_password": {"owner": "forced", "val": "0d2b71cdcc90c4367dcd47fe16bd7d308b7e22aca4c4fe36014c22e0"}, "nom_plage_dhcp": {"owner": {"0": "gen_config"}, "val": {"0": "ecole"}}, "system_mail_to": {"owner": "gen_config", "val": "root@test.ac-marseille.fr"}, "eth0_method": {"owner": "gen_config", "val": "dhcp"}, "activer_ead_web": {"owner": "gen_config", "val": "oui"}, "ip_admin_eth0": {"owner": "gen_config", "val": ["192.168.211.228"]}, "cert_type": {"owner": "gen_config", "val": "autosign\u00e9"}, "ip_admin_eth1": {"owner": "gen_config", "val": ["10.20.0.30"]}, "numero_etab": {"owner": "gen_config", "val": "test"}, "netmask_admin_eth1": {"owner": {"0": "gen_config"}, "val": {"0": "255.255.255.255"}}, "netmask_admin_eth0": {"owner": {"0": "gen_config"}, "val": {"0": "255.255.255.255"}}, "activer_ftp_anonymous_access": {"owner": "gen_config", "val": "oui"}, "smb_share_model": {"owner": "gen_config", "val": "commun"}, "bareos_db_type": {"owner": "forced", "val": "mysql"}, "esu_proxy_default": {"owner": "forced", "val": "oui"}, "nom_academie": {"owner": "gen_config", "val": "ac-marseille"}, "ip_ssh_eth1": {"owner": "gen_config", "val": ["10.20.1.1"]}, "ip_ssh_eth0": {"owner": "gen_config", "val": ["192.168.211.228", "193.33.56.228"]}, "libelle_etab": {"owner": "gen_config", "val": "test"}, "smb_workgroup": {"owner": "gen_config", "val": "ecole-wg"}, "smb_netbios_name": {"owner": "gen_config", "val": "ecole-srv"}, "netmask_ssh_eth0": {"owner": {"1": "gen_config", "0": "gen_config"}, "val": {"1": "255.255.255.255", "0": "255.255.255.255"}}, "netmask_ssh_eth1": {"owner": {"0": "gen_config"}, "val": {"0": "255.255.255.255"}}, "omapi_secret": {"owner": "forced", "val": "42f0707bbf047e86da7fb90aa0752f750503be5899135f2ea6542a34"}, "activer_exim_relay_smtp": {"owner": "gen_config", "val": "non"}, "adresse_ip_eth1": {"owner": "gen_config", "val": "10.20.1.1"}, "web_url": {"owner": "gen_config", "val": "test.ac-marseille.fr"}, "activer_ead3": {"owner": "gen_config", "val": "oui"}, "ftp_anonymous_directory": {"owner": "gen_config", "val": "/var/lib/tftpboot/public"}, "repertoire_tftp": {"owner": "gen_config", "val": "/var/lib/tftpboot/"}}
+{"bareos_dir_name": {"owner": "forced", "val": "amonecole-dir"}, "type_amon": {"owner": "gen_config", "val": "2zones-amonecole-cuques"}, "adresse_ip_eth1_proxy_link": {"owner": "gen_config", "val": "10.20.1.2"}, "activer_ajout_hosts": {"owner": "gen_config", "val": "oui"}, "nom_domaine_local": {"owner": "gen_config", "val": "malraux1.plandecuques.fr"}, "nom_court_hosts": {"owner": {"0": "gen_config"}, "val": {"0": "dnsproxy"}}, "activer_squid_auth": {"owner": "gen_config", "val": "non"}, "bareos_sd_password": {"owner": "forced", "val": "01006d73c6f13edbff49539ea6a50b744c26d4f1380cfad072df4daf"}, "adresse_ip_hosts": {"owner": "gen_config", "val": ["10.20.1.2"]}, "bareos_db_mysql_password": {"owner": "gen_config", "val": "38a0a5ed7180cb6fc3660b4049dc111deecf5e67aed721e839e88536"}, "adresse_ip_fichier_link": {"owner": "gen_config", "val": "10.20.1.3"}, "nom_machine": {"owner": "gen_config", "val": "amonecole"}, "bareos_dir_password": {"owner": "forced", "val": "548c71a8e99ce2452009f2d21d225da30e6f2bba95cb05bfc8cf7b98"}, "ip_haute_dhcp": {"owner": {"0": "gen_config"}, "val": {"0": "10.20.1.254"}}, "domaine_messagerie_etab": {"owner": "gen_config", "val": "malraux1.plandecuques.fr"}, "___version___": "2.6.2", "esu_proxy": {"owner": "gen_config", "val": "oui"}, "activer_dhcp": {"owner": "gen_config", "val": "oui"}, "ip_basse_dhcp": {"owner": {"0": "gen_config"}, "val": {"0": "10.20.1.20"}}, "activer_tftp": {"owner": "gen_config", "val": "oui"}, "bareos_fd_password": {"owner": "forced", "val": "0d2b71cdcc90c4367dcd47fe16bd7d308b7e22aca4c4fe36014c22e0"}, "nom_plage_dhcp": {"owner": {"0": "gen_config"}, "val": {"0": "ecole"}}, "system_mail_to": {"owner": "gen_config", "val": "root@malraux1.plandecuques.fr"}, "eth0_method": {"owner": "gen_config", "val": "dhcp"}, "activer_ead_web": {"owner": "gen_config", "val": "oui"}, "ip_admin_eth0": {"owner": "gen_config", "val": ["192.168.3.208", "193.33.56.228", "84.240.95.168"]}, "cert_type": {"owner": "gen_config", "val": "autosign\u00e9"}, "ip_admin_eth1": {"owner": "gen_config", "val": ["10.20.1.24"]}, "numero_etab": {"owner": "gen_config", "val": "malraux1"}, "nom_long_hosts": {"owner": {"0": "gen_config"}, "val": {"0": "dnsproxy.malraux1.plandecuques.fr"}}, "netmask_admin_eth1": {"owner": {"0": "gen_config"}, "val": {"0": "255.255.255.255"}}, "netmask_admin_eth0": {"owner": {"1": "gen_config", "0": "gen_config", "2": "gen_config"}, "val": {"1": "255.255.255.255", "0": "255.255.255.255", "2": "255.255.255.255"}}, "activer_ftp_anonymous_access": {"owner": "gen_config", "val": "oui"}, "smb_share_model": {"owner": "gen_config", "val": "commun"}, "bareos_db_type": {"owner": "forced", "val": "mysql"}, "esu_proxy_default": {"owner": "forced", "val": "oui"}, "nom_academie": {"owner": "gen_config", "val": "ac-marseille"}, "ip_ssh_eth1": {"owner": "gen_config", "val": ["10.20.1.1"]}, "ip_ssh_eth0": {"owner": "gen_config", "val": ["192.168.3.208", "193.33.56.228", "84.240.95.168", "192.168.3.210"]}, "libelle_etab": {"owner": "gen_config", "val": "malraux1"}, "smb_workgroup": {"owner": "gen_config", "val": "ecole-wg"}, "ftp_anonymous_directory": {"owner": "gen_config", "val": "/var/lib/tftpboot/public"}, "smb_netbios_name": {"owner": "gen_config", "val": "ecole-srv"}, "netmask_ssh_eth0": {"owner": {"1": "gen_config", "0": "gen_config", "3": "gen_config", "2": "gen_config"}, "val": {"1": "255.255.255.255", "0": "255.255.255.255", "3": "255.255.255.255", "2": "255.255.255.255"}}, "netmask_ssh_eth1": {"owner": {"0": "gen_config"}, "val": {"0": "255.255.255.255"}}, "omapi_secret": {"owner": "forced", "val": "42f0707bbf047e86da7fb90aa0752f750503be5899135f2ea6542a34"}, "activer_exim_relay_smtp": {"owner": "gen_config", "val": "non"}, "adresse_ip_eth1": {"owner": "gen_config", "val": "10.20.1.1"}, "adresse_ip_eth2": {"owner": "gen_config", "val": "10.20.2.1"}, "web_url": {"owner": "gen_config", "val": "malraux1.plandecuques.fr"}, "adresse_ip_eth2_proxy_link": {"owner": "gen_config", "val": "10.20.2.2"}, "activer_ead3": {"owner": "gen_config", "val": "oui"}, "nombre_interfaces": {"owner": "gen_config", "val": "2"}, "repertoire_tftp": {"owner": "gen_config", "val": "/var/lib/tftpboot/"}}
\ No newline at end of file
diff --git a/import_config.sh b/import_config.sh
new file mode 100755
index 0000000..a5a9c4a
--- /dev/null
+++ b/import_config.sh
@@ -0,0 +1,17 @@
+#!/bin/bash
+
+DIR=`dirname $0`
+srvname=`cat $DIR/srvname`
+if [ -z "$1" ]
+then
+    echo "Veuillez entrer le nom du serveur (ex: malraux1) :"
+    read $srvname
+    echo $srvname > $DIR/srvname
+fi
+
+echo "Copying configuration"
+sed -e "s/malraux1/$srvname/g" $DIR/eole/config.eol > /etc/eole/config.eol
+cp -v $DIR/eole/creole/* /usr/share/eole/creole/modif
+cp -v $DIR/eole/era/* /usr/share/era/modeles
+
+gen_patch
-- 
GitLab