1
0
mirror of https://github.com/1C-Company/docker_fresh.git synced 2024-12-04 10:24:48 +02:00

add smtl base creation

This commit is contained in:
WizaXxX 2020-04-06 00:09:47 +03:00
parent 5bf32b49d5
commit 6f8baa837a
2 changed files with 92 additions and 8 deletions

View File

@ -22,4 +22,50 @@ def new_docker_command(extra_path=None):
current_distr_path = distr_path
command.append(current_distr_path + ':/out_files')
return command
def web_publish_command(host_name, conf_name, internal, descriptor, base_name=''):
if internal:
prefix = 'a'
else:
prefix = 'int'
command = []
command.append('docker')
command.append('exec')
command.append('web.' + host_name)
command.append('/opt/1C/v8.3/x86_64/webinst')
command.append('-apache24')
command.append('-wsdir')
command.append(prefix + '/' + conf_name)
command.append('-dir')
command.append('/var/www/' + conf_name)
command.append('-connstr')
if base_name != '':
command.append('\'Srvr=srv;Ref=' + base_name + ';\'')
else:
command.append('\'Srvr=srv;Ref=' + conf_name + ';\'')
command.append('-confpath')
command.append('\'/etc/httpd/conf/httpd.conf\'')
command.append('-descriptor')
command.append('\'/mnt/other-files/vrd/' + descriptor + '.vrd\'')
return command
def create_ib_command(host_name, ib_name, conf_ver=''):
command = []
command.append('docker')
command.append('exec')
command.append('-t')
command.append('srv.' + host_name)
command.append('/opt/1C/v8.3/x86_64/1cv8')
command.append('CREATEINFOBASE')
command.append('\'Srvr="srv";Ref="' + ib_name + '";DBMS=PostgreSQL;DBSrvr="db";DB="' + ib_name + '";DBUID="postgres";LicDstr="Y";Locale="ru_RU";CrSQLDB="Y";SchJobDn="N";\'')
command.append('/UseTemplate')
command.append('/mnt/' + ib_name + '_' + conf_ver.replace('.', '_') + '.cf')
command.append('/Out "/mnt/create_ib_' + ib_name + '.out"')
command.append('/DumpResult "/mnt/create_ib_' + ib_name + '.result"')
return command

View File

@ -1,8 +1,11 @@
import subprocess
import os
import modules.helper as helper
import sys
from datetime import datetime
host_name = 'test.1cfresh.dev'
sup_password = '123Qwer'
configurations = {}
@ -30,20 +33,33 @@ def get_configurations_data():
conf_key = file.split('.')[0].split('_')[0]
configurations[conf_key] = '.'.join(file.split('.')[0].split('_')).replace(conf_key + '.', '')
new_server = False
def prepare_new_ib(key):
print('creating', key)
start_time = datetime.now()
call(' '.join(helper.create_ib_command(host_name, key, configurations[key])), remote=False)
print(key, 'creation', 'is fihish')
print('duration:', datetime.now() - start_time)
new_server = os.path.isfile('workdir') != True
print('install control extension')
#TODO
# if new_server:
# call('mkdir ' + work_dir)
# call('mkdir ' + work_dir + 'mnt')
# call('sh -c "cp /out_files/distr/*.cf ' + work_dir + 'mnt/"')
# get_configurations_data()
new_server = True
if len(sys.argv) > 1:
new_server = sys.argv[1] == 'new'
call(docker_compose_str + 'down', False)
if new_server:
call('rm -rf /out_files/workdir')
call('mkdir -p ' + work_dir + 'mnt')
call('sh -c "cp /out_files/distr/*.cf ' + work_dir + 'mnt/"')
get_configurations_data()
# renew docker-compose.yml
call('cp /out_files/docker-compose.yml /out_files/workdir/docker-compose.yml')
call('sh -c "sed -i \'s/HOSTNAMEREPLACE/' + host_name + '/\' ' + work_dir + '/*.yml"')
call(docker_compose_str + 'down', False)
# renew all nginx conf files
call('rm -rf ' + work_dir + 'nginx_conf/')
@ -58,5 +74,27 @@ call('sh -c "sed -i \'s/HOSTNAMEREPLACE/' + host_name + '/\' ' + work_dir_other
# start db srv ras web gate
call(docker_compose_str + 'up -d db srv ras web gate', remote=False)
# publish a services
call(' '.join(helper.web_publish_command(host_name, 'adm', False, 'zoneless', 'sm')), remote=False)
call(' '.join(helper.web_publish_command(host_name, 'smtl', False, 'withzone')), remote=False)
call(' '.join(helper.web_publish_command(host_name, 'sa', False, 'zoneless')), remote=False)
call(' '.join(helper.web_publish_command(host_name, 'openid', False, 'openid', 'sm')), remote=False)
# publish int services
call(' '.join(helper.web_publish_command(host_name, 'sm', True, 'zoneless')), remote=False)
call(' '.join(helper.web_publish_command(host_name, 'smtl', True, 'zoneless')), remote=False)
call(' '.join(helper.web_publish_command(host_name, 'sa', True, 'zoneless')), remote=False)
call(' '.join(helper.web_publish_command(host_name, 'am', True, 'zoneless')), remote=False)
call(' '.join(helper.web_publish_command(host_name, 'sc', True, 'sessioncontrol', 'sm;Usr=SessionControl;Pwd=' + sup_password)), remote=False)
call(' '.join(helper.web_publish_command(host_name, 'extreg', True, 'extreg', 'sm;Usr=ExtReg;Pwd=' + sup_password)), remote=False)
# restart Apache
call('docker exec web.' + host_name + ' chown -R usr1cv8:grp1cv8 /var/www', remote=False)
call('docker exec web.' + host_name + ' httpd -k graceful', remote=False)
if new_server:
prepare_new_ib('smtl')