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

fix problem with ' symbol

This commit is contained in:
WizaXxX 2020-07-23 20:57:47 +03:00
parent ff93e21117
commit 183317773d
5 changed files with 43 additions and 22 deletions

3
.gitignore vendored
View File

@ -6,4 +6,5 @@ workdir
workdir/
test.py
.vscode/launch.json
.hostname
.hostname
conf/core/nethasp.ini

View File

@ -7,8 +7,8 @@ services:
hostname: db.HOSTNAMEREPLACE
container_name: db.HOSTNAMEREPLACE
volumes:
- ./artifacts/db/data:/var/lib/1c/pgdata
- ./postgres_socket:/tmp/postgresql/socket
- 1c_pg_data:/var/lib/1c/pgdata
- 1c_pg_socket:/tmp/postgresql/socket
- ./mnt:/mnt
- ../images/site/create_db.psql:/create_db_site.psql
- ../images/forum/create_db.psql:/create_db_forum.psql
@ -56,7 +56,7 @@ services:
container_name: srv.HOSTNAMEREPLACE
command: srv+cli
volumes:
- ./postgres_socket:/tmp/postgresql/socket
- 1c_pg_socket:/tmp/postgresql/socket
- ./artifacts/srv/data:/var/lib/1c/data
- ./artifacts/srv/log:/var/log/1c
- ./mnt:/mnt
@ -135,4 +135,8 @@ services:
volumes:
- ./mnt:/mnt
depends_on:
- srv
- srv
volumes:
1c_pg_data:
1c_pg_socket:

View File

@ -1,5 +1,6 @@
import subprocess
import sys
import platform
from datetime import datetime
import modules.site as site
@ -14,9 +15,15 @@ class colors:
WHITE = '\033[97m'
RED = '\033[91m'
def get_docker_image_command():
if platform.system().lower() == 'windows':
return ['docker', 'images']
else:
return ['docker images']
def image_exist(image_name):
full_image_name = 'fresh/' + image.name
result = subprocess.run(['docker' ,'images'], shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
result = subprocess.run(get_docker_image_command(), shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
return full_image_name in str(result.stdout)

View File

@ -44,13 +44,13 @@ def web_publish_command(host_name, conf_name, internal, descriptor, base_name=''
command.append('-connstr')
if base_name != '':
command.append('\'Srvr=srv;Ref={};\''.format(base_name))
command.append('"Srvr=srv;Ref={};"'.format(base_name))
else:
command.append('\'Srvr=srv;Ref={};\''.format(conf_name))
command.append('"Srvr=srv;Ref={};"'.format(conf_name))
command.append('-confpath')
command.append('\'/etc/httpd/conf/httpd.conf\'')
command.append('"/etc/httpd/conf/httpd.conf"')
command.append('-descriptor')
command.append('\'/mnt/other-files/vrd/{}.vrd\''.format(descriptor))
command.append('"/mnt/other-files/vrd/{}.vrd"'.format(descriptor))
return command
def get_out_file_name_command(action, ib_name):
@ -64,7 +64,7 @@ def create_ib_command(host_name, ib_name, file_name, job_block, action):
command.append('srv.' + host_name)
command.append('/opt/1C/v8.3/x86_64/1cv8')
command.append('CREATEINFOBASE')
command.append('\'Srvr="srv";Ref="{0}";DBMS=PostgreSQL;DBSrvr="/tmp/postgresql/socket";DB="{0}";DBUID="postgres";LicDstr="Y";Locale="ru_RU";CrSQLDB="Y";SchJobDn="{1}";\''.format(
command.append('"Srvr=srv;Ref={0};DBMS=PostgreSQL;DBSrvr=/tmp/postgresql/socket;DB={0};DBUID=postgres;LicDstr=Y;Locale=ru_RU;CrSQLDB=Y;SchJobDn={1};"'.format(
ib_name, job_block))
command.append('/UseTemplate')
command.append('/mnt/{}'.format(file_name))

View File

@ -5,6 +5,7 @@ import sys
import json
import threading
import time
import codecs
from datetime import datetime
host_name = '.1cfresh.dev'
@ -133,7 +134,7 @@ def call(command, remote=True, debug=False, action='', measure_duration=False, s
def get_configurations_data():
"""Get configuration data"""
is_fail = False
with open('other_files/params.json') as json_file:
with codecs.open('other_files/params.json', 'r', 'utf-8') as json_file:
data = json.load(json_file)
for ib_data in data['ИнформационныеБазы']:
if not os.path.isfile('distr/{}'.format(ib_data['ИмяФайлаКонфигурации'])):
@ -204,6 +205,13 @@ def prepare_new_ib(ib_name, int_name, conf_file_name, job_block):
action='Initialization',
measure_duration=True)
@print_description
def delete_volumes():
"""Delete volumes"""
call('docker volume rm workdir_1c_pg_data', remote=False)
call('docker volume rm workdir_1c_pg_socket', remote=False)
@print_description
def prepare_bases():
"""Prepare all bases"""
@ -235,15 +243,15 @@ def renew_nginx_files():
conf_catalog = work_dir + 'artifacts/nginx/conf/'
call('mkdir -p {}'.format(conf_catalog))
call('sh -c \'cp -r /out_files/conf/nginx/* {}'.format(conf_catalog) + '\'')
call('sh -c "cp -r /out_files/conf/nginx/* {}"'.format(conf_catalog))
call('sh -c \'sed -i \'s/hosthosthost/{}/g\' {}*.conf\''.format(host_name, conf_catalog))
call('sh -c \'sed -i \'s/sitesitesite/site.{}/g\' {}*.conf\''.format(host_name, conf_catalog))
call('sh -c \'sed -i \'s/webwebweb/web.{}/g\' {}*.conf\''.format(host_name, conf_catalog))
call('sh -c \'sed -i \'s/gategategate/gate.{}/g\' {}*.conf\''.format(host_name, conf_catalog))
call('sh -c "sed -i \'s/hosthosthost/{}/g\' {}*.conf"'.format(host_name, conf_catalog))
call('sh -c "sed -i \'s/sitesitesite/site.{}/g\' {}*.conf"'.format(host_name, conf_catalog))
call('sh -c "sed -i \'s/webwebweb/web.{}/g\' {}*.conf"'.format(host_name, conf_catalog))
call('sh -c "sed -i \'s/gategategate/gate.{}/g\' {}*.conf"'.format(host_name, conf_catalog))
call('sh -c \'sed -i \'s/sitesitesite/site.{}/g\' {}conf.d/*.conf\''.format(host_name, conf_catalog))
call('sh -c \'sed -i \'s/hosthosthost/{}/g\' {}conf.d/*.conf\''.format(host_name, conf_catalog))
call('sh -c "sed -i \'s/sitesitesite/site.{}/g\' {}conf.d/*.conf"'.format(host_name, conf_catalog))
call('sh -c "sed -i \'s/hosthosthost/{}/g\' {}conf.d/*.conf"'.format(host_name, conf_catalog))
@print_description
@ -332,7 +340,7 @@ def set_full_host_name(is_new):
def create_db_site():
"""Create db for site"""
call('docker exec -t db.{} sh -c \'/usr/bin/psql -U postgres -f {}'.format(host_name, '/create_db_site.psql\''),
call('docker exec -t db.{} sh -c "/usr/bin/psql -U postgres -f {}'.format(host_name, '/create_db_site.psql"'),
remote=False)
@ -340,7 +348,7 @@ def create_db_site():
def create_db_forum():
"""Create db for forum"""
call('docker exec -t db.{} sh -c \'/usr/bin/psql -U postgres -f {}'.format(host_name, '/create_db_forum.psql\''),
call('docker exec -t db.{} sh -c "/usr/bin/psql -U postgres -f {}'.format(host_name, '/create_db_forum.psql"'),
remote=False)
@ -403,7 +411,7 @@ def wait_site():
def enable_job_in_sm():
"""Enable scheduled jobs sm"""
call('docker exec -t ras.{} deployka scheduledjobs unlock -db sm -db-user \'Администратор\''.format(host_name),
call('docker exec -t ras.{} deployka scheduledjobs unlock -db sm -db-user "Администратор"'.format(host_name),
remote=False)
@print_description
@ -428,6 +436,7 @@ if new_server:
renew_nginx_files()
renew_docker_compose()
renew_other_files()
delete_volumes()
# start db srv ras web gate conteiners
call(docker_compose_str + 'up -d db srv ras web gate', remote=False, silent=False)