Updated the init process to get the branch from package_info in docker images

This commit is contained in:
morpheus65535 2021-03-30 16:52:23 -04:00
parent e88c94ccd2
commit 0c09bc2360
1 changed files with 24 additions and 2 deletions

View File

@ -92,8 +92,30 @@ with open(os.path.join(args.config_dir, 'config', 'config.ini'), 'w+') as handle
# migrate enabled_providers from comma separated string to list
if isinstance(settings.general.enabled_providers, str) and not settings.general.enabled_providers.startswith('['):
settings.general.enabled_providers = str(settings.general.enabled_providers.split(","))
with open(os.path.join(args.config_dir, 'config', 'config.ini'), 'w+') as handle:
settings.write(handle)
with open(os.path.join(args.config_dir, 'config', 'config.ini'), 'w+') as handle:
settings.write(handle)
# make sure settings.general.branch is properly set when running inside a docker container
package_info_file = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'package_info')
if os.path.isfile(package_info_file):
try:
package_info = {}
with open(package_info_file) as file:
for line in file.readlines():
if line == '\n':
break
splitted_line = line.split('=')
if len(splitted_line) == 2:
package_info[splitted_line[0].lower()] = splitted_line[1].replace('\n', '')
else:
continue
if 'branch' in package_info:
settings.general.branch = package_info['branch']
except:
pass
else:
with open(os.path.join(args.config_dir, 'config', 'config.ini'), 'w+') as handle:
settings.write(handle)
# create database file
if not os.path.exists(os.path.join(args.config_dir, 'db', 'bazarr.db')):