From eb30524030c6e6eeea06ed629979c5232185ebb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Diemer?= <stephane.diemer@ubicast.eu> Date: Thu, 2 Feb 2017 09:40:54 +0100 Subject: [PATCH] Changed config management. --- 10.VM/1.Export_VM/0_setup.sh | 2 +- 10.VM/2.Export_VM_local/0_setup.sh | 2 +- 2.Common_services/6.Munin/0_setup.sh | 2 +- .../1.Apply_client_configuration/0_setup.sh | 2 +- .../2.Dump_config/0_setup.sh | 2 +- .../3.Configure_client_smtp/0_setup.sh | 2 +- .../4.Apply_default_configuration/0_setup.sh | 2 +- .../5.Insert_wowza_license/0_setup.sh | 2 +- .../1.Download_envsetup_config/0_setup.sh | 9 ++++++--- .../2.Fill_empty_conf/0_setup.sh | 8 ++++++-- .../3.Initialize_APT/0_setup.sh | 2 +- .../4.Dell_openmanage/0_setup.sh | 2 +- .../1.Install_MediaServer/0_setup.sh | 2 +- 5.MediaServer/3.Install_MS_deploy/0_setup.sh | 2 +- .../1.Install_CampusManager/0_setup.sh | 2 +- 8.Cache/1.Install_cache/0_setup.sh | 2 +- .../2.Deploy_munin_configuration/0_setup.sh | 2 +- 8.Cache/3.Install_ferm/0_setup.sh | 2 +- 9.MediaVault/1.Install_MediaVault/0_setup.sh | 2 +- conf.sh | 4 +--- envsetup.py | 1 - default-conf.sh => global-conf.sh | 19 ++++++++++++++++++- utils.py | 7 +++++-- 23 files changed, 53 insertions(+), 29 deletions(-) rename {20.Client configuration & testing => 20.Client_configuration}/1.Apply_client_configuration/0_setup.sh (99%) rename {20.Client configuration & testing => 20.Client_configuration}/2.Dump_config/0_setup.sh (98%) rename {20.Client configuration & testing => 20.Client_configuration}/3.Configure_client_smtp/0_setup.sh (80%) rename {20.Client configuration & testing => 20.Client_configuration}/4.Apply_default_configuration/0_setup.sh (95%) rename {20.Client configuration & testing => 20.Client_configuration}/5.Insert_wowza_license/0_setup.sh (85%) rename default-conf.sh => global-conf.sh (86%) diff --git a/10.VM/1.Export_VM/0_setup.sh b/10.VM/1.Export_VM/0_setup.sh index 66e77a00..4f92fdb1 100755 --- a/10.VM/1.Export_VM/0_setup.sh +++ b/10.VM/1.Export_VM/0_setup.sh @@ -1,5 +1,5 @@ #!/bin/bash -source /root/envsetup/conf.sh +source /root/envsetup/global-conf.sh KEY=~/.ssh/ubicast_support VM_HYPER=$(grep VM_HYPER ${CONF} | awk -F "=" '{print$2}') diff --git a/10.VM/2.Export_VM_local/0_setup.sh b/10.VM/2.Export_VM_local/0_setup.sh index 5ce30466..2c4a320c 100755 --- a/10.VM/2.Export_VM_local/0_setup.sh +++ b/10.VM/2.Export_VM_local/0_setup.sh @@ -1,5 +1,5 @@ #!/bin/bash -source /root/envsetup/conf.sh +source /root/envsetup/global-conf.sh VM_STORE=/home/jallary/ubicast/TMP/ENVOI VM_STORE_LOCAL=/home/jallary/ubicast/TMP/ENVOI diff --git a/2.Common_services/6.Munin/0_setup.sh b/2.Common_services/6.Munin/0_setup.sh index f779b19d..9bad0efc 100755 --- a/2.Common_services/6.Munin/0_setup.sh +++ b/2.Common_services/6.Munin/0_setup.sh @@ -1,5 +1,5 @@ #!/bin/bash -source /root/envsetup/conf.sh +source /root/envsetup/global-conf.sh # This script should be run after Nginx, MySQL and Wowza setup (if they should be installed) diff --git a/20.Client configuration & testing/1.Apply_client_configuration/0_setup.sh b/20.Client_configuration/1.Apply_client_configuration/0_setup.sh similarity index 99% rename from 20.Client configuration & testing/1.Apply_client_configuration/0_setup.sh rename to 20.Client_configuration/1.Apply_client_configuration/0_setup.sh index 7b8c2eb1..c57465cf 100755 --- a/20.Client configuration & testing/1.Apply_client_configuration/0_setup.sh +++ b/20.Client_configuration/1.Apply_client_configuration/0_setup.sh @@ -1,5 +1,5 @@ #!/bin/bash -source /root/envsetup/conf.sh +source /root/envsetup/global-conf.sh echo -e " ${RED}Customer parameters will be applied after rebooting. Note that you won't be able to login to the machine after this operation !${NC}" diff --git a/20.Client configuration & testing/2.Dump_config/0_setup.sh b/20.Client_configuration/2.Dump_config/0_setup.sh similarity index 98% rename from 20.Client configuration & testing/2.Dump_config/0_setup.sh rename to 20.Client_configuration/2.Dump_config/0_setup.sh index 36381460..f6c17e96 100755 --- a/20.Client configuration & testing/2.Dump_config/0_setup.sh +++ b/20.Client_configuration/2.Dump_config/0_setup.sh @@ -1,5 +1,5 @@ #!/bin/bash -source /root/envsetup/conf.sh +source /root/envsetup/global-conf.sh # generate post-deployment conf file echo "SOURCES.LIST" > /root/deployment.results diff --git a/20.Client configuration & testing/3.Configure_client_smtp/0_setup.sh b/20.Client_configuration/3.Configure_client_smtp/0_setup.sh similarity index 80% rename from 20.Client configuration & testing/3.Configure_client_smtp/0_setup.sh rename to 20.Client_configuration/3.Configure_client_smtp/0_setup.sh index 41247330..2b220b13 100755 --- a/20.Client configuration & testing/3.Configure_client_smtp/0_setup.sh +++ b/20.Client_configuration/3.Configure_client_smtp/0_setup.sh @@ -1,5 +1,5 @@ #!/bin/bash -source /root/envsetup/conf.sh +source /root/envsetup/global-conf.sh # set SMTP if ( ! test -z ${EMAIL_SMTP_SERVER} ) diff --git a/20.Client configuration & testing/4.Apply_default_configuration/0_setup.sh b/20.Client_configuration/4.Apply_default_configuration/0_setup.sh similarity index 95% rename from 20.Client configuration & testing/4.Apply_default_configuration/0_setup.sh rename to 20.Client_configuration/4.Apply_default_configuration/0_setup.sh index e3527b7a..0d386929 100755 --- a/20.Client configuration & testing/4.Apply_default_configuration/0_setup.sh +++ b/20.Client_configuration/4.Apply_default_configuration/0_setup.sh @@ -1,5 +1,5 @@ #!/bin/bash -source /root/envsetup/conf.sh +source /root/envsetup/global-conf.sh # apply MS default network parameters sudo sed -i "s@address .*@address 192.168.1.10@" /etc/network/interfaces diff --git a/20.Client configuration & testing/5.Insert_wowza_license/0_setup.sh b/20.Client_configuration/5.Insert_wowza_license/0_setup.sh similarity index 85% rename from 20.Client configuration & testing/5.Insert_wowza_license/0_setup.sh rename to 20.Client_configuration/5.Insert_wowza_license/0_setup.sh index 8487c869..28bc4fb7 100755 --- a/20.Client configuration & testing/5.Insert_wowza_license/0_setup.sh +++ b/20.Client_configuration/5.Insert_wowza_license/0_setup.sh @@ -1,5 +1,5 @@ #!/bin/bash -source /root/envsetup/conf.sh +source /root/envsetup/global-conf.sh echo "Insert wowza license key :" read WOWZA_LICENSE2 diff --git a/3.New_server_deployment/1.Download_envsetup_config/0_setup.sh b/3.New_server_deployment/1.Download_envsetup_config/0_setup.sh index dc20e09b..c19ee5c1 100755 --- a/3.New_server_deployment/1.Download_envsetup_config/0_setup.sh +++ b/3.New_server_deployment/1.Download_envsetup_config/0_setup.sh @@ -1,14 +1,17 @@ #!/bin/bash -source /root/envsetup/conf.sh +source /root/envsetup/global-conf.sh # Download config file from skyreach if ( ! test -z ${SKYREACH_API_KEY} ); then conf_url="https://$SKYREACH_HOST/erp/credentials/$SKYREACH_API_KEY/conf.sh" if ( curl -I "$conf_url" >/dev/null ); then - wget -q "$conf_url" -O /root/envsetup/conf.sh - source /root/envsetup/conf.sh + wget -q "$conf_url" -O /root/envsetup/auto-generated-conf.sh + echo "Config file updated." + source /root/envsetup/global-conf.sh else echo "Failed to download configuration using url:" echo " $conf_url" fi +else + echo "No API key for $SKYREACH_HOST. The config will not be downloaded." fi diff --git a/3.New_server_deployment/2.Fill_empty_conf/0_setup.sh b/3.New_server_deployment/2.Fill_empty_conf/0_setup.sh index a5a93531..197aaeb9 100755 --- a/3.New_server_deployment/2.Fill_empty_conf/0_setup.sh +++ b/3.New_server_deployment/2.Fill_empty_conf/0_setup.sh @@ -1,5 +1,5 @@ #!/bin/bash -source /root/envsetup/conf.sh +source /root/envsetup/global-conf.sh # Autogenerate missing values if [ "${MS_ID}" = "" ]; then @@ -9,6 +9,7 @@ if [ "${MS_ID}" = "" ]; then else echo "MS_ID='${MS_ID}'" >> /root/envsetup/conf.sh fi + echo "The config MS_ID has been set." fi if [ "${MS_API_KEY}" = "" ]; then MS_API_KEY=$(echo "s$(pwgen 4)-$(pwgen 5)-$(pwgen 5)-$(pwgen 5)-$(pwgen 5)") @@ -19,6 +20,7 @@ if [ "${MS_API_KEY}" = "" ]; then else echo "MS_API_KEY='${MS_API_KEY}'" >> /root/envsetup/conf.sh fi + echo "The config MS_API_KEY has been set." fi if [ "${MS_SECRET}" = "secret" ]; then MS_SECRET=$(echo "$(pwgen 40)") @@ -27,13 +29,15 @@ if [ "${MS_SECRET}" = "secret" ]; then else echo "MS_SECRET='${MS_SECRET}'" >> /root/envsetup/conf.sh fi + echo "The config MS_SECRET has been set." fi # Worker IP for whitelist -if [ "${CELERITY_WORKER_IP}" = "" ]; then +if [ "${CELERITY_WORKER_IP}" = "" ] || [ "${CELERITY_WORKER_IP}" = "127.0.1.1" ]; then CELERITY_WORKER_IP=$(ip addr show | grep inet | grep -v 127 | grep -v ":" | awk -F " " '{print$2}' | awk -F "/" '{print$1}') if ( cat "/root/envsetup/conf.sh" | grep "CELERITY_WORKER_IP" >/dev/null ); then sed -i "s@^CELERITY_WORKER_IP=.*@CELERITY_WORKER_IP='${CELERITY_WORKER_IP}'@" /root/envsetup/conf.sh else echo "CELERITY_WORKER_IP='${CELERITY_WORKER_IP}'" >> /root/envsetup/conf.sh fi + echo "The config CELERITY_WORKER_IP has been set." fi diff --git a/3.New_server_deployment/3.Initialize_APT/0_setup.sh b/3.New_server_deployment/3.Initialize_APT/0_setup.sh index f3b8e286..0c0d3a2a 100755 --- a/3.New_server_deployment/3.Initialize_APT/0_setup.sh +++ b/3.New_server_deployment/3.Initialize_APT/0_setup.sh @@ -1,5 +1,5 @@ #!/bin/bash -source /root/envsetup/conf.sh +source /root/envsetup/global-conf.sh # migrate to Ubuntu 16.04 / apply sources.list if ( rgrep '14.04' /etc/lsb-release >/dev/null ); then diff --git a/3.New_server_deployment/4.Dell_openmanage/0_setup.sh b/3.New_server_deployment/4.Dell_openmanage/0_setup.sh index 19b07901..b57d5883 100755 --- a/3.New_server_deployment/4.Dell_openmanage/0_setup.sh +++ b/3.New_server_deployment/4.Dell_openmanage/0_setup.sh @@ -1,5 +1,5 @@ #!/bin/bash -source /root/envsetup/conf.sh +source /root/envsetup/global-conf.sh # DELL server - install dell openmanage if ( ! dpkg -l | grep dmidecode ); then diff --git a/5.MediaServer/1.Install_MediaServer/0_setup.sh b/5.MediaServer/1.Install_MediaServer/0_setup.sh index 169cf8b0..1f6515e6 100755 --- a/5.MediaServer/1.Install_MediaServer/0_setup.sh +++ b/5.MediaServer/1.Install_MediaServer/0_setup.sh @@ -1,5 +1,5 @@ #!/bin/bash -source /root/envsetup/conf.sh +source /root/envsetup/global-conf.sh # Ms package install DEBIAN_FRONTEND=noninteractive apt-get install -y python3-mediaserver diff --git a/5.MediaServer/3.Install_MS_deploy/0_setup.sh b/5.MediaServer/3.Install_MS_deploy/0_setup.sh index b41af8a4..e87d3f91 100755 --- a/5.MediaServer/3.Install_MS_deploy/0_setup.sh +++ b/5.MediaServer/3.Install_MS_deploy/0_setup.sh @@ -1,5 +1,5 @@ #!/bin/bash -source /root/envsetup/conf.sh +source /root/envsetup/global-conf.sh echo "Copying MS_deploy.sh" cp -v MS_deploy.sh /var/tmp/MS_deploy.sh diff --git a/6.CampusManager/1.Install_CampusManager/0_setup.sh b/6.CampusManager/1.Install_CampusManager/0_setup.sh index 548c5e76..0823e5d6 100755 --- a/6.CampusManager/1.Install_CampusManager/0_setup.sh +++ b/6.CampusManager/1.Install_CampusManager/0_setup.sh @@ -1,5 +1,5 @@ #!/bin/bash -source /root/envsetup/conf.sh +source /root/envsetup/global-conf.sh # install cm apt-get install -y campus-manager diff --git a/8.Cache/1.Install_cache/0_setup.sh b/8.Cache/1.Install_cache/0_setup.sh index ac90ec7e..a723e053 100755 --- a/8.Cache/1.Install_cache/0_setup.sh +++ b/8.Cache/1.Install_cache/0_setup.sh @@ -1,5 +1,5 @@ #!/bin/bash -source /root/envsetup/conf.sh +source /root/envsetup/global-conf.sh sed -i "s@\[CLIENT\]@$(hostname)@" default sed -i "s@\[CACHE_DIR\]@${CACHE_DIR}@" default diff --git a/8.Cache/2.Deploy_munin_configuration/0_setup.sh b/8.Cache/2.Deploy_munin_configuration/0_setup.sh index 285fc051..462bf12f 100755 --- a/8.Cache/2.Deploy_munin_configuration/0_setup.sh +++ b/8.Cache/2.Deploy_munin_configuration/0_setup.sh @@ -1,5 +1,5 @@ #!/bin/bash -source /root/envsetup/conf.sh +source /root/envsetup/global-conf.sh # for munin DEBIAN_FRONTEND=noninteractive apt-get install -y ubicast-config diff --git a/8.Cache/3.Install_ferm/0_setup.sh b/8.Cache/3.Install_ferm/0_setup.sh index 1de2ce98..2e701f46 100755 --- a/8.Cache/3.Install_ferm/0_setup.sh +++ b/8.Cache/3.Install_ferm/0_setup.sh @@ -1,5 +1,5 @@ #!/bin/bash -source /root/envsetup/conf.sh +source /root/envsetup/global-conf.sh DEBIAN_FRONTEND=noninteractive apt-get install -y ferm cp ferm.conf /etc/ferm/ferm.conf diff --git a/9.MediaVault/1.Install_MediaVault/0_setup.sh b/9.MediaVault/1.Install_MediaVault/0_setup.sh index 89f429f7..d1724d57 100755 --- a/9.MediaVault/1.Install_MediaVault/0_setup.sh +++ b/9.MediaVault/1.Install_MediaVault/0_setup.sh @@ -1,5 +1,5 @@ #!/bin/bash -source /root/envsetup/conf.sh +source /root/envsetup/global-conf.sh apt-get install -y dialog cd /root diff --git a/conf.sh b/conf.sh index c1308c9a..8c1790d5 100644 --- a/conf.sh +++ b/conf.sh @@ -1,7 +1,5 @@ #!/bin/bash # Envsetup local configuration file -# See default configuration in default-conf.sh - -source /root/envsetup/default-conf.sh +# See default configuration in global-conf.sh # Put your configuration here diff --git a/envsetup.py b/envsetup.py index 2bba8053..fa19dad1 100755 --- a/envsetup.py +++ b/envsetup.py @@ -156,7 +156,6 @@ class EnvSetup(): if target == str(action['index']) and action['fct']: found = True log('Starting action %s: %s setup.' % (action['index'], action['label'])) - log('Please wait, the setup is in progress... ') try: os.chdir(action['path']) if isinstance(action['fct'], str): diff --git a/default-conf.sh b/global-conf.sh similarity index 86% rename from default-conf.sh rename to global-conf.sh index 73e425f8..e5474847 100644 --- a/default-conf.sh +++ b/global-conf.sh @@ -1,8 +1,11 @@ #!/bin/bash -# Envsetup default configuration file # DO NOT EDIT THIS FILE! # Put your local configuration in conf.sh + +# Default configuration values +# ---------------------------- + # -- Constants -- CYAN='\033[0;36m' GREEN='\033[0;32m' @@ -119,3 +122,17 @@ HA_LB1='ha-lb3' HA_LB1_IP='192.168.41.177' HA_LB2= HA_LB2_IP= + + +# Upstream configuration override +# ------------------------------- +# (file generated by Panel / Skyreach) +if [ -f "/root/envsetup/auto-generated-conf.sh" ]; then + source "/root/envsetup/auto-generated-conf.sh" +fi + +# Local configuration override +# ---------------------------- +if [ -f "/root/envsetup/conf.sh" ]; then + source "/root/envsetup/conf.sh" +fi diff --git a/utils.py b/utils.py index 72ea1e22..95c64d92 100644 --- a/utils.py +++ b/utils.py @@ -6,7 +6,8 @@ import subprocess import sys -DEFAULT_CONF_PATH = 'default-conf.sh' +DEFAULT_CONF_PATH = 'global-conf.sh' +AUTO_CONF_PATH = 'auto-generated-conf.sh' CONF_PATH = 'conf.sh' CONF = dict() @@ -51,15 +52,17 @@ def load_conf(): base_dir = get_dir(__file__) files = ( (os.path.join(base_dir, DEFAULT_CONF_PATH), True), + (os.path.join(base_dir, AUTO_CONF_PATH), False), (os.path.join(base_dir, CONF_PATH), False), ) only_default = True override = OrderedDict() for path, is_default in files: if not os.path.exists(path): - log('The configuration file for EnvSetup script does not exist.\nPath of configuration file: %s' % path, error=True) if is_default: + log('The configuration file for EnvSetup script does not exist.\nPath of configuration file: %s' % path, error=True) return dict() + continue # Load conf with open(path, 'r') as fo: content = fo.read() -- GitLab