Commit 0a84752c authored by Jean-Baptiste Petre's avatar Jean-Baptiste Petre

add def function

parent 894b5ebc
......@@ -29,86 +29,87 @@
import ConfigParser, os
from os import chdir
config = ConfigParser.RawConfigParser()
# search slapos.cfg
slapos_path_configuration_old = "/etc/slapos/slapos.cfg"
slapos_path_configuration = "/etc/opt/slapos/slapos.cfg"
def slapos_cfg_update():
config = ConfigParser.RawConfigParser()
# check path slapos.cfg
if os.path.isfile(slapos_path_configuration_old) == True:
# search slapos.cfg
slapos_path_configuration_old = "/etc/slapos/slapos.cfg"
slapos_path_configuration = "/etc/opt/slapos/slapos.cfg"
# check path slapos.cfg
if os.path.isfile(slapos_path_configuration_old) == True:
path_slapos = "/etc/slapos/"
if os.path.isfile(slapos_path_configuration) == True:
if os.path.isfile(slapos_path_configuration) == True:
path_slapos = "/etc/opt/slapos/"
# deplacement the real folder
chdir(path_slapos)
# deplacement the real folder
chdir(path_slapos)
# read slapos.cfg
config.read('slapos.cfg')
# read slapos.cfg
config.read('slapos.cfg')
# SECTION slapformat
# SECTION slapformat
# convert bridge_name -> interface_name
# convert bridge_name -> interface_name
if config.has_option('slapformat', 'bridge_name') == True:
if config.has_option('slapformat', 'bridge_name') == True:
bridge_name_interface = config.get('slapformat', 'bridge_name')
config.remove_option('slapformat', 'bridge_name')
config.set('slapformat','interface_name', bridge_name_interface)
# add log_file = /opt/slapos/slapformat.log
if config.has_option('slapformat', 'log_file') == False:
# add log_file = /opt/slapos/slapformat.log
if config.has_option('slapformat', 'log_file') == False:
config.set('slapformat', 'log_file', '/opt/slapos/slapformat.log')
ipv6_interface = config.has_option('slapformat', 'ipv6_interface')
if ipv6_interface == False:
ipv6_interface = config.has_option('slapformat', 'ipv6_interface')
if ipv6_interface == False:
config.set('slapformat', 'ipv6_interface', 'tapVPN')
# SECTION networkcache
# SECTION networkcache
# checking the section true or false
check_section_networkcache = config.has_section('networkcache')
# checking the section true or false
check_section_networkcache = config.has_section('networkcache')
# add from section networkcache if there is not
if check_section_networkcache == False:
# add from section networkcache if there is not
if check_section_networkcache == False:
config.add_section('networkcache')
# check the part network
# check the part network
check_section_networkcache_download_binary_cache_url = config.has_option('networkcache', 'download-binary-cache-url')
check_section_networkcache_download_cache_url = config.has_option('networkcache', 'download-cache-url')
check_section_networkcache_download_binary_dir_url = config.has_option('networkcache', 'download-binary-dir-url')
check_section_networkcache_signature_certificate_list = config.has_option('networkcache', 'signature-certificate-list')
check_section_networkcache_download_from_binary_cache_url_blacklist = config.has_option('networkcache', 'download-from-binary-cache-url-blacklist')
check_section_networkcache_upload_to_binary_cache_url_blacklist = config.has_option('networkcache', 'upload-to-binary-cache-url-blacklist')
check_section_networkcache_download_binary_cache_url = config.has_option('networkcache', 'download-binary-cache-url')
check_section_networkcache_download_cache_url = config.has_option('networkcache', 'download-cache-url')
check_section_networkcache_download_binary_dir_url = config.has_option('networkcache', 'download-binary-dir-url')
check_section_networkcache_signature_certificate_list = config.has_option('networkcache', 'signature-certificate-list')
check_section_networkcache_download_from_binary_cache_url_blacklist = config.has_option('networkcache', 'download-from-binary-cache-url-blacklist')
check_section_networkcache_upload_to_binary_cache_url_blacklist = config.has_option('networkcache', 'upload-to-binary-cache-url-blacklist')
# check 1 - 1 a section networkcache
# check 1 - 1 a section networkcache
if check_section_networkcache_download_binary_cache_url == False:
if check_section_networkcache_download_binary_cache_url == False:
config.set('networkcache', 'download-binary-cache-url', 'http://www.shacache.org/shacache')
if check_section_networkcache_download_cache_url == False:
if check_section_networkcache_download_cache_url == False:
config.set('networkcache', 'download-cache-url', 'https://www.shacache.org/shacache')
if check_section_networkcache_download_binary_dir_url == False:
if check_section_networkcache_download_binary_dir_url == False:
config.set('networkcache', 'download-binary-dir-url', 'http://www.shacache.org/shadir')
if check_section_networkcache_signature_certificate_list == False:
if check_section_networkcache_signature_certificate_list == False:
config.set('networkcache', 'signature-certificate-list', '\n-----BEGIN CERTIFICATE-----\nMIIB4DCCAUkCADANBgkqhkiG9w0BAQsFADA5MQswCQYDVQQGEwJGU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3WP3xCLE4LxLg1eIhd4nwNHj8H18xR9aP0AGjo4UFl5BOMa1\nmwoyBt3VtfGtUmb8whpeJgHhqrPPxLoON+i6fIbXDaUCAwEAAaNQME4wHQYDVR0O\nBBYEFEfjy3OopT2lOksKmKBNHTJE2hFlMB8GA1UdIwQYMBaAFEfjy3OopT2lOksK\nmKBNHTJE2hFlMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQADgYEAaNRx6YN2\nM/p3R8/xS6zvH1EqJ3FFD7XeAQ52WuQnKSREzuw0dsw12ClxjcHiQEFioyTiTtjs\n5pW18Ry5Ie7iFK4cQMerZwWPxBodEbAteYlRsI6kePV7Gf735Y1RpuN8qZ2sYL6e\nx2IMeSwJ82BpdEI5niXxB+iT0HxhmR+XaMI=\n-----END CERTIFICATE-----')
if check_section_networkcache_download_from_binary_cache_url_blacklist == False:
if check_section_networkcache_download_from_binary_cache_url_blacklist == False:
config.set('networkcache', 'download-from-binary-cache-url-blacklist', '\nhttp://git.erp5.org/gitweb/slapos.git/blob_plain/HEAD\nhttp://git.erp5.org/gitweb/slapos.core.git/blob_plain/refs/heads\n/')
if check_section_networkcache_upload_to_binary_cache_url_blacklist == False:
if check_section_networkcache_upload_to_binary_cache_url_blacklist == False:
config.set('networkcache', 'upload-to-binary-cache-url-blacklist', '\nhttp://git.erp5.org/gitweb/slapos.git/blob_plain/HEAD\nhttp://git.erp5.org/gitweb/slapos.core.git/blob_plain/refs/heads\n/')
# writing slapos.cfg
with open('slapos.cfg', 'wb') as configfile:
# writing slapos.cfg
with open('slapos.cfg', 'wb') as configfile:
config.write(configfile)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment