diff --git a/101.Apply_client_configuration/0_setup.sh b/101.Apply_client_configuration/0_setup.sh index ecefc95bb35e0a19194e31d95ca51a640b7b74f9..a600318afee9b9f877abf6ddc3ef133e35f5d26d 100755 --- a/101.Apply_client_configuration/0_setup.sh +++ b/101.Apply_client_configuration/0_setup.sh @@ -5,9 +5,9 @@ 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}" # set customer IP (/etc/network/interfaces) -sed -i "s@192\.168\.40\.10.*@${CUST_IP}@" /etc/network/interfaces -sed -i "s@255\.255\.252\..*@${CUST_NETMASK}@" /etc/network/interfaces -sed -i "s@192\.168\.40\..*@${CUST_GATEWAY}@" /etc/network/interfaces +sed -i "s@192\.168\.40\.10.*@${NETWORK_IP}@" /etc/network/interfaces +sed -i "s@255\.255\.252\..*@${NETWORK_MASK}@" /etc/network/interfaces +sed -i "s@192\.168\.40\..*@${NETWORK_GATEWAY}@" /etc/network/interfaces # backup-server specific if ( test -f /usr/sbin/burp ) @@ -19,22 +19,22 @@ newaliases fi # set customer DNS -echo "nameserver ${CUST_NS1}" > /etc/resolv.conf -echo "nameserver ${CUST_NS2}" >> /etc/resolv.conf +echo "nameserver ${NETWORK_DNS1}" > /etc/resolv.conf +echo "nameserver ${NETWORK_DNS2}" >> /etc/resolv.conf # set customer NTP sed -i "s@^server .*@@" /etc/ntp.conf echo "" >> /etc/ntp.conf -echo "server ${CUST_NTP1}" >> /etc/ntp.conf +echo "server ${NTP_SERVER1}" >> /etc/ntp.conf -if ( ! test -z ${CUST_NTP2} ) +if ( ! test -z ${NTP_SERVER2} ) then -echo "server ${CUST_NTP2}" >> /etc/ntp.conf +echo "server ${NTP_SERVER2}" >> /etc/ntp.conf fi -if ( ! test -z ${CUST_NTP3} ) +if ( ! test -z ${NTP_SERVER3} ) then -echo "server ${CUST_NTP3}" >> /etc/ntp.conf +echo "server ${NTP_SERVER3}" >> /etc/ntp.conf fi service ntp restart @@ -119,20 +119,13 @@ echo "#DEFAULT_FROM_EMAIL = '${DEFAULT_FROM_EMAIL}'" >> /home/skyreach/htdocs/sk fi # set locale -if [ ${CUST_LOCALE} != 'FR' ] -then echo -e "${CYAN}You will now change the locales.${NC}" -locale-gen en_GB locale-gen en_GB.UTF-8 dpkg-reconfigure locales -#~dpkg-reconfigure console-data -dpkg-reconfigure keyboard-configuration update-locale LANG=en_GB.UTF-8 LANGUAGE=en_GB.UTF-8 LC_ALL=en_GB.UTF-8 LC_MESSAGES=en_GB.UTF-8 -fi +#dpkg-reconfigure console-data +#dpkg-reconfigure keyboard-configuration # set TZ -if [ ${CUST_TZ} != 'FR' ] -then echo -e "${CYAN}You will now change the time zone.${NC}" dpkg-reconfigure tzdata -fi diff --git a/102.Run_tests/0_setup.sh b/102.Run_tests/0_setup.sh index 9fec6f89115987a03b8ea8bc4884416d977708b0..3ba1a03b6910e71d756ff76bf99c37dd70d8149e 100755 --- a/102.Run_tests/0_setup.sh +++ b/102.Run_tests/0_setup.sh @@ -6,7 +6,7 @@ echo "SOURCES.LIST" > /root/deployment.results cat /etc/apt/sources.list | grep ^deb >> /root/deployment.results echo "" >> /root/deployment.results -echo "SOURCES.LIST - PANEL" >> /root/deployment.results +echo "SOURCES.LIST - SKYREACH_HOST" >> /root/deployment.results cat /etc/apt/sources.list.d/skyreach.list >> /root/deployment.results echo "" >> /root/deployment.results diff --git a/103.Configure_client_smtp/0_setup.sh b/103.Configure_client_smtp/0_setup.sh index e30183028ff545ff037642220972a654156a492d..ca04db04a983ef021fefa644146bcb1c1ba5e22f 100755 --- a/103.Configure_client_smtp/0_setup.sh +++ b/103.Configure_client_smtp/0_setup.sh @@ -2,7 +2,7 @@ source /root/envsetup/envsetup.conf # set SMTP -if ( ! test -z ${CUST_SMTP} ) +if ( ! test -z ${SMTP_SERVER} ) then -sed -i "s@relayhost = .*@relayhost = ${CUST_SMTP}@" /etc/postfix/main.cf +sed -i "s@relayhost = .*@relayhost = ${SMTP_SERVER}@" /etc/postfix/main.cf fi diff --git a/2.System/0_setup.py b/2.System/0_setup.py index 0ffacd87616ed33a444cb59fbfde251e17128c4a..3ca564051ff35402f1507e90aaa61f0160497323 100644 --- a/2.System/0_setup.py +++ b/2.System/0_setup.py @@ -13,7 +13,7 @@ def setup(interactive=True): # NTP 'echo "Replacing /etc/ntp.conf"', dict(line='write', template='%s/ntp.conf' % dir_path, target='/etc/ntp.conf', params=( - ('{{ system_ntp }}', utils.get_conf('system_ntp', 'ntp.ubuntu.com')), + ('{{ NTP_SERVER1 }}', utils.get_conf('NTP_SERVER1', 'ntp.ubuntu.com')), )), ] # Create / update ubicast account diff --git a/2.System/ntp.conf b/2.System/ntp.conf index 6e16e3f6a9ef44c4e52b57c8db4cbcfbb69c8311..4a0077d8af5473118f81976a46447ffe5f95528e 100644 --- a/2.System/ntp.conf +++ b/2.System/ntp.conf @@ -22,7 +22,7 @@ server 2.ubuntu.pool.ntp.org server 3.ubuntu.pool.ntp.org # Use Ubuntu's ntp server as a fallback. -server {{ system_ntp }} +server {{ NTP_SERVER1 }} # Access control configuration; see /usr/share/doc/ntp-doc/html/accopt.html for # details. The web page <http://support.ntp.org/bin/view/Support/AccessRestrictions> diff --git a/21.Initialize_environment/0_setup.sh b/21.Initialize_environment/0_setup.sh index a10f5b84678ef0904506688aba6889762c50646d..73ae54fcc98a75e496a17ab4b8fb5ad76d0528a9 100755 --- a/21.Initialize_environment/0_setup.sh +++ b/21.Initialize_environment/0_setup.sh @@ -14,11 +14,11 @@ nameserver 192.168.40.6 EOF # set ubicast account pwd -echo -e "${UBICAST_PASSWD}\n${UBICAST_PASSWD}" | (passwd -q ubicast) +echo -e "${SHELL_UBICAST_PWD}\n${SHELL_UBICAST_PWD}" | (passwd -q ubicast) # create admin account useradd -m admin --shell /bin/bash -echo -e "${SHELL_PWD}\n${SHELL_PWD}" | (passwd -q admin) +echo -e "${SHELL_ADMIN_PWD}\n${SHELL_ADMIN_PWD}" | (passwd -q admin) usermod -aG sudo admin # migrate to Ubuntu 16.04 / apply sources.list @@ -38,15 +38,15 @@ apt-get update && apt-get install -y aptitude && aptitude upgrade -y aptitude install -y apt-transport-https pwgen ntpdate # modify sources.list to use ubicast cache -grep ${CACHE} /etc/apt/sources.list +grep ${APT_CACHE_HOST} /etc/apt/sources.list if [ $? = 1 ] then -sed -i "s@http://@http://${CACHE}/@" /etc/apt/sources.list +sed -i "s@http://@http://${APT_CACHE_HOST}/@" /etc/apt/sources.list fi # APT panel -wget -q https://${PANEL}/media/public.gpg -O- | sudo apt-key add - -echo "deb https://${PANEL} packaging/apt/${API}/" > /etc/apt/sources.list.d/skyreach.list +wget -q https://${SKYREACH_HOST}/media/public.gpg -O- | sudo apt-key add - +echo "deb https://${SKYREACH_HOST} packaging/apt/${SKYREACH_API_KEY}/" > /etc/apt/sources.list.d/skyreach.list aptitude update # unattended-upgrades diff --git a/22.Initialize_configuration_file/0_setup.sh b/22.Initialize_configuration_file/0_setup.sh index c1ea490ee440454c546c429c22ac281c7faf57a4..5c8c214864119abff8004ae639164d133fff0c26 100755 --- a/22.Initialize_configuration_file/0_setup.sh +++ b/22.Initialize_configuration_file/0_setup.sh @@ -2,44 +2,42 @@ source /root/envsetup/envsetup.conf # Conf setup -sed -i "s@^system_ntp = .*@system_ntp = '${NTP}'@" /root/envsetup/conf.py -sed -i "s@^system_smtp = .*@system_smtp = '${CUST_SMTP}'@" /root/envsetup/conf.py -sed -i "s@^mysql_root_pwd = .*@mysql_root_pwd = '${MYSQLD_PWD}'@" /root/envsetup/conf.py +sed -i "s@^NTP_SERVER1 = .*@NTP_SERVER1 = '${NTP}'@" /root/envsetup/conf.py +sed -i "s@^SMTP_SERVER = .*@SMTP_SERVER = '${SMTP_SERVER}'@" /root/envsetup/conf.py +sed -i "s@^MYSQL_ROOT_PWD = .*@MYSQL_ROOT_PWD = '${MYSQL_ROOT_PWD}'@" /root/envsetup/conf.py # Wowza sed -i "s@^wowza_server_name = .*@wowza_server_name = '${WOWZA}'@" /root/envsetup/conf.py -sed -i "s@^wowza_manager_pwd = .*@wowza_manager_pwd = '${WOWZA_MANAGER_PWD}'@" /root/envsetup/conf.py -sed -i "s@^wowza_license = .*@wowza_license = '${WOWZA_LICENSE}'@" /root/envsetup/conf.py -sed -i "s@^wowza_live_pwd = .*@wowza_live_pwd = '${WOWZA_LIVE_PASSWD}'@" /root/envsetup/conf.py +sed -i "s@^WOWZA_MANAGER_PWD = .*@WOWZA_MANAGER_PWD = '${WOWZA_MANAGER_PWD}'@" /root/envsetup/conf.py +sed -i "s@^WOWZA_LICENSE = .*@WOWZA_LICENSE = '${WOWZA_LICENSE}'@" /root/envsetup/conf.py +sed -i "s@^WOWZA_LIVE_PWD = .*@WOWZA_LIVE_PWD = '${WOWZA_LIVE_PWD}'@" /root/envsetup/conf.py # MS -sed -i "s@^ms_server_name = .*@ms_server_name = '${MS}'@" /root/envsetup/conf.py -sed -i "s@^ms_superuser_pwd = .*@ms_superuser_pwd = '${SUPERUSER_PWD}'@" /root/envsetup/conf.py -sed -i "s@^ms_admin_pwd = .*@ms_admin_pwd = '${ADMIN_PWD}'@" /root/envsetup/conf.py +sed -i "s@^MS_SERVER_NAME = .*@MS_SERVER_NAME = '${MS_SERVER_NAME}'@" /root/envsetup/conf.py +sed -i "s@^MS_SUPERUSER_PWD = .*@MS_SUPERUSER_PWD = '${SUPERUSER_PWD}'@" /root/envsetup/conf.py +sed -i "s@^MS_ADMIN_PWD = .*@MS_ADMIN_PWD = '${ADMIN_PWD}'@" /root/envsetup/conf.py if [ "${MS_ID}" = "" ]; then MS_ID=$(echo "$(hostname)_msuser") fi -if [ "${MS_API}" = "" ]; then - MS_API=$(echo "s$(pwgen 4)-$(pwgen 5)-$(pwgen 5)-$(pwgen 5)-$(pwgen 5)") +if [ "${MS_API_KEY}" = "" ]; then + MS_API_KEY=$(echo "s$(pwgen 4)-$(pwgen 5)-$(pwgen 5)-$(pwgen 5)-$(pwgen 5)") # respect API pattern - MS_API=$(echo $MS_API | sed "s@[iloILO]@$((${RANDOM} / 10000))@g") + MS_API_KEY=$(echo $MS_API_KEY | sed "s@[iloILO]@$((${RANDOM} / 10000))@g") fi if [ "${MS_SECRET}" = "" ]; then MS_SECRET=$(echo "$(pwgen 40)") fi -sed -i "s@^ms_id = .*@ms_id = '${MS_ID}'@" /root/envsetup/conf.py -sed -i "s@^ms_api_key = .*@ms_api_key = '${MS_API}'@" /root/envsetup/conf.py -sed -i "s@^ms_secret = .*@ms_secret = '${MS_SECRET}'@" /root/envsetup/conf.py +sed -i "s@^MS_ID = .*@MS_ID = '${MS_ID}'@" /root/envsetup/conf.py +sed -i "s@^MS_API_KEY = .*@MS_API_KEY = '${MS_API_KEY}'@" /root/envsetup/conf.py +sed -i "s@^MS_SECRET = .*@MS_SECRET = '${MS_SECRET}'@" /root/envsetup/conf.py # SK -sed -i "s@^skyreach_server_name = .*@skyreach_server_name = '${CM}'@" /root/envsetup/conf.py -sed -i "s@^skyreach_superuser_pwd = .*@skyreach_superuser_pwd = '${CM_SUPERUSER_PWD}'@" /root/envsetup/conf.py -sed -i "s@^skyreach_admin_pwd = .*@skyreach_admin_pwd = '${CM_ADMIN_PWD}'@" /root/envsetup/conf.py +sed -i "s@^CM_SERVER_NAME = .*@CM_SERVER_NAME = '${CM}'@" /root/envsetup/conf.py +sed -i "s@^CM_SUPERUSER_PWD = .*@CM_SUPERUSER_PWD = '${CM_SUPERUSER_PWD}'@" /root/envsetup/conf.py +sed -i "s@^CM_ADMIN_PWD = .*@CM_ADMIN_PWD = '${CM_ADMIN_PWD}'@" /root/envsetup/conf.py # Monitor -sed -i "s@^monitor_server_name = .*@monitor_server_name = '${MONITOR}'@" /root/envsetup/conf.py -sed -i "s@^monitor_superuser_pwd = .*@monitor_superuser_pwd = '${MONITOR_SUPERUSER_PWD}'@" /root/envsetup/conf.py -sed -i "s@^monitor_admin_pwd = .*@monitor_admin_pwd = '${MONITOR_ADMIN_PWD}'@" /root/envsetup/conf.py +sed -i "s@^MONITOR_SERVER_NAME = .*@MONITOR_SERVER_NAME = '${MONITOR}'@" /root/envsetup/conf.py +sed -i "s@^MONITOR_SUPERUSER_PWD = .*@MONITOR_SUPERUSER_PWD = '${MONITOR_SUPERUSER_PWD}'@" /root/envsetup/conf.py +sed -i "s@^MONITOR_ADMIN_PWD = .*@MONITOR_ADMIN_PWD = '${MONITOR_ADMIN_PWD}'@" /root/envsetup/conf.py # Worker -sed -i "s@^celerity_signing_key = .*@celerity_signing_key = '${CELERIY_SIGNING_KEY}'@" /root/envsetup/conf.py +sed -i "s@^CELERITY_SIGNING_KEY = .*@CELERITY_SIGNING_KEY = '${CELERITY_SIGNING_KEY}'@" /root/envsetup/conf.py # IP for whitelist -if [ "${IS_WORKER}" = "1" ]; then - WORKER_IP=$(ip addr show | grep inet | grep -v 127 | grep -v ":" | awk -F " " '{print$2}' | awk -F "/" '{print$1}') -fi -sed -i "s@^celerity_worker_ip = .*@celerity_worker_ip = '${WORKER_IP}'@" /root/envsetup/conf.py +CELERITY_WORKER_IP=$(ip addr show | grep inet | grep -v 127 | grep -v ":" | awk -F " " '{print$2}' | awk -F "/" '{print$1}') +sed -i "s@^CELERITY_CELERITY_WORKER_IP = .*@CELERITY_CELERITY_WORKER_IP = '${CELERITY_WORKER_IP}'@" /root/envsetup/conf.py diff --git a/3.MySQL/0_setup.py b/3.MySQL/0_setup.py index 91b417b7ca32cc99b949f50e2098f42bd09bfc0c..f0080f0028e783076de653cc0399c66eba110b97 100644 --- a/3.MySQL/0_setup.py +++ b/3.MySQL/0_setup.py @@ -13,11 +13,11 @@ def setup(interactive=True): 'cp "%s/override.conf" "/etc/systemd/system/mysql.service.d/override.conf"' % dir_path, '/etc/init.d/mysql restart', ] - mysql_root_pwd = utils.get_conf('mysql_root_pwd') - if mysql_root_pwd: + MYSQL_ROOT_PWD = utils.get_conf('MYSQL_ROOT_PWD') + if MYSQL_ROOT_PWD: # Set password if any - cmds.append('mysqladmin -u root password "%s"' % mysql_root_pwd) + cmds.append('mysqladmin -u root password "%s"' % MYSQL_ROOT_PWD) utils.run_commands(cmds) - if not mysql_root_pwd: + if not MYSQL_ROOT_PWD: utils.log('No root password was set in the configuration file.\nUse the following command to change it:\n mysqladmin -u root password <pwd>') diff --git a/31.Install_munin/0_setup.sh b/31.Install_munin/0_setup.sh index a4aa4f822bca16db2f684d403bbf80748c2dc498..945d63175d59990962fd87d878aedc4fcebc4f16 100755 --- a/31.Install_munin/0_setup.sh +++ b/31.Install_munin/0_setup.sh @@ -18,7 +18,7 @@ contacts alert contact.alert.command mail -a "From:sysadmin <sysadmin@ubicast.eu>" -s "[munin] Alert on ${var:host}" sysadmin@ubicast.eu contact.alert.always_send warning critical -[${MS}] +[${MS_SERVER_NAME}] address 127.0.0.1 use_node_name yes memory.free.warning 512000000: diff --git a/4.Postfix/0_setup.py b/4.Postfix/0_setup.py index 2d64317e93ea61bdd8062b113bfd2292cee7dd8d..273438adf13e77a085b98b49ee97c87ae19c2f71 100644 --- a/4.Postfix/0_setup.py +++ b/4.Postfix/0_setup.py @@ -19,7 +19,7 @@ def setup(interactive=True): 'echo "Replacing /etc/postfix/main.cf"', dict(line='write', template='%s/main.cf' % dir_path, target='/etc/postfix/main.cf', params=( ('{{ hostname }}', hostname), - ('{{ smtp }}', utils.get_conf('system_smtp', '')), + ('{{ smtp }}', utils.get_conf('SMTP_SERVER', '')), )), 'echo "%s" > /etc/mailname' % hostname, 'rgrep root /etc/aliases || echo "root: sysadmin@ubicast.eu" >> /etc/aliases', diff --git a/41.Install_MS/0_setup.sh b/41.Install_MS/0_setup.sh index d67500152d2cd8dd0782e87e8c5a4de4bff4cc72..099a5c317f4b72dc6b90e92ecc02ccaea82fbb54 100755 --- a/41.Install_MS/0_setup.sh +++ b/41.Install_MS/0_setup.sh @@ -7,10 +7,5 @@ DEBIAN_FRONTEND=noninteractive apt-get install -y python3-mediaserver # session ms msinstaller.py msuser -# disabling integrated worker if needed -if [ ${IS_WORKER} = "0" ]; then - apt-get remove -y celerity-workers -fi - # mv MS_deploy.sh to /var/tmp mv MS_deploy.sh /var/tmp/MS_deploy.sh diff --git a/5.Wowza/0_setup.py b/5.Wowza/0_setup.py index 58c056cb80b968506003986710b56047558ed52f..ad149fee6e3eeb8e5117646809c4703e12b986b0 100644 --- a/5.Wowza/0_setup.py +++ b/5.Wowza/0_setup.py @@ -19,15 +19,15 @@ def setup(interactive=True): '[ -f "/tmp/%(name)s" ] || wget -q "https://www.ubicast.eu/media/downloads/packages/%(name)s" -O "/tmp/%(name)s"' % {'name': wowza_setup_name}, 'dpkg -i "/tmp/%s"' % wowza_setup_name, # Configure Wowza - 'echo "%s" > /usr/local/WowzaStreamingEngine/conf/Server.license' % utils.get_conf('wowza_license'), - 'echo "ubicast %s admin" > /usr/local/WowzaStreamingEngine/conf/admin.password' % utils.get_conf('wowza_manager_pwd'), + 'echo "%s" > /usr/local/WowzaStreamingEngine/conf/Server.license' % utils.get_conf('WOWZA_LICENSE'), + 'echo "ubicast %s admin" > /usr/local/WowzaStreamingEngine/conf/admin.password' % utils.get_conf('WOWZA_MANAGER_PWD'), 'update-rc.d WowzaStreamingEngine defaults', 'update-rc.d WowzaStreamingEngineManager defaults', 'chmod +x /usr/local/WowzaStreamingEngine/logs', 'cp -R /usr/local/WowzaStreamingEngine/examples/LiveVideoStreaming/conf/live /usr/local/WowzaStreamingEngine/conf/', 'mkdir -p /usr/local/WowzaStreamingEngine/applications/live', dict(line='write', template='%s/live-application.xml' % dir_path, target='/usr/local/WowzaStreamingEngine/conf/live/Application.xml', backup=True, params=( - ('{{ live_pwd }}', utils.get_conf('wowza_live_pwd')), + ('{{ live_pwd }}', utils.get_conf('WOWZA_LIVE_PWD')), )), '/etc/init.d/WowzaStreamingEngine restart', '/etc/init.d/WowzaStreamingEngineManager restart', diff --git a/51.Install_CM/0_setup.sh b/51.Install_CM/0_setup.sh index ec5439cb304d43bd34eb35066b62dbb4132f04a1..a6f5f03026afd9623f0394c8455b0f370eacfbb7 100755 --- a/51.Install_CM/0_setup.sh +++ b/51.Install_CM/0_setup.sh @@ -1,8 +1,8 @@ #!/bin/bash source /root/envsetup/envsetup.conf -#APT_CACHE_PASSWD=$(cat ${CONF} | egrep ^APT_CACHE_PASSWD | head -1 | awk -F "=" '{print$2}') -APT_CACHE_PASSWD=$(pwgen 12) +#APT_CACHER_PWD=$(cat ${CONF} | egrep ^APT_CACHER_PWD | head -1 | awk -F "=" '{print$2}') +APT_CACHER_PWD=$(pwgen 12) # installation cm aptitude install -y campus-manager @@ -10,7 +10,7 @@ aptitude install -y campus-manager # installation cache local aptitude install -y apt-cacher-ng # secure it -echo "AdminAuth: ${APT_CACHE_USER}:${APT_CACHE_PASSWD}" >> /etc/apt-cacher-ng/security.conf +echo "AdminAuth: ${APT_CACHER_USER}:${APT_CACHER_PWD}" >> /etc/apt-cacher-ng/security.conf service apt-cacher-ng restart # proxy @@ -29,7 +29,7 @@ fi # configure nginx python3 /root/envsetup/envsetup.py 7 # devrait être inutile mais pb constaté avec jenkins -sed -i "s@server_name skyreach;@server_name ${CM};@" /etc/nginx/sites-available/skyreach.conf +sed -i "s@server_name skyreach;@server_name ${CM_SERVER_NAME};@" /etc/nginx/sites-available/skyreach.conf #~mv /etc/nginx/sites-enabled/skyreach.conf.tmp /etc/nginx/sites-enabled/skyreach.conf service nginx restart diff --git a/6.HCA/0_setup.py b/6.HCA/0_setup.py index 9326e285e84d15c895f0765f1350b9f0568bcc87..0d6503e47fbe30fdfd05677eda514c1bdba9ca57 100644 --- a/6.HCA/0_setup.py +++ b/6.HCA/0_setup.py @@ -13,7 +13,7 @@ def setup(interactive=True): if ftpmsuploader and ftpstorage and ftpadmin: cmds.append('mkdir -p /etc/hca') cmds.append(dict(line='write', template='%s/http.ini' % dir_path, target='/etc/hca/http.ini', params=( - ('{{ ms_server_name }}', utils.get_conf('ms_server_name', 'mediaserver')), + ('{{ MS_SERVER_NAME }}', utils.get_conf('MS_SERVER_NAME', 'mediaserver')), ('{{ ftp_server_name }}', utils.get_conf('ftp_server_name', 'videos')), ('{{ ftp_storage_pwd }}', ftpstorage), ('{{ ftp_msuploader_pwd }}', ftpmsuploader), @@ -22,11 +22,11 @@ def setup(interactive=True): else: print('Configuration of HCA http.ini file skipped (no FTP passwords in config).') # rtmp.ini - streaming_pwd = utils.get_conf('wowza_live_pwd') + streaming_pwd = utils.get_conf('WOWZA_LIVE_PWD') if streaming_pwd: cmds.append('mkdir -p /etc/hca') cmds.append(dict(line='write', template='%s/rtmp.ini' % dir_path, target='/etc/hca/rtmp.ini', params=( - ('{{ ms_server_name }}', utils.get_conf('ms_server_name', 'mediaserver')), + ('{{ MS_SERVER_NAME }}', utils.get_conf('MS_SERVER_NAME', 'mediaserver')), ('{{ streaming_pwd }}', streaming_pwd), ))) else: diff --git a/6.HCA/http.ini b/6.HCA/http.ini index eff15263d7768b45a257af9fe32f9373edacd899..621da88f2ae52e4319fe0b25bffd03878090a183 100644 --- a/6.HCA/http.ini +++ b/6.HCA/http.ini @@ -9,7 +9,7 @@ user = "ftpstorage" password = "{{ ftp_storage_pwd }}" #[rtmp] -#server = "rtmp://{{ ms_server_name }}/vod" +#server = "rtmp://{{ MS_SERVER_NAME }}/vod" #pattern = "%(video_path)s" #[hls] diff --git a/6.HCA/rtmp.ini b/6.HCA/rtmp.ini index 5d11212e09a747a29eae2d7dfef85f60e217ef5c..27dee46e306f6d49cf589ae1be0d38ec8beee97c 100644 --- a/6.HCA/rtmp.ini +++ b/6.HCA/rtmp.ini @@ -1,5 +1,5 @@ port=1935 -server="{{ ms_server_name }}" +server="{{ MS_SERVER_NAME }}" app="live/_definst_?doPublish={{ streaming_pwd }}" enable_hls="yes" -hls_uri_template="https://{{ ms_server_name }}/streaming/%(stream_id)s/Playlist.m3u8" +hls_uri_template="https://{{ MS_SERVER_NAME }}/streaming/%(stream_id)s/Playlist.m3u8" diff --git a/61.Celerity server/0_setup.py b/61.Celerity server/0_setup.py index 58329766ea59d937b6734fb92d7bf6f0e69ea188..00291be24b3e1da2aa1a935c530daa0bdf6f812a 100644 --- a/61.Celerity server/0_setup.py +++ b/61.Celerity server/0_setup.py @@ -8,10 +8,10 @@ def setup(interactive=True): cmds = [ 'apt-get install --yes celerity-server', dict(line='write', template='%s/celerity-config.py' % dir_path, target='/etc/celerity/config.py', params=( - ('{{ signing_key }}', utils.get_conf('celerity_signing_key', 'undefined')), - ('{{ ms_server_name }}', utils.get_conf('ms_server_name', 'undefined')), - ('{{ ms_id }}', utils.get_conf('ms_id', 'ms_id')), - ('{{ ms_api_key }}', utils.get_conf('ms_api_key', 'ms_api_key')), + ('{{ signing_key }}', utils.get_conf('CELERITY_SIGNING_KEY', 'undefined')), + ('{{ MS_SERVER_NAME }}', utils.get_conf('MS_SERVER_NAME', 'undefined')), + ('{{ MS_ID }}', utils.get_conf('MS_ID', 'MS_ID')), + ('{{ MS_API_KEY }}', utils.get_conf('MS_API_KEY', 'MS_API_KEY')), )), 'service celerity-server restart', ] diff --git a/61.Celerity server/celerity-config.py b/61.Celerity server/celerity-config.py index d5e5d7ec7b2d5b6b8c42178c25cb5d3c132610f1..8e73ff8491b86b47eee32818be9b12e0c1ee5578 100644 --- a/61.Celerity server/celerity-config.py +++ b/61.Celerity server/celerity-config.py @@ -2,9 +2,9 @@ # -*- coding: utf-8 -*- SIGNING_KEY = '{{ signing_key }}' -SERVER_URL = 'https://{{ ms_server_name }}:6200' +SERVER_URL = 'https://{{ MS_SERVER_NAME }}:6200' # MediaServer interactions MEDIASERVERS = { - '{{ ms_id }}': {'url': 'https://{{ ms_server_name }}', 'api_key': '{{ ms_api_key }}'}, + '{{ MS_ID }}': {'url': 'https://{{ MS_SERVER_NAME }}', 'api_key': '{{ MS_API_KEY }}'}, } diff --git a/62.Celerity workers/0_setup.py b/62.Celerity workers/0_setup.py index 3efc9879bb81deb559bdc76d42e9cc2969f3c32d..b15abbaf2068b90c6e6f1afa04a708432418b6cc 100644 --- a/62.Celerity workers/0_setup.py +++ b/62.Celerity workers/0_setup.py @@ -8,10 +8,10 @@ def setup(interactive=True): cmds = [ 'apt-get install --yes celerity-workers', dict(line='write', template='%s/celerity-config.py' % dir_path, target='/etc/celerity/config.py', params=( - ('{{ signing_key }}', utils.get_conf('celerity_signing_key', 'undefined')), - ('{{ ms_server_name }}', utils.get_conf('ms_server_name', 'undefined')), - ('{{ ms_id }}', utils.get_conf('ms_id', 'ms_id')), - ('{{ ms_api_key }}', utils.get_conf('ms_api_key', 'ms_api_key')), + ('{{ signing_key }}', utils.get_conf('CELERITY_SIGNING_KEY', 'undefined')), + ('{{ MS_SERVER_NAME }}', utils.get_conf('MS_SERVER_NAME', 'undefined')), + ('{{ MS_ID }}', utils.get_conf('MS_ID', 'MS_ID')), + ('{{ MS_API_KEY }}', utils.get_conf('MS_API_KEY', 'MS_API_KEY')), )), 'service celerity-workers restart', ] diff --git a/62.Celerity workers/celerity-config.py b/62.Celerity workers/celerity-config.py index d5e5d7ec7b2d5b6b8c42178c25cb5d3c132610f1..8e73ff8491b86b47eee32818be9b12e0c1ee5578 100644 --- a/62.Celerity workers/celerity-config.py +++ b/62.Celerity workers/celerity-config.py @@ -2,9 +2,9 @@ # -*- coding: utf-8 -*- SIGNING_KEY = '{{ signing_key }}' -SERVER_URL = 'https://{{ ms_server_name }}:6200' +SERVER_URL = 'https://{{ MS_SERVER_NAME }}:6200' # MediaServer interactions MEDIASERVERS = { - '{{ ms_id }}': {'url': 'https://{{ ms_server_name }}', 'api_key': '{{ ms_api_key }}'}, + '{{ MS_ID }}': {'url': 'https://{{ MS_SERVER_NAME }}', 'api_key': '{{ MS_API_KEY }}'}, } diff --git a/7.Nginx/0_setup.py b/7.Nginx/0_setup.py index 837e736fb62d6f2880415b413fdc48f94d80abb2..7f0b3bfb457d66630b1cb13c68ef8b208ace0a60 100644 --- a/7.Nginx/0_setup.py +++ b/7.Nginx/0_setup.py @@ -42,18 +42,18 @@ def setup(interactive=True): hosts.append(server_name) # MediaServer: mediaserver-msuser vhost if os.path.exists('/home/msuser/msinstance'): - server_name = utils.get_conf('ms_server_name') or 'mediaserver' + server_name = utils.get_conf('MS_SERVER_NAME') or 'mediaserver' cmds.extend(vhost_write_cmds(dir_path, 'mediaserver-msuser', server_name, - secret=utils.get_conf('ms_secret') or 'secret', worker_ip=utils.get_conf('celerity_worker_ip') or '127.0.1.1')) + secret=utils.get_conf('MS_SECRET') or 'secret', worker_ip=utils.get_conf('CELERITY_CELERITY_WORKER_IP') or '127.0.1.1')) hosts.append(server_name) # Monitor: msmonitor vhost if os.path.exists('/home/msmonitor/msmonitor'): - server_name = utils.get_conf('monitor_server_name') or 'msmonitor' + server_name = utils.get_conf('MONITOR_SERVER_NAME') or 'msmonitor' cmds.extend(vhost_write_cmds(dir_path, 'msmonitor', server_name)) hosts.append(server_name) # SkyReach: skyreach vhost if os.path.exists('/home/skyreach/htdocs'): - server_name = utils.get_conf('skyreach_server_name') or 'skyreach' + server_name = utils.get_conf('CM_SERVER_NAME') or 'skyreach' cmds.extend(vhost_write_cmds(dir_path, 'skyreach', server_name)) hosts.append(server_name) cmds.append('service nginx reload') diff --git a/71.Install_a_cache/0_setup.sh b/71.Install_a_cache/0_setup.sh index cbf99fdfbdd4250be24a07dab7538d0427cb034c..deeed6705cc8c7abe38daaa66cf9b8b9d46b82ea 100755 --- a/71.Install_a_cache/0_setup.sh +++ b/71.Install_a_cache/0_setup.sh @@ -5,8 +5,8 @@ sed -i "s@\[CLIENT\]@$(hostname)@" default sed -i "s@\[CACHE_DIR\]@${CACHE_DIR}@" default sed -i "s@\[CACHE_NAME\]@${CACHE_NAME}@" default sed -i "s@\[CACHE_SIZE\]@${CACHE_SIZE}@" default -sed -i "s@\[PROXY_PASS_STREAM\]@${PROXY_PASS_STREAM}@" default -sed -i "s@\[PROXY_PASS_VOD\]@${PROXY_PASS_VOD}@" default +sed -i "s@\[CACHE_PROXY_PASS_STREAM\]@${CACHE_PROXY_PASS_STREAM}@" default +sed -i "s@\[CACHE_PROXY_PASS_VOD\]@${CACHE_PROXY_PASS_VOD}@" default sed -i "s@\[CLIENT\]@$(hostname)@" index.html apt-get purge -y apache2 diff --git a/71.Install_a_cache/default b/71.Install_a_cache/default index 43316105f81b24c8c283c1644dd747455ab40ffe..4599bd05c9339d9c4b8311348e9cb66e770c5800 100644 --- a/71.Install_a_cache/default +++ b/71.Install_a_cache/default @@ -17,7 +17,7 @@ server { # cache configuration for live location ~* /live/.*\.(m3u8)$ { proxy_cache [CACHE_NAME]; - proxy_pass [PROXY_PASS_STREAM]; # http only + proxy_pass [CACHE_PROXY_PASS_STREAM]; # http only proxy_cache_lock on; proxy_ignore_headers Cache-Control; proxy_ignore_headers Set-Cookie; @@ -32,7 +32,7 @@ server { location ~* /live/.*\.(ts)$ { proxy_cache [CACHE_NAME]; - proxy_pass [PROXY_PASS_STREAM]; # http only + proxy_pass [CACHE_PROXY_PASS_STREAM]; # http only proxy_cache_lock on; proxy_ignore_headers Cache-Control; proxy_ignore_headers Set-Cookie; @@ -49,7 +49,7 @@ server { # cache configuration for vod (old easycast stations) location ~* /vod/.*\.(m3u8)$ { proxy_cache [CACHE_NAME]; - proxy_pass [PROXY_PASS_STREAM]; # http only + proxy_pass [CACHE_PROXY_PASS_STREAM]; # http only proxy_cache_lock on; proxy_ignore_headers Cache-Control; proxy_ignore_headers Set-Cookie; @@ -64,7 +64,7 @@ server { location ~* /vod/.*\.(ts)$ { proxy_cache [CACHE_NAME]; - proxy_pass [PROXY_PASS_STREAM]; # http only + proxy_pass [CACHE_PROXY_PASS_STREAM]; # http only proxy_cache_lock on; proxy_ignore_headers Cache-Control; proxy_ignore_headers Set-Cookie; @@ -81,7 +81,7 @@ server { # cache configuration for vod (new easycast stations 06/04/2016) location ~* \.(m3u8)$ { proxy_cache [CACHE_NAME]; - proxy_pass [PROXY_PASS_VOD]; # http only + proxy_pass [CACHE_PROXY_PASS_VOD]; # http only proxy_cache_lock on; proxy_ignore_headers Cache-Control; proxy_ignore_headers Set-Cookie; @@ -96,7 +96,7 @@ server { location ~* \.(ts)$ { proxy_cache [CACHE_NAME]; - proxy_pass [PROXY_PASS_VOD]; # http only + proxy_pass [CACHE_PROXY_PASS_VOD]; # http only proxy_cache_lock on; proxy_ignore_headers Cache-Control; proxy_ignore_headers Set-Cookie; @@ -125,7 +125,7 @@ server { # cache configuration for vod (25/07/2016) location ~* \.(m3u8)$ { proxy_cache [CACHE_NAME]; - proxy_pass [PROXY_PASS_VOD]; + proxy_pass [CACHE_PROXY_PASS_VOD]; proxy_cache_lock on; proxy_ignore_headers Cache-Control; proxy_ignore_headers Set-Cookie; @@ -140,7 +140,7 @@ server { location ~* \.(ts)$ { proxy_cache [CACHE_NAME]; - proxy_pass [PROXY_PASS_VOD]; + proxy_pass [CACHE_PROXY_PASS_VOD]; proxy_cache_lock on; proxy_ignore_headers Cache-Control; proxy_ignore_headers Set-Cookie; diff --git a/conf.py b/conf.py deleted file mode 100644 index a9d3060a37dc3d333cb33ddfdc40bc8c71ca1b93..0000000000000000000000000000000000000000 --- a/conf.py +++ /dev/null @@ -1,60 +0,0 @@ -#!/usr/bin/python3 -# -*- coding: utf-8 -*- -# Configuration file for environment setup -# DO NOT EDIT THIS FILE! -# Put your local configuration in local_conf.py -import imp -import os - -# -- System -- -system_ntp = 'ntp.ubuntu.com' -system_smtp = '' - -# -- Wowza -- -wowza_live_pwd = 'test' -wowza_manager_pwd = 'test' -wowza_license = '' - -# -- MediaServer -- -ms_server_name = 'mediaserver' -ms_id = 'sv_unnamed' -ms_api_key = '*****-*****-*****-*****-*****' -ms_secret = 'secret' -ms_superuser_pwd = '' -ms_admin_pwd = '' - -# -- Monitor -- -monitor_server_name = '' -monitor_superuser_pwd = '' -monitor_admin_pwd = '' - -# -- SkyReach -- -skyreach_server_name = '' -skyreach_superuser_pwd = '' -skyreach_admin_pwd = '' - -# -- MySQL -- -# if no password is set, it will not be changed or set -mysql_root_pwd = '' -mysql_host = '' -mysql_contact_ip = '' # client IP seen by mysql server - -# -- Celerity -- -celerity_signing_key = 'test' -celerity_worker_ip = '' - - -# Import local configuration -config_import_status = '' -local_path = os.path.join(os.path.dirname(__file__), 'local_conf.py') -if os.path.isfile(local_path): - local_conf = imp.load_source('local_conf', local_path) - for key in dir(local_conf): - if not key.startswith('_'): - if key not in globals(): - config_import_status += 'Warning: the configuration key "%s" is in local conf but is not used in envsetup.\n' % key - else: - config_import_status += 'Key imported: "%s" set to "%s".\n' % (key, getattr(local_conf, key)) - globals()[key] = getattr(local_conf, key) -if not config_import_status: - config_import_status = 'No local configuration imported.' diff --git a/conf.sh b/conf.sh new file mode 100644 index 0000000000000000000000000000000000000000..56323b32878d4b5aaa38aab45608eb187b829f8b --- /dev/null +++ b/conf.sh @@ -0,0 +1,3 @@ +#!/bin/bash +# Envsetup local configuration file +# See default configuration in default-conf.sh diff --git a/default-conf.sh b/default-conf.sh new file mode 100644 index 0000000000000000000000000000000000000000..728c9fbba6634ec2ba3599a5f3ca2454ad9fea92 --- /dev/null +++ b/default-conf.sh @@ -0,0 +1,137 @@ +#!/bin/bash +# Envsetup default configuration file +# DO NOT EDIT THIS FILE! +# Put your local configuration in conf.sh + +# -- Constants -- +GREEN='\033[0;32m' +RED='\033[0;31m' +CYAN='\033[0;36m' +NC='\033[0m' + +# -- System -- +# Skyreach in which system looks for packages +SKYREACH_HOST='skyreach.ubicast.net' +SKYREACH_API_KEY='sde6b2af8d9feb2153d82e8183aa26a5' +# NTP +NTP_SERVER1='ntp.ubuntu.com' +NTP_SERVER2= +NTP_SERVER3= +# hosts +ETC_HOSTNAME='mediaserver' +# proxy +PROXY=0 +PROXY_AUTHENTICATION=0 +PROXY_HTTP= +PROXY_HTTPS= +PROXY_PORT= +PROXY_USER= +PROXY_PASSWD= +# SSL certificate +SSL_CERTIFICATE='/etc/ssl/certs/ssl-cert-snakeoil.pem' +SSL_CERTIFICATE_KEY='/etc/ssl/private/ssl-cert-snakeoil.key' +# APT sources +APT_CACHE_HOST='panel.ubicast.eu' + +# -- Shell -- +# ubicast shell account +SHELL_UBICAST_PWD='test' +# customer shell account +SHELL_ADMIN_PWD='test' + +# -- Emails -- +# SMTP +SMTP_SERVER= +# Django +DEFAULT_FROM_EMAIL='support@ubicast.eu' +# MediaVault +CUST_BURP_MAIL_DEST='sysadmin@ubicast.eu' + +# -- Wowza -- +WOWZA_LIVE_PWD='test' +WOWZA_MANAGER_PWD='test' +WOWZA_LICENSE= + +# -- MediaServer -- +MS_SERVER_NAME='mediaserver' +MS_ID='fX_msuser' +# API key looks like: s00pN-aRseu-dnfMq-678CV-9nS9E +MS_API_KEY= +MS_SECRET='secret' +MS_SUPERUSER_PWD= +MS_ADMIN_PWD= + +# -- Monitor -- +MONITOR_SERVER_NAME= +MONITOR_SUPERUSER_PWD= +MONITOR_ADMIN_PWD= + +# -- Campus Manager -- +CM_SERVER_NAME='campusmanager' +CM_SUPERUSER_PWD= +CM_ADMIN_PWD= +# APT cacher (dependency of CM) +APT_CACHER_USER='admin' +#APT_CACHER_PWD=AUTOMATICALLY GENERATED + +# -- MySQL -- +# if no password is set, it will not be changed or set +MYSQL_ROOT_PWD= +MYSQL_HOST= +# client IP seen by mysql server +MYSQL_CONTACT_IP= + +# -- Celerity -- +CELERITY_SIGNING_KEY='test' +CELERITY_CELERITY_WORKER_IP='127.0.1.1' + +# -- Network configuration -- +# applied with envsetup-launcher.sh client +NETWORK_IP=0 +NETWORK_DNS1=0 +NETWORK_DNS2=0 +NETWORK_MASK=0 +NETWORK_GATEWAY=0 + +# -- Cache server specific -- +# cache directory, prefer a ramfs - /tmp +CACHE_DIR='/tmp' +# only used by nginx internal - cache, toto +CACHE_NAME='cache' +# allowed size in GB - 100 +CACHE_SIZE='2' +# origin server - http://streaming-delltest.ubicast.net +CACHE_PROXY_PASS_STREAM='http://streaming.beta.ubicast.net' +# origin server - http://videos-delltest.ubicast.net +CACHE_PROXY_PASS_VOD='http://videos.beta.ubicast.net' +# munin - be carefull, format is important +CACHE_MUNIN_SRV=10\\.139\\.71\\.14 + +# -- Backup server specific (burp) -- +BURP_STATUS_IP= +BURPUI_PASSWORD='1234' +# FQDN +BURP_SERVER='backupserver.ubicast.net' +BURP_MAIL_DEST='sysadmin@ubicast.eu' +# default mediaserver +BURP_CLIENT_NAME= + +# -- HA server specific -- +HA_NODE1='ha-ms3' +HA_NODE1_IP='192.168.41.178' +HA_NODE2='ha-ms4' +HA_NODE2_IP='192.168.41.179' +HA_LB1='ha-lb3' +HA_LB1_IP='192.168.41.177' +HA_LB2= +HA_LB2_IP= + +# -- VM specific -- +# hypervisor +VM_HYPER=vboxserver +# path from ${VM_HYPER} +VM_STORE=/media/nas/EXPORT +# path to VM_STORE from your machine +VM_STORE_LOCAL=/media/nas/Production/images_vm/EXPORT +# spacecake virtual machines; if blank, will use ETC_HOSTNAME +VM_NAME= diff --git a/envsetup.conf b/envsetup.conf deleted file mode 100644 index fdbafe342f5e2cf1d58ae7fe3c35448b813d3cfe..0000000000000000000000000000000000000000 --- a/envsetup.conf +++ /dev/null @@ -1,143 +0,0 @@ -#!/bin/bash -### configuration -## general -GREEN='\033[0;32m' -RED='\033[0;31m' -CYAN='\033[0;36m' -NC='\033[0m' -# UbiCast password (shell account) -UBICAST_PASSWD=test -## repository -# cache for retrieving packages -CACHE=panel.ubicast.eu -# panel address -PANEL=skyreach.ubicast.net -# panel api key -API=sde6b2af8d9feb2153d82e8183aa26a5 -ETC_HOSTNAME=toto - -## envsetup -# superuser = ubicast -SUPERUSER_PWD=test -ADMIN_PWD=test -MONITOR_SUPERUSER_PWD=test -MONITOR_ADMIN_PWD=test -CM_SUPERUSER_PWD=test -CM_ADMIN_PWD=test -# customer shell account (admin) -SHELL_PWD=test - -# WOWZA -WOWZA_MANAGER_PWD=test -WOWZA_LICENSE=test -WOWZA_LIVE_PASSWD=123456789 -# MySQL -MYSQLD_PWD=1234 -# celerity -CELERIY_SIGNING_KEY=test -# is MS a worker too ? -IS_WORKER=0 -WORKER_IP=127.0.1.1 - -## CM -# apt-cache-ng credentials -APT_CACHE_USER=admin -#APT_CACHE_PASSWD=AUTOMATICALLY GENERATED - -## webserver URLs -# MS -HOSTNAME=maquette.ubicast.net -MS=maquette.ubicast.net -CM=cm-maquette.ubicast.net -MONITOR=monitor-maquette.ubicast.net -# streaming URL -WOWZA=streaming-maquette.ubicast.net - - -#--- client configuration (applied with envsetup-launcher.sh client) ---# -# locale : FR, EN -CUST_LOCALE=EN -CUST_TZ=EN -# NTP -CUST_NTP1= -CUST_NTP2= -CUST_NTP3= -CUST_IP=0 -CUST_NS1=0 -CUST_NS2=0 -CUST_NETMASK=0 -CUST_GATEWAY=0 -# SSL certificate # leave blank if none -SSL_CERTIFICATE=/etc/ssl/ubicast_net/STAR_ubicast_net_bundle.crt -SSL_CERTIFICATE_KEY=/etc/ssl/ubicast_net/ubicast_net.key -# proxy (0/1) -PROXY=0 -PROXY_AUTHENTICATION=0 -PROXY_HTTP= -PROXY_HTTPS= -PROXY_PORT= -PROXY_USER= -PROXY_PASSWD= -# SMTP server (leave blank if none) -CUST_SMTP= -DEFAULT_FROM_EMAIL=support@ubicast.eu -# MediaVault -CUST_BURP_MAIL_DEST=sysadmin@ubicast.eu - - -#--- MS & Worker specific ---# -# API - needed by worker -# ID - f100_dev -MS_ID= -# API - s00pN-aRseu-dnfMq-678CV-9nS9E -MS_API= -MS_SECRET= - -#--- cache server specific ---# -## cache -# cache directory, prefer a ramfs - /tmp -CACHE_DIR=/tmp -# only used by nginx internal - cache, toto -CACHE_NAME=cache -# allowed size in GB - 100 -CACHE_SIZE=2 -# origin server - http://streaming-delltest.ubicast.net -PROXY_PASS_STREAM=http://streaming.beta.ubicast.net -# origin server - http://videos-delltest.ubicast.net -PROXY_PASS_VOD=http://videos.beta.ubicast.net -# munin - be carefull, format is important -MUNIN_SRV=10\\.139\\.71\\.14 - -#--- backup server specific ---# -BURP_STATUS_IP= -BURPUI_PASSWORD=1234 -# FQDN -BURP_SERVER=backupserver.ubicast.net -BURP_MAIL_DEST=sysadmin@ubicast.eu -# default mediaserver -BURP_CLIENT_NAME= - -#--- HA server specific ---# -## HA -NODE1=ha-ms3 -NODE1_IP=192.168.41.178 -NODE2=ha-ms4 -NODE2_IP=192.168.41.179 -LB1=ha-lb3 -LB1_IP=192.168.41.177 -LB2= -LB2_IP= - -#--- VM specific ---# -## spacecake virtual machines -KEY=~/.ssh/ubicast_support -# hypervisor -HYPER=vboxserver -# path from ${HYPER} -STORE=/media/nas/EXPORT -# path to STORE from your machine -STORE_LOCAL=/media/nas/Production/images_vm/EXPORT - -## spacecake virtual machines -# if blank, will use ETC_HOSTNAME -VM= diff --git a/envsetup.py b/envsetup.py index 473028f3beeb83f6c61be6ccc69ed1925b1891c5..35eef5850a91ce9a90cc3a2065db174a16238d60 100755 --- a/envsetup.py +++ b/envsetup.py @@ -17,7 +17,7 @@ class EnvSetup(): BASH_SETUP_NAME = '0_setup.sh' def __init__(self, *args): - utils.display_header() + self.display_header() args = list(args) # Check current dir root_dir = utils.get_dir(__file__) @@ -70,6 +70,11 @@ class EnvSetup(): # Open main menu self.menu() + def display_header(self): + log('\033[96m-------------------------------------\033[0m') + log('\033[96m- Environment setup for MediaServer -\033[0m') + log('\033[96m-------------------------------------\033[0m') + def menu(self): # Show main menu log('Actions:') @@ -166,7 +171,7 @@ class EnvSetup(): except (KeyboardInterrupt, EOFError): log('') sys.exit(exit_code) - utils.display_header() + self.display_header() self.menu() else: sys.exit(exit_code) diff --git a/envsetup-launcher.sh b/launcher.sh similarity index 75% rename from envsetup-launcher.sh rename to launcher.sh index f332734d4d30f7075e3a2a0a57eade861668a681..3a837de6f31214fc4cb7444fc1d5c3fde0737947 100755 --- a/envsetup-launcher.sh +++ b/launcher.sh @@ -90,45 +90,45 @@ reconf_smtp() { python3 /root/envsetup/envsetup.py 103 } -wowza_license() { +WOWZA_LICENSE() { python3 /root/envsetup/envsetup.py 105 } exportvm() { KEY=~/.ssh/ubicast_support - HYPER=$(grep HYPER ${CONF} | awk -F "=" '{print$2}') - STORE=$(grep STORE ${CONF} | head -1 | awk -F "=" '{print$2}') - STORE_LOCAL=$(grep STORE_LOCAL ${CONF} | awk -F "=" '{print$2}') + VM_HYPER=$(grep VM_HYPER ${CONF} | awk -F "=" '{print$2}') + VM_STORE=$(grep VM_STORE ${CONF} | head -1 | awk -F "=" '{print$2}') + VM_STORE_LOCAL=$(grep VM_STORE_LOCAL ${CONF} | awk -F "=" '{print$2}') - if ( test -z $VM ); then - VM=$(cat ${CONF} | egrep ^ETC_HOSTNAME | head -1 | awk -F "=" '{print$2}') + if ( test -z $VM_NAME ); then + VM_NAME=$(cat ${CONF} | egrep ^ETC_HOSTNAME | head -1 | awk -F "=" '{print$2}') else - VM=$(grep VM ${CONF} | awk -F "=" '{print$2}') + VM_NAME=$(grep VM ${CONF} | awk -F "=" '{print$2}') fi - ssh -i ${KEY} -o User=root ${HYPER} "VBoxManage export ${VM} -o ${STORE}/${VM}.ovf --ovf10" + ssh -i ${KEY} -o User=root ${VM_HYPER} "VBoxManage export ${VM_NAME} -o ${VM_STORE}/${VM_NAME}.ovf --ovf10" # vbox conf file created # generating vmware conf file - cp ${STORE_LOCAL}/${VM}.ovf ${STORE_LOCAL}/${VM}_vmware.ovf - sed -i "s@<vssd:VirtualSystemType>virtualbox-2.2</vssd:VirtualSystemType>@<vssd:VirtualSystemType>vmx-07</vssd:VirtualSystemType>@" ${STORE_LOCAL}/${VM}_vmware.ovf - sed -i "s@<rasd:Caption>sataController0</rasd:Caption>@<rasd:Caption>SCSIController</rasd:Caption>@" ${STORE_LOCAL}/${VM}_vmware.ovf - sed -i "s@<rasd:Description>SATA Controller</rasd:Description>@<rasd:Description>SCSIController</rasd:Description>@" ${STORE_LOCAL}/${VM}_vmware.ovf - sed -i "s@<rasd:ElementName>sataController0</rasd:ElementName>@<rasd:ElementName>SCSIController</rasd:ElementName>@" ${STORE_LOCAL}/${VM}_vmware.ovf - sed -i "s@<rasd:ResourceSubType>AHCI</rasd:ResourceSubType>@<rasd:ResourceSubType>lsilogic</rasd:ResourceSubType>@" ${STORE_LOCAL}/${VM}_vmware.ovf - sed -i "s@<rasd:ResourceType>20</rasd:ResourceType>@<rasd:ResourceType>6</rasd:ResourceType>@" ${STORE_LOCAL}/${VM}_vmware.ovf + cp ${VM_STORE_LOCAL}/${VM_NAME}.ovf ${VM_STORE_LOCAL}/${VM_NAME}_vmware.ovf + sed -i "s@<vssd:VirtualSystemType>virtualbox-2.2</vssd:VirtualSystemType>@<vssd:VirtualSystemType>vmx-07</vssd:VirtualSystemType>@" ${VM_STORE_LOCAL}/${VM_NAME}_vmware.ovf + sed -i "s@<rasd:Caption>sataController0</rasd:Caption>@<rasd:Caption>SCSIController</rasd:Caption>@" ${VM_STORE_LOCAL}/${VM_NAME}_vmware.ovf + sed -i "s@<rasd:Description>SATA Controller</rasd:Description>@<rasd:Description>SCSIController</rasd:Description>@" ${VM_STORE_LOCAL}/${VM_NAME}_vmware.ovf + sed -i "s@<rasd:ElementName>sataController0</rasd:ElementName>@<rasd:ElementName>SCSIController</rasd:ElementName>@" ${VM_STORE_LOCAL}/${VM_NAME}_vmware.ovf + sed -i "s@<rasd:ResourceSubType>AHCI</rasd:ResourceSubType>@<rasd:ResourceSubType>lsilogic</rasd:ResourceSubType>@" ${VM_STORE_LOCAL}/${VM_NAME}_vmware.ovf + sed -i "s@<rasd:ResourceType>20</rasd:ResourceType>@<rasd:ResourceType>6</rasd:ResourceType>@" ${VM_STORE_LOCAL}/${VM_NAME}_vmware.ovf # recherche n° ligne paragraphe à supp. - LIG=$(grep -n '<rasd:AddressOnParent>3</rasd:AddressOnParent>' ${STORE_LOCAL}/${VM}_vmware.ovf | awk -F ":" '{print$1}') + LIG=$(grep -n '<rasd:AddressOnParent>3</rasd:AddressOnParent>' ${VM_STORE_LOCAL}/${VM_NAME}_vmware.ovf | awk -F ":" '{print$1}') LIG0=$(( $LIG - 1 )) LIG1=$(( $LIG0 + 9 )) - sed -i "${LIG0},${LIG1}d" ${STORE_LOCAL}/${VM}_vmware.ovf + sed -i "${LIG0},${LIG1}d" ${VM_STORE_LOCAL}/${VM_NAME}_vmware.ovf # converting disk to qemu image - qemu-img convert -c -O qcow2 ${STORE_LOCAL}/${VM}-disk1.vmdk ${STORE_LOCAL}/${VM}.qcow2 + qemu-img convert -c -O qcow2 ${VM_STORE_LOCAL}/${VM_NAME}-disk1.vmdk ${VM_STORE_LOCAL}/${VM_NAME}.qcow2 - echo -e "${CYAN}Files are available at ${STORE_LOCAL}${NC}" + echo -e "${CYAN}Files are available at ${VM_STORE_LOCAL}${NC}" } case "$1" in @@ -178,7 +178,7 @@ case "$1" in ;; "wrecette") - wowza_license + WOWZA_LICENSE reconf_recette ;; diff --git a/tests/test_ntp.sh b/tests/test_ntp.sh index 263751eef3c10b179b07e208e9c6591a6f415455..6b56c61ecc461a617a5a09206ad061a8a94b4319 100755 --- a/tests/test_ntp.sh +++ b/tests/test_ntp.sh @@ -3,7 +3,7 @@ source /root/envsetup/envsetup.conf set -e -NTP_SERVER="$CUST_NTP1" +NTP_SERVER="$NTP_SERVER1" if [ "${NTP_SERVER}" = "" ]; then NTP_SERVER="ntp.ubuntu.com" fi diff --git a/utils.py b/utils.py index 4d7f5e4b9c3e6a478c39db61c745a6e339a368e3..c59ee2e44d46af798cf6e9e3bbec1123242c42d4 100644 --- a/utils.py +++ b/utils.py @@ -1,14 +1,14 @@ #!/usr/bin/python3 # -*- coding: utf-8 -*- -import imp import os +import re import subprocess import sys -DEFAULT_CONF_PATH = 'default_conf.py' -CONF_PATH = 'conf.py' -CONF = None +DEFAULT_CONF_PATH = 'default-conf.sh' +CONF_PATH = 'conf.sh' +CONF = dict() def log(text, error=False): @@ -40,41 +40,45 @@ def exec_cmd(cmd, get_out=False): return p.returncode -def display_header(): - log('\033[96m-------------------------------------\033[0m') - log('\033[96m- Environment setup for MediaServer -\033[0m') - log('\033[96m-------------------------------------\033[0m') - - def load_conf(): - if not os.path.exists(CONF_PATH): - log('The configuration file for EnvSetup script does not exist.\nPath of configuration file: %s' % CONF_PATH) - sys.exit(1) - # Load conf - try: - envsetup_conf = imp.load_source('envsetup_conf', CONF_PATH) - except Exception as e: - log('The configuration file for EnvSetup script cannot be loaded.\nPath of configuration file: %s\nError:\n %s' % (CONF_PATH, e)) - sys.exit(1) - globals()['CONF'] = envsetup_conf - # Check a value to know if the config file has been changed - try: - value = getattr(CONF, 'ms_server_name') - except Exception as e: - log('The configuration file for EnvSetup script is missing a required value: ms_server_name.\nPlease check that the configuration file is correct.\nPath of configuration file: %s\nError:\n %s' % (CONF_PATH, e)) - sys.exit(1) - if value == 'mediaserver': - log('\033[93mWarning:\033[0m') - log('The configuration file for EnvSetup script contains the default value for ms_server_name.') - log('Perhaps you forget to change the configuration.') - log('Path of configuration file: %s' % CONF_PATH) - log('Perhaps you want to quit this script to change the configuration?\n') + files = ( + (DEFAULT_CONF_PATH, True), + (CONF_PATH, False), + ) + for path, mandatory 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 mandatory: + sys.exit(1) + # Load conf + with open(path, 'r') as fo: + content = fo.read() + # Parse conf + for line in content.split('\n'): + line = line.strip() + if line and not line.startswith('#') and '=' in line: + name, *val = line.split('=') + name = name.strip(' \t\'\"') + val = ('='.join(val)).strip(' \t\'\"') + CONF[name] = val + # Check a value to know if the config file has been changed + try: + value = getattr(CONF, 'MS_SERVER_NAME') + except Exception as e: + log('The configuration file for EnvSetup script is missing a required value: MS_SERVER_NAME.\nPlease check that the configuration file is correct.\nPath of configuration file: %s\nError:\n %s' % (CONF_PATH, e)) + sys.exit(1) + if value == 'mediaserver': + log('\033[93mWarning:\033[0m') + log('The configuration file for EnvSetup script contains the default value for MS_SERVER_NAME.') + log('Perhaps you forget to change the configuration.') + log('Path of configuration file: %s' % CONF_PATH) + log('Perhaps you want to quit this script to change the configuration?\n') def get_conf(name, default=None): if not CONF: load_conf() - return getattr(CONF, name, default) + return CONF.get(name, default) def run_commands(cmds):