diff --git a/1.Utilities/0_setup.py b/1.Base/1.Utilities/0_setup.py similarity index 83% rename from 1.Utilities/0_setup.py rename to 1.Base/1.Utilities/0_setup.py index 86921deb4a388ec922f4400daaaa92be0f33dff0..150b322e506c3b459cb8337ab3642e0e6999a962 100644 --- a/1.Utilities/0_setup.py +++ b/1.Base/1.Utilities/0_setup.py @@ -1,4 +1,4 @@ -#!/usr/bin/python3 +#!/usr/bin/env python3 # -*- coding: utf-8 -*- import os @@ -10,6 +10,10 @@ def setup(interactive=True): 'apt-get clean', 'apt-get update', 'apt-get install --yes make ipython ipython3 vim netcat git htop iotop bmon host lm-sensors pciutils ntp nfs-client smartmontools pwgen ntpdate dialog curl', + # Locale + 'locale-gen en_GB.UTF-8', + 'update-locale LANG=en_GB.UTF-8 LANGUAGE=en_GB.UTF-8 LC_ALL=en_GB.UTF-8 LC_MESSAGES=en_GB.UTF-8', + # Vim colors '[ -f ~/.vimrc ] || echo "color ron" > ~/.vimrc', ] utils.run_commands(cmds) @@ -39,8 +43,8 @@ alias rmpyc='find . -name *.pyc -type f -delete && find . -name __pycache__ -typ bashrc_path = os.path.expanduser('~/.bashrc') bashrc = '' if os.path.exists(bashrc_path): - with open(bashrc_path, 'r') as fd: - bashrc = fd.read() + with open(bashrc_path, 'r') as fo: + bashrc = fo.read() new_bashrc = bashrc.replace('#force_color_prompt=yes', 'force_color_prompt=yes') for line in lines.split('\n'): line = line.strip() @@ -50,7 +54,7 @@ alias rmpyc='find . -name *.pyc -type f -delete && find . -name __pycache__ -typ new_bashrc += '\n' + line if new_bashrc != bashrc: new_bashrc += '\n' - with open(bashrc_path, 'w') as fd: - fd.write(new_bashrc) + with open(bashrc_path, 'w') as fo: + fo.write(new_bashrc) utils.log('bashrc file updated: %s' % bashrc_path) utils.log('bashrc file up to date.') diff --git a/2.System/0_setup.py b/1.Base/2.ubicast_shell_access/0_setup.py similarity index 72% rename from 2.System/0_setup.py rename to 1.Base/2.ubicast_shell_access/0_setup.py index 456a4cc5be7fd31f72b5d644b79e3c914c086a73..532273d42421559675ed14282f318382a2f41b8d 100644 --- a/2.System/0_setup.py +++ b/1.Base/2.ubicast_shell_access/0_setup.py @@ -1,21 +1,13 @@ -#!/usr/bin/python3 +#!/usr/bin/env python3 # -*- coding: utf-8 -*- +import subprocess + import utils def setup(interactive=True): - # TODO: setup IP dir_path = utils.get_dir(__file__) - cmds = [ - # Locale - 'locale-gen en_GB.UTF-8', - 'update-locale LANG=en_GB.UTF-8 LANGUAGE=en_GB.UTF-8 LC_ALL=en_GB.UTF-8 LC_MESSAGES=en_GB.UTF-8', - # NTP - 'echo "Replacing /etc/ntp.conf"', - dict(line='write', template='%s/ntp.conf' % dir_path, target='/etc/ntp.conf', params=( - ('{{ NTP_SERVER1 }}', utils.get_conf('NTP_SERVER1', 'ntp.ubuntu.com')), - )), - ] + cmds = list() # Create / update ubicast account cmds.append('echo "Checking ubicast account"') code, out = utils.exec_cmd(['id', 'ubicast']) @@ -45,3 +37,11 @@ def setup(interactive=True): cmds.append('chown -R ubicast:ubicast /home/ubicast/.ssh') utils.run_commands(cmds) + # Set ubicast password if any + pwd = utils.get_conf('SHELL_UBICAST_PWD') + if pwd and pwd != 'test': + p = subprocess.Popen(['passwd', '-q', 'ubicast'], stdin=subprocess.PIPE) + p.communicate(input=b'%(pwd)s\n%(pwd)s' % dict(pwd=pwd.encode('utf-8'))) + if p.returncode != 0: + raise Exception('Failed to set ubicast account password.') + utils.log('\033[1;33m The ubicast account password has been set. \033[0m') diff --git a/2.System/ubicast_support.pub b/1.Base/2.ubicast_shell_access/ubicast_support.pub similarity index 100% rename from 2.System/ubicast_support.pub rename to 1.Base/2.ubicast_shell_access/ubicast_support.pub diff --git a/1.Base/3.admin_shell_account/0_setup.py b/1.Base/3.admin_shell_account/0_setup.py new file mode 100644 index 0000000000000000000000000000000000000000..50cbeb8846a2a38ef59754d117af998a26728b97 --- /dev/null +++ b/1.Base/3.admin_shell_account/0_setup.py @@ -0,0 +1,29 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +import subprocess + +import utils + + +def setup(interactive=True): + # Create / update admin account + utils.log('Checking admin account') + cmds = list() + code, out = utils.exec_cmd(['id', 'admin']) + if code != 0: + cmds.append('useradd -m -s /bin/bash admin') + out = '' + if 'sudo' not in out: + cmds.append('usermod -aG sudo admin') + cmds.append('mkdir -p /home/admin/.ssh') + cmds.append('chmod 700 /home/admin/.ssh') + cmds.append('chown -R admin:admin /home/admin/.ssh') + utils.run_commands(cmds) + # Set password if any + pwd = utils.get_conf('SHELL_ADMIN_PWD') + if pwd and pwd != 'test': + p = subprocess.Popen(['passwd', '-q', 'admin'], stdin=subprocess.PIPE) + p.communicate(input=b'%(pwd)s\n%(pwd)s' % dict(pwd=pwd.encode('utf-8'))) + if p.returncode != 0: + raise Exception('Failed to set admin account password.') + utils.log('\033[1;33m The admin account password has been set. \033[0m') diff --git a/10.VM/1.Export_VM/0_setup.sh b/10.VM/1.Export_VM/0_setup.sh new file mode 100755 index 0000000000000000000000000000000000000000..66e77a00fae53a09b8075c5c56fd17ac1843eea1 --- /dev/null +++ b/10.VM/1.Export_VM/0_setup.sh @@ -0,0 +1,37 @@ +#!/bin/bash +source /root/envsetup/conf.sh + +KEY=~/.ssh/ubicast_support +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_NAME ); then + VM_NAME=$(cat ${CONF} | egrep ^ETC_HOSTNAME | head -1 | awk -F "=" '{print$2}') +else + VM_NAME=$(grep VM ${CONF} | awk -F "=" '{print$2}') +fi + +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 ${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>' ${VM_STORE_LOCAL}/${VM_NAME}_vmware.ovf | awk -F ":" '{print$1}') +LIG0=$(( $LIG - 1 )) +LIG1=$(( $LIG0 + 9 )) +sed -i "${LIG0},${LIG1}d" ${VM_STORE_LOCAL}/${VM_NAME}_vmware.ovf + +# converting disk to qemu image +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 ${VM_STORE_LOCAL}${NC}" diff --git a/10.VM/2.Export_VM_local/0_setup.sh b/10.VM/2.Export_VM_local/0_setup.sh new file mode 100755 index 0000000000000000000000000000000000000000..5ce30466f68c94be888733af856ad7d15c410bf6 --- /dev/null +++ b/10.VM/2.Export_VM_local/0_setup.sh @@ -0,0 +1,27 @@ +#!/bin/bash +source /root/envsetup/conf.sh + +VM_STORE=/home/jallary/ubicast/TMP/ENVOI +VM_STORE_LOCAL=/home/jallary/ubicast/TMP/ENVOI +# depuis poste local +VBoxManage export ${VM_NAME} -o ${VM_STORE}/${VM_NAME}.ovf --ovf10 + +# generating vmware conf file +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>' ${VM_STORE_LOCAL}/${VM_NAME}_vmware.ovf | awk -F ":" '{print$1}') +LIG0=$(( $LIG - 1 )) +LIG1=$(( $LIG0 + 9 )) +sed -i "${LIG0},${LIG1}d" ${VM_STORE_LOCAL}/${VM_NAME}_vmware.ovf + +# converting disk to qemu image +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 ${VM_STORE_LOCAL}${NC}" diff --git a/100.--- Client configuration & testing ---/placeholder b/100.--- Client configuration & testing ---/placeholder deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/4.Postfix/0_setup.py b/2.Common_services/1.Postfix/0_setup.py similarity index 97% rename from 4.Postfix/0_setup.py rename to 2.Common_services/1.Postfix/0_setup.py index 67589d1dc10aa16625e1ab45d87f13a9a769069c..065167ae2f836b5c0868463c44b11e8b2fcf4bf9 100644 --- a/4.Postfix/0_setup.py +++ b/2.Common_services/1.Postfix/0_setup.py @@ -1,4 +1,4 @@ -#!/usr/bin/python3 +#!/usr/bin/env python3 # -*- coding: utf-8 -*- import utils diff --git a/4.Postfix/main.cf b/2.Common_services/1.Postfix/main.cf similarity index 100% rename from 4.Postfix/main.cf rename to 2.Common_services/1.Postfix/main.cf diff --git a/2.Common_services/2.NTP/0_setup.py b/2.Common_services/2.NTP/0_setup.py new file mode 100644 index 0000000000000000000000000000000000000000..33a2358d9d1e31e05466480c62abf096743d2a32 --- /dev/null +++ b/2.Common_services/2.NTP/0_setup.py @@ -0,0 +1,15 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +import utils + + +def setup(interactive=True): + dir_path = utils.get_dir(__file__) + cmds = [ + # NTP + 'echo "Replacing /etc/ntp.conf"', + dict(line='write', template='%s/ntp.conf' % dir_path, target='/etc/ntp.conf', params=( + ('{{ NTP_SERVER1 }}', utils.get_conf('NTP_SERVER1') or 'ntp.ubuntu.com'), + )), + ] + utils.run_commands(cmds) diff --git a/2.System/ntp.conf b/2.Common_services/2.NTP/ntp.conf similarity index 100% rename from 2.System/ntp.conf rename to 2.Common_services/2.NTP/ntp.conf diff --git a/3.MySQL/0_setup.py b/2.Common_services/3.MySQL/0_setup.py similarity index 97% rename from 3.MySQL/0_setup.py rename to 2.Common_services/3.MySQL/0_setup.py index f0080f0028e783076de653cc0399c66eba110b97..669f9c67c81fad130709bb53736d29fa737c930b 100644 --- a/3.MySQL/0_setup.py +++ b/2.Common_services/3.MySQL/0_setup.py @@ -1,4 +1,4 @@ -#!/usr/bin/python3 +#!/usr/bin/env python3 # -*- coding: utf-8 -*- import utils diff --git a/3.MySQL/mysql.cnf b/2.Common_services/3.MySQL/mysql.cnf similarity index 100% rename from 3.MySQL/mysql.cnf rename to 2.Common_services/3.MySQL/mysql.cnf diff --git a/3.MySQL/override.conf b/2.Common_services/3.MySQL/override.conf similarity index 100% rename from 3.MySQL/override.conf rename to 2.Common_services/3.MySQL/override.conf diff --git a/5.Wowza/0_setup.py b/2.Common_services/4.Wowza/0_setup.py similarity index 99% rename from 5.Wowza/0_setup.py rename to 2.Common_services/4.Wowza/0_setup.py index 62ee95e9e7df9e545ddb8738ec5cc82a81fc78cb..f4116db04bcfa9c1e3f9f27ef1324f1b63f2d065 100644 --- a/5.Wowza/0_setup.py +++ b/2.Common_services/4.Wowza/0_setup.py @@ -1,4 +1,4 @@ -#!/usr/bin/python3 +#!/usr/bin/env python3 # -*- coding: utf-8 -*- import os diff --git a/5.Wowza/Tune.xml b/2.Common_services/4.Wowza/Tune.xml similarity index 100% rename from 5.Wowza/Tune.xml rename to 2.Common_services/4.Wowza/Tune.xml diff --git a/5.Wowza/live-application.xml b/2.Common_services/4.Wowza/live-application.xml similarity index 100% rename from 5.Wowza/live-application.xml rename to 2.Common_services/4.Wowza/live-application.xml diff --git a/5.Wowza/live-application.xml.bak b/2.Common_services/4.Wowza/live-application.xml.bak similarity index 100% rename from 5.Wowza/live-application.xml.bak rename to 2.Common_services/4.Wowza/live-application.xml.bak diff --git a/5.Wowza/wowza-update.sh.back b/2.Common_services/4.Wowza/wowza-update.sh.back similarity index 100% rename from 5.Wowza/wowza-update.sh.back rename to 2.Common_services/4.Wowza/wowza-update.sh.back diff --git a/6.Nginx/0_setup.py b/2.Common_services/5.Nginx/0_setup.py similarity index 99% rename from 6.Nginx/0_setup.py rename to 2.Common_services/5.Nginx/0_setup.py index 14f931a8d4616712ba3507bc4c6f6d7092c66945..228843ff8e919cb9f2e6d4df67295ccdf4d3f67e 100644 --- a/6.Nginx/0_setup.py +++ b/2.Common_services/5.Nginx/0_setup.py @@ -1,4 +1,4 @@ -#!/usr/bin/python3 +#!/usr/bin/env python3 # -*- coding: utf-8 -*- import os import re diff --git a/6.Nginx/crossdomain.xml b/2.Common_services/5.Nginx/crossdomain.xml similarity index 100% rename from 6.Nginx/crossdomain.xml rename to 2.Common_services/5.Nginx/crossdomain.xml diff --git a/6.Nginx/vhost_mediaserver-msuser.conf b/2.Common_services/5.Nginx/vhost_mediaserver-msuser.conf similarity index 100% rename from 6.Nginx/vhost_mediaserver-msuser.conf rename to 2.Common_services/5.Nginx/vhost_mediaserver-msuser.conf diff --git a/6.Nginx/vhost_msmonitor.conf b/2.Common_services/5.Nginx/vhost_msmonitor.conf similarity index 100% rename from 6.Nginx/vhost_msmonitor.conf rename to 2.Common_services/5.Nginx/vhost_msmonitor.conf diff --git a/6.Nginx/vhost_skyreach.conf b/2.Common_services/5.Nginx/vhost_skyreach.conf similarity index 100% rename from 6.Nginx/vhost_skyreach.conf rename to 2.Common_services/5.Nginx/vhost_skyreach.conf diff --git a/6.Nginx/vhost_streaming.conf b/2.Common_services/5.Nginx/vhost_streaming.conf similarity index 100% rename from 6.Nginx/vhost_streaming.conf rename to 2.Common_services/5.Nginx/vhost_streaming.conf diff --git a/6.Nginx/vhost_videos.conf b/2.Common_services/5.Nginx/vhost_videos.conf similarity index 100% rename from 6.Nginx/vhost_videos.conf rename to 2.Common_services/5.Nginx/vhost_videos.conf diff --git a/7.Munin/0_setup.sh b/2.Common_services/6.Munin/0_setup.sh similarity index 93% rename from 7.Munin/0_setup.sh rename to 2.Common_services/6.Munin/0_setup.sh index fd7e29b6176f6ee02119501288fb3bcee35f31f0..f779b19d64c4ca715c8750a29dc6ce096d996d9d 100755 --- a/7.Munin/0_setup.sh +++ b/2.Common_services/6.Munin/0_setup.sh @@ -1,7 +1,7 @@ #!/bin/bash source /root/envsetup/conf.sh -# This script should be run after Nginx and Wowza setup (if they should be installed) +# This script should be run after Nginx, MySQL and Wowza setup (if they should be installed) # munin DEBIAN_FRONTEND=noninteractive apt-get install -y ubicast-config diff --git a/20.--- Configuration ---/placeholder b/20.--- Configuration ---/placeholder deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/101.Apply_client_configuration/0_setup.sh b/20.Client configuration & testing/1.Apply_client_configuration/0_setup.sh similarity index 100% rename from 101.Apply_client_configuration/0_setup.sh rename to 20.Client configuration & testing/1.Apply_client_configuration/0_setup.sh diff --git a/102.Run_tests/0_setup.sh b/20.Client configuration & testing/2.Dump_config/0_setup.sh similarity index 100% rename from 102.Run_tests/0_setup.sh rename to 20.Client configuration & testing/2.Dump_config/0_setup.sh diff --git a/103.Configure_client_smtp/0_setup.sh b/20.Client configuration & testing/3.Configure_client_smtp/0_setup.sh similarity index 100% rename from 103.Configure_client_smtp/0_setup.sh rename to 20.Client configuration & testing/3.Configure_client_smtp/0_setup.sh diff --git a/104.Apply_default_configuration/0_setup.sh b/20.Client configuration & testing/4.Apply_default_configuration/0_setup.sh similarity index 100% rename from 104.Apply_default_configuration/0_setup.sh rename to 20.Client configuration & testing/4.Apply_default_configuration/0_setup.sh diff --git a/105.Insert_wowza_license/0_setup.sh b/20.Client configuration & testing/5.Insert_wowza_license/0_setup.sh similarity index 100% rename from 105.Insert_wowza_license/0_setup.sh rename to 20.Client configuration & testing/5.Insert_wowza_license/0_setup.sh diff --git a/200.--- Deprecated ---/placeholder b/200.--- Deprecated ---/placeholder deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/23.Initialize_environment/0_setup.sh b/23.Initialize_environment/0_setup.sh deleted file mode 100755 index a8cc0659141e5570d84ebde2b419ca4877c5b4c4..0000000000000000000000000000000000000000 --- a/23.Initialize_environment/0_setup.sh +++ /dev/null @@ -1,52 +0,0 @@ -#!/bin/bash -source /root/envsetup/conf.sh - -# hostname -echo "127.0.0.1 ${ETC_HOSTNAME}" >> /etc/hosts -echo ${ETC_HOSTNAME} > /etc/hostname - -# DNS -cat > /etc/resolv.conf << EOF -search ubicast.net -nameserver 192.168.40.3 -nameserver 192.168.40.2 -nameserver 192.168.40.6 -EOF - -# set ubicast account pwd -if ( ! test -z ${SHELL_UBICAST_PWD} ); then - echo -e "${SHELL_UBICAST_PWD}\n${SHELL_UBICAST_PWD}" | passwd -q ubicast -fi - -# create admin account -if ( ! id admin >/dev/null ); then - useradd -m admin --shell /bin/bash -fi -usermod -aG sudo admin -if ( ! test -z ${SHELL_ADMIN_PWD} ); then - echo -e "${SHELL_ADMIN_PWD}\n${SHELL_ADMIN_PWD}" | passwd -q admin -fi - -# DELL server - install dell openmanage -if ( ! dpkg -l | grep dmidecode ) -then -apt-get install -y dmidecode -fi - -dmidecode > /tmp/dmidecode - -if ( grep Dell /tmp/dmidecode ) -then -echo 'deb http://linux.dell.com/repo/community/ubuntu xenial openmanage' | sudo tee -a /etc/apt/sources.list.d/linux.dell.com.sources.list -gpg --keyserver pool.sks-keyservers.net --recv-key 1285491434D8786F -gpg -a --export 1285491434D8786F | sudo apt-key add - - -apt-get update && apt-get install -y srvadmin-all - -update-rc.d dsm_om_connsvc defaults -echo "@reboot root /usr/sbin/service dsm_om_connsvc start" > /etc/cron.d/dell_openmanage - -sed -i "s@^root@root,admin@" /opt/dell/srvadmin/etc/omarolemap - -service dsm_om_connsvc start -fi diff --git a/21.Download_configuration_file/0_setup.sh b/3.New_server_deployment/1.Download_envsetup_config/0_setup.sh similarity index 100% rename from 21.Download_configuration_file/0_setup.sh rename to 3.New_server_deployment/1.Download_envsetup_config/0_setup.sh diff --git a/22.Initialize_configuration_file/0_setup.sh b/3.New_server_deployment/2.Fill_empty_conf/0_setup.sh similarity index 100% rename from 22.Initialize_configuration_file/0_setup.sh rename to 3.New_server_deployment/2.Fill_empty_conf/0_setup.sh diff --git a/24.Initialize_APT/0_setup.sh b/3.New_server_deployment/3.Initialize_APT/0_setup.sh similarity index 100% rename from 24.Initialize_APT/0_setup.sh rename to 3.New_server_deployment/3.Initialize_APT/0_setup.sh diff --git a/24.Initialize_APT/sources16.list b/3.New_server_deployment/3.Initialize_APT/sources16.list similarity index 100% rename from 24.Initialize_APT/sources16.list rename to 3.New_server_deployment/3.Initialize_APT/sources16.list diff --git a/3.New_server_deployment/4.Dell_openmanage/0_setup.sh b/3.New_server_deployment/4.Dell_openmanage/0_setup.sh new file mode 100755 index 0000000000000000000000000000000000000000..19b079014e4626c39837f56b4446add3a34cde04 --- /dev/null +++ b/3.New_server_deployment/4.Dell_openmanage/0_setup.sh @@ -0,0 +1,23 @@ +#!/bin/bash +source /root/envsetup/conf.sh + +# DELL server - install dell openmanage +if ( ! dpkg -l | grep dmidecode ); then + apt-get install -y dmidecode +fi + +if ( dmidecode | grep Dell ); then + echo 'deb http://linux.dell.com/repo/community/ubuntu xenial openmanage' | sudo tee -a /etc/apt/sources.list.d/linux.dell.com.sources.list + gpg --keyserver pool.sks-keyservers.net --recv-key 1285491434D8786F + gpg -a --export 1285491434D8786F | sudo apt-key add - + + apt-get update + apt-get install -y srvadmin-all + + update-rc.d dsm_om_connsvc defaults + echo "@reboot root /usr/sbin/service dsm_om_connsvc start" > /etc/cron.d/dell_openmanage + + sed -i "s@^root@root,admin@" /opt/dell/srvadmin/etc/omarolemap + + service dsm_om_connsvc start +fi diff --git a/30.--- Monitor ---/placeholder b/30.--- Monitor ---/placeholder deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/202.test envsetup/0_setup.sh b/30.Deprecated/1.Fake_actions_to_test_envsetup/0_setup.sh similarity index 100% rename from 202.test envsetup/0_setup.sh rename to 30.Deprecated/1.Fake_actions_to_test_envsetup/0_setup.sh diff --git a/201.deprecated - FTP/0_setup.py b/30.Deprecated/2.FTP/0_setup.py similarity index 99% rename from 201.deprecated - FTP/0_setup.py rename to 30.Deprecated/2.FTP/0_setup.py index 8970d0209920660ff45ff4f811927b60d109b0ac..c2f1ef685291cfde92227388fdc66b0b86a8d1e6 100644 --- a/201.deprecated - FTP/0_setup.py +++ b/30.Deprecated/2.FTP/0_setup.py @@ -1,4 +1,4 @@ -#!/usr/bin/python3 +#!/usr/bin/env python3 # -*- coding: utf-8 -*- import os diff --git a/201.deprecated - FTP/create_account.sh b/30.Deprecated/2.FTP/create_account.sh similarity index 100% rename from 201.deprecated - FTP/create_account.sh rename to 30.Deprecated/2.FTP/create_account.sh diff --git a/201.deprecated - FTP/on_ftp_upload.py b/30.Deprecated/2.FTP/on_ftp_upload.py similarity index 100% rename from 201.deprecated - FTP/on_ftp_upload.py rename to 30.Deprecated/2.FTP/on_ftp_upload.py diff --git a/201.deprecated - FTP/pure-ftpd-common b/30.Deprecated/2.FTP/pure-ftpd-common similarity index 100% rename from 201.deprecated - FTP/pure-ftpd-common rename to 30.Deprecated/2.FTP/pure-ftpd-common diff --git a/201.deprecated - FTP/remove_empty_dirs.py b/30.Deprecated/2.FTP/remove_empty_dirs.py similarity index 100% rename from 201.deprecated - FTP/remove_empty_dirs.py rename to 30.Deprecated/2.FTP/remove_empty_dirs.py diff --git a/203.HCA/0_setup.py b/30.Deprecated/3.HCA/0_setup.py similarity index 98% rename from 203.HCA/0_setup.py rename to 30.Deprecated/3.HCA/0_setup.py index 6792b7e38ef630c4b1ed8ee5cdd146faca2d4314..f0c3895beafa7cce0f669634032d7a34c0cdc7a0 100644 --- a/203.HCA/0_setup.py +++ b/30.Deprecated/3.HCA/0_setup.py @@ -1,4 +1,4 @@ -#!/usr/bin/python3 +#!/usr/bin/env python3 # -*- coding: utf-8 -*- import os diff --git a/203.HCA/http.ini b/30.Deprecated/3.HCA/http.ini similarity index 100% rename from 203.HCA/http.ini rename to 30.Deprecated/3.HCA/http.ini diff --git a/203.HCA/rtmp.ini b/30.Deprecated/3.HCA/rtmp.ini similarity index 100% rename from 203.HCA/rtmp.ini rename to 30.Deprecated/3.HCA/rtmp.ini diff --git a/31.Install_monitor/0_setup.sh b/4.Monitor/1.Install_monitor/0_setup.sh similarity index 100% rename from 31.Install_monitor/0_setup.sh rename to 4.Monitor/1.Install_monitor/0_setup.sh diff --git a/40.--- MediaServer ---/placeholder b/40.--- MediaServer ---/placeholder deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/42.nginx_tweaks/0_setup.sh b/42.nginx_tweaks/0_setup.sh deleted file mode 100755 index f063df6c660299e7d0cc840b16c22d2b72933aca..0000000000000000000000000000000000000000 --- a/42.nginx_tweaks/0_setup.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash -source /root/envsetup/conf.sh - -# optimisations nginx -if ( test -f /etc/nginx/nginx.conf ) -then -CPU=$(cat /proc/cpuinfo | grep processor | wc -l) -sed -i "s@worker_processes .*@worker_processes ${CPU};@" /etc/nginx/nginx.conf -service nginx restart -fi diff --git a/41.Install_MS/0_setup.sh b/5.MediaServer/1.Install_MediaServer/0_setup.sh similarity index 71% rename from 41.Install_MS/0_setup.sh rename to 5.MediaServer/1.Install_MediaServer/0_setup.sh index 7e1c03c253e11415ba899fc1a45f97aa3850fc23..c87fb5da09098167c5f083738e132ac8acde13d8 100755 --- a/41.Install_MS/0_setup.sh +++ b/5.MediaServer/1.Install_MediaServer/0_setup.sh @@ -7,5 +7,5 @@ DEBIAN_FRONTEND=noninteractive apt-get install -y python3-mediaserver # session ms msinstaller.py msuser -# mv MS_deploy.sh to /var/tmp -mv MS_deploy.sh /var/tmp/MS_deploy.sh +# copy MS_deploy.sh to /var/tmp +cp MS_deploy.sh /var/tmp/MS_deploy.sh diff --git a/41.Install_MS/MS_deploy.sh b/5.MediaServer/1.Install_MediaServer/MS_deploy.sh similarity index 100% rename from 41.Install_MS/MS_deploy.sh rename to 5.MediaServer/1.Install_MediaServer/MS_deploy.sh diff --git a/8.Startup check script for NFS/0_setup.py b/5.MediaServer/2.Startup check script for NFS/0_setup.py similarity index 96% rename from 8.Startup check script for NFS/0_setup.py rename to 5.MediaServer/2.Startup check script for NFS/0_setup.py index a7184be31ee16322e7177257b0c5d604133afb70..d2726f17350856af489fbeaa5a5bd818d0b0f620 100644 --- a/8.Startup check script for NFS/0_setup.py +++ b/5.MediaServer/2.Startup check script for NFS/0_setup.py @@ -1,4 +1,4 @@ -#!/usr/bin/python3 +#!/usr/bin/env python3 # -*- coding: utf-8 -*- import utils diff --git a/8.Startup check script for NFS/check_services.py b/5.MediaServer/2.Startup check script for NFS/check_services.py similarity index 97% rename from 8.Startup check script for NFS/check_services.py rename to 5.MediaServer/2.Startup check script for NFS/check_services.py index 5a869f7fbc0f72e5de05706ac8f9713c14cf7bbb..5840fdcf38b1c34a0f1aa872355c070baf0cf62f 100755 --- a/8.Startup check script for NFS/check_services.py +++ b/5.MediaServer/2.Startup check script for NFS/check_services.py @@ -5,11 +5,11 @@ This script checks services that require /home are started. If /home is not mounted, a mail is sent and in the other case, it checks that all services that depend on /home are started. ''' -import os -import sys +import datetime import imp +import os import socket -import datetime +import sys if __name__ == '__main__': @@ -37,7 +37,6 @@ if __name__ == '__main__': fail_silently=True ) else: - os.system('service apache2 start') os.system('mscontroller.py start') os.system('msmonitor-website.sh start') os.system('/etc/init.d/campus-manager start') diff --git a/50.--- CampusManager ---/placeholder b/50.--- CampusManager ---/placeholder deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/51.Install_CM/0_setup.sh b/6.CampusManager/1.Install_CampusManager/0_setup.sh similarity index 100% rename from 51.Install_CM/0_setup.sh rename to 6.CampusManager/1.Install_CampusManager/0_setup.sh diff --git a/60.--- Worker ---/placeholder b/60.--- Worker ---/placeholder deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/61.Celerity server/0_setup.py b/7.Worker/1.Celerity_server/0_setup.py similarity index 96% rename from 61.Celerity server/0_setup.py rename to 7.Worker/1.Celerity_server/0_setup.py index 00291be24b3e1da2aa1a935c530daa0bdf6f812a..719b72ed2d6f1e095d7c63e6696251908a4533d3 100644 --- a/61.Celerity server/0_setup.py +++ b/7.Worker/1.Celerity_server/0_setup.py @@ -1,4 +1,4 @@ -#!/usr/bin/python3 +#!/usr/bin/env python3 # -*- coding: utf-8 -*- import utils diff --git a/61.Celerity server/celerity-config.py b/7.Worker/1.Celerity_server/celerity-config.py similarity index 100% rename from 61.Celerity server/celerity-config.py rename to 7.Worker/1.Celerity_server/celerity-config.py diff --git a/62.Celerity workers/0_setup.py b/7.Worker/2.Celerity_workers/0_setup.py similarity index 96% rename from 62.Celerity workers/0_setup.py rename to 7.Worker/2.Celerity_workers/0_setup.py index b15abbaf2068b90c6e6f1afa04a708432418b6cc..1b2abcaf522a66f2efe8099af9c718769bc4d49e 100644 --- a/62.Celerity workers/0_setup.py +++ b/7.Worker/2.Celerity_workers/0_setup.py @@ -1,4 +1,4 @@ -#!/usr/bin/python3 +#!/usr/bin/env python3 # -*- coding: utf-8 -*- import utils diff --git a/62.Celerity workers/celerity-config.py b/7.Worker/2.Celerity_workers/celerity-config.py similarity index 100% rename from 62.Celerity workers/celerity-config.py rename to 7.Worker/2.Celerity_workers/celerity-config.py diff --git a/70.--- Cache ---/placeholder b/70.--- Cache ---/placeholder deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/71.Install_a_cache/0_setup.sh b/8.Cache/1.Install_cache/0_setup.sh similarity index 100% rename from 71.Install_a_cache/0_setup.sh rename to 8.Cache/1.Install_cache/0_setup.sh diff --git a/71.Install_a_cache/default b/8.Cache/1.Install_cache/default similarity index 100% rename from 71.Install_a_cache/default rename to 8.Cache/1.Install_cache/default diff --git a/71.Install_a_cache/index.html b/8.Cache/1.Install_cache/index.html similarity index 100% rename from 71.Install_a_cache/index.html rename to 8.Cache/1.Install_cache/index.html diff --git a/72.Deploy_munin_configuration/0_setup.sh b/8.Cache/2.Deploy_munin_configuration/0_setup.sh similarity index 100% rename from 72.Deploy_munin_configuration/0_setup.sh rename to 8.Cache/2.Deploy_munin_configuration/0_setup.sh diff --git a/73.Install_ferm/0_setup.sh b/8.Cache/3.Install_ferm/0_setup.sh similarity index 100% rename from 73.Install_ferm/0_setup.sh rename to 8.Cache/3.Install_ferm/0_setup.sh diff --git a/73.Install_ferm/ferm.conf b/8.Cache/3.Install_ferm/ferm.conf similarity index 100% rename from 73.Install_ferm/ferm.conf rename to 8.Cache/3.Install_ferm/ferm.conf diff --git a/80.--- MediaVault ---/placeholder b/80.--- MediaVault ---/placeholder deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/81.Install_MV/0_setup.sh b/9.MediaVault/1.Install_MediaVault/0_setup.sh similarity index 100% rename from 81.Install_MV/0_setup.sh rename to 9.MediaVault/1.Install_MediaVault/0_setup.sh diff --git a/default-conf.sh b/default-conf.sh index d510a7b91193169217b31e99bc3236c0fbbfa777..73e425f8387c3a08bc9620fb656171a1a7ef79bd 100644 --- a/default-conf.sh +++ b/default-conf.sh @@ -4,9 +4,9 @@ # Put your local configuration in conf.sh # -- Constants -- +CYAN='\033[0;36m' GREEN='\033[0;32m' RED='\033[0;31m' -CYAN='\033[0;36m' NC='\033[0m' # -- System -- @@ -17,8 +17,6 @@ SKYREACH_API_KEY= NTP_SERVER1='ntp.ubuntu.com' NTP_SERVER2= NTP_SERVER3= -# hosts -ETC_HOSTNAME='mediaserver' # SSL certificate SSL_CERTIFICATE='/etc/ssl/certs/ssl-cert-snakeoil.pem' SSL_CERTIFICATE_KEY='/etc/ssl/private/ssl-cert-snakeoil.key' diff --git a/envsetup.py b/envsetup.py index 1676e2ac8b1732428a040043ff8d6497fffdecb1..2bba8053ec53d67833f2c32233283b815dd3921e 100755 --- a/envsetup.py +++ b/envsetup.py @@ -32,32 +32,12 @@ class EnvSetup(): root_dir = utils.get_dir(__file__) if root_dir != '': os.chdir(root_dir) + self.root_dir = root_dir # Add to python path if root_dir not in sys.path: sys.path.append(root_dir) # Get available actions - self.root_dir = root_dir - names = os.listdir(root_dir) - self.actions = list() - for name in names: - path = os.path.join(root_dir, name) - if os.path.isdir(path): - try: - index = int(name.split('.')[0]) - except ValueError: - continue - label = name[len(str(index)) + 1:].strip() - if not label: - log('No label found for dir %s.' % name) - continue - if os.path.isfile(os.path.join(path, self.PY_SETUP_NAME)): - setup_module = imp.load_source('setup_%s' % name, os.path.join(path, self.PY_SETUP_NAME)) - self.actions.append(dict(index=index, label=label, path=path, fct=setup_module.setup)) - elif os.path.isfile(os.path.join(path, self.BASH_SETUP_NAME)): - self.actions.append(dict(index=index, label=label, path=path, fct='bash -e "%s"' % os.path.join(path, self.BASH_SETUP_NAME))) - else: - self.actions.append(dict(index=index, label=label, path=path, fct=None)) - self.actions.sort(key=lambda a: a['index']) + self.actions = self.discover_actions() if not self.actions: log('No action available.') sys.exit(1) @@ -87,6 +67,43 @@ class EnvSetup(): log('\033[96m- Environment setup for MediaServer -\033[0m') log('\033[96m-------------------------------------\033[0m') + def discover_actions(self): + actions = list() + for section_name in os.listdir(self.root_dir): + section_path = os.path.join(self.root_dir, section_name) + if not os.path.isdir(section_path): + continue + try: + section_index = int(section_name.split('.')[0]) + except ValueError: + continue + section_label = section_name[len(str(section_index)) + 1:].strip().replace('_', ' ') + if not section_label: + log('No label found for dir %s.' % section_name) + continue + actions.append(dict(index=int(str(section_index) + '0'), label=section_label, path=section_path, fct=None)) + + for name in os.listdir(section_path): + path = os.path.join(section_path, name) + if not os.path.isdir(path): + continue + try: + index = int(str(section_index) + name.split('.')[0]) + except ValueError: + continue + label = name[len(str(index)) + 1 - len(str(section_index)):].strip().replace('_', ' ') + if not label: + log('No label found for dir %s.' % name) + continue + + if os.path.isfile(os.path.join(path, self.PY_SETUP_NAME)): + setup_module = imp.load_source('setup_%s' % name, os.path.join(path, self.PY_SETUP_NAME)) + actions.append(dict(index=index, label=label, path=path, fct=setup_module.setup)) + elif os.path.isfile(os.path.join(path, self.BASH_SETUP_NAME)): + actions.append(dict(index=index, label=label, path=path, fct='bash -e "%s"' % os.path.join(path, self.BASH_SETUP_NAME))) + actions.sort(key=lambda a: a['index']) + return actions + def menu(self): # Show main menu log('Actions:') diff --git a/launcher.sh b/launcher.sh index 9aab84f5f7e49f922efdd5e1b4c88cd24db6ce54..f25832690930e3d124b8058ae3dac6f513673abc 100755 --- a/launcher.sh +++ b/launcher.sh @@ -18,140 +18,87 @@ exec > >(tee -i ${LOGFILE}) ## envsetup integration init() { - python3 /root/envsetup/envsetup.py 1 - python3 /root/envsetup/envsetup.py 2 + python3 /root/envsetup/envsetup.py 11 + python3 /root/envsetup/envsetup.py 12 + python3 /root/envsetup/envsetup.py 13 + + python3 /root/envsetup/envsetup.py 31 + python3 /root/envsetup/envsetup.py 32 + python3 /root/envsetup/envsetup.py 33 + python3 /root/envsetup/envsetup.py 34 + + python3 /root/envsetup/envsetup.py 21 python3 /root/envsetup/envsetup.py 22 - python3 /root/envsetup/envsetup.py 23 - python3 /root/envsetup/envsetup.py 24 - python3 /root/envsetup/envsetup.py 4 } monitor() { - python3 /root/envsetup/envsetup.py 3 - python3 /root/envsetup/envsetup.py 6 - python3 /root/envsetup/envsetup.py 7 - python3 /root/envsetup/envsetup.py 31 + python3 /root/envsetup/envsetup.py 23 + python3 /root/envsetup/envsetup.py 25 + python3 /root/envsetup/envsetup.py 26 + python3 /root/envsetup/envsetup.py 41 } mediaserver() { - python3 /root/envsetup/envsetup.py 3 - python3 /root/envsetup/envsetup.py 5 - python3 /root/envsetup/envsetup.py 8 - python3 /root/envsetup/envsetup.py 61 - python3 /root/envsetup/envsetup.py 6 - python3 /root/envsetup/envsetup.py 41 - python3 /root/envsetup/envsetup.py 42 - python3 /root/envsetup/envsetup.py 6 + python3 /root/envsetup/envsetup.py 23 + python3 /root/envsetup/envsetup.py 24 + python3 /root/envsetup/envsetup.py 71 + python3 /root/envsetup/envsetup.py 25 + python3 /root/envsetup/envsetup.py 51 + python3 /root/envsetup/envsetup.py 52 + python3 /root/envsetup/envsetup.py 25 } worker() { - python3 /root/envsetup/envsetup.py 62 + python3 /root/envsetup/envsetup.py 72 } campusmanager() { - python3 /root/envsetup/envsetup.py 3 - python3 /root/envsetup/envsetup.py 6 - python3 /root/envsetup/envsetup.py 51 - python3 /root/envsetup/envsetup.py 6 + python3 /root/envsetup/envsetup.py 23 + python3 /root/envsetup/envsetup.py 25 + python3 /root/envsetup/envsetup.py 61 + python3 /root/envsetup/envsetup.py 25 } cache() { - python3 /root/envsetup/envsetup.py 71 - python3 /root/envsetup/envsetup.py 72 - python3 /root/envsetup/envsetup.py 73 - python3 /root/envsetup/envsetup.py 42 + python3 /root/envsetup/envsetup.py 81 + python3 /root/envsetup/envsetup.py 82 + python3 /root/envsetup/envsetup.py 83 } tests() { - python3 /root/envsetup/envsetup.py t + python3 /root/envsetup/tester.py } backup_server() { - python3 /root/envsetup/envsetup.py 81 -} - -reconf_default() { - python3 /root/envsetup/envsetup.py 104 + python3 /root/envsetup/envsetup.py 91 } reconf_client() { - python3 /root/envsetup/envsetup.py 101 + python3 /root/envsetup/envsetup.py 201 } -reconf_recette() { - python3 /root/envsetup/envsetup.py 102 +reconf_dump_config() { + python3 /root/envsetup/envsetup.py 202 } reconf_smtp() { - python3 /root/envsetup/envsetup.py 103 + python3 /root/envsetup/envsetup.py 203 +} + +reconf_default() { + python3 /root/envsetup/envsetup.py 204 } WOWZA_LICENSE() { - python3 /root/envsetup/envsetup.py 105 + python3 /root/envsetup/envsetup.py 205 } exportvm() { - KEY=~/.ssh/ubicast_support - 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_NAME ); then - VM_NAME=$(cat ${CONF} | egrep ^ETC_HOSTNAME | head -1 | awk -F "=" '{print$2}') - else - VM_NAME=$(grep VM ${CONF} | awk -F "=" '{print$2}') - fi - - 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 ${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>' ${VM_STORE_LOCAL}/${VM_NAME}_vmware.ovf | awk -F ":" '{print$1}') - LIG0=$(( $LIG - 1 )) - LIG1=$(( $LIG0 + 9 )) - sed -i "${LIG0},${LIG1}d" ${VM_STORE_LOCAL}/${VM_NAME}_vmware.ovf - - # converting disk to qemu image - 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 ${VM_STORE_LOCAL}${NC}" + python3 /root/envsetup/envsetup.py 101 } exportvm_local(){ -VM_STORE=/home/jallary/ubicast/TMP/ENVOI -VM_STORE_LOCAL=/home/jallary/ubicast/TMP/ENVOI -# depuis poste local -VBoxManage export ${VM_NAME} -o ${VM_STORE}/${VM_NAME}.ovf --ovf10 - -# generating vmware conf file -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>' ${VM_STORE_LOCAL}/${VM_NAME}_vmware.ovf | awk -F ":" '{print$1}') -LIG0=$(( $LIG - 1 )) -LIG1=$(( $LIG0 + 9 )) -sed -i "${LIG0},${LIG1}d" ${VM_STORE_LOCAL}/${VM_NAME}_vmware.ovf - -# converting disk to qemu image -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 ${VM_STORE_LOCAL}${NC}" + python3 /root/envsetup/envsetup.py 102 } case "$1" in @@ -192,17 +139,17 @@ case "$1" in "client") reconf_client - reconf_recette + reconf_dump_config reconf_smtp ;; "recette") - reconf_recette + reconf_dump_config ;; "wrecette") WOWZA_LICENSE - reconf_recette + reconf_dump_config ;; "exportvm") diff --git a/utils.py b/utils.py index 1e71079a51efa39938cc7c7fc5f3b9c2766e85ca..1f786c4498f2cc46a26bda4e75c972056b85c144 100644 --- a/utils.py +++ b/utils.py @@ -1,4 +1,4 @@ -#!/usr/bin/python3 +#!/usr/bin/env python3 # -*- coding: utf-8 -*- from collections import OrderedDict import os