@@ -98,13 +98,6 @@ def preBuild():
9898 global currentServiceName
9999 with open ("{serviceDir}{buildSettings}" .format (serviceDir = serviceService , buildSettings = buildSettingsFileName )) as objHardwareListFile :
100100 deconzYamlBuildOptions = yaml .load (objHardwareListFile )
101- try :
102- if "deconz" in dockerComposeServicesYaml :
103- dockerComposeServicesYaml ["deconz" ]["devices" ] = deconzYamlBuildOptions ["hardware" ]
104- except Exception as err :
105- print ("Error setting deconz hardware: " , err )
106- return False
107-
108101 # Password randomisation
109102 # Multi-service:
110103 with open ((r'%s/' % serviceTemplate ) + servicesFileName ) as objServiceFile :
@@ -126,47 +119,45 @@ def preBuild():
126119
127120 if os .path .exists (buildSettings ):
128121 # Password randomisation
129- with open (r'%s' % buildSettings ) as objBuildSettingsFile :
130- deconzYamlBuildOptions = yaml .load (objBuildSettingsFile )
131- if "databasePasswordOption" in deconzYamlBuildOptions :
132- if (
133- deconzYamlBuildOptions ["databasePasswordOption" ] == "Randomise database password for this build"
134- or deconzYamlBuildOptions ["databasePasswordOption" ] == "Randomise database password every build"
135- or deconzYamlBuildOptions ["databasePasswordOption" ] == "Use default password for this build"
136- ):
137- if deconzYamlBuildOptions ["databasePasswordOption" ] == "Use default password for this build" :
138- newPassword = "IOtSt4ckDec0nZ"
139- else :
140- newPassword = generateRandomString ()
141- for (index , serviceName ) in enumerate (serviceYamlTemplate ):
142- dockerComposeServicesYaml [serviceName ] = serviceYamlTemplate [serviceName ]
143- if "environment" in serviceYamlTemplate [serviceName ]:
144- for (envIndex , envName ) in enumerate (serviceYamlTemplate [serviceName ]["environment" ]):
145- envName = envName .replace ("%randomPassword%" , newPassword )
146- dockerComposeServicesYaml [serviceName ]["environment" ][envIndex ] = envName
147-
148- # Ensure you update the "Do nothing" and other 2 strings used for password settings in 'passwords.py'
149- if (deconzYamlBuildOptions ["databasePasswordOption" ] == "Randomise database password for this build" ):
150- deconzYamlBuildOptions ["databasePasswordOption" ] = "Do nothing"
151- with open (buildSettings , 'w' ) as outputFile :
152- yaml .dump (deconzYamlBuildOptions , outputFile )
153- else : # Do nothing - don't change password
154- for (index , serviceName ) in enumerate (buildCacheServices ):
155- if serviceName in buildCacheServices : # Load service from cache if exists (to maintain password)
156- dockerComposeServicesYaml [serviceName ] = buildCacheServices [serviceName ]
157- else :
158- dockerComposeServicesYaml [serviceName ] = serviceYamlTemplate [serviceName ]
159- else :
160- print ("Deconz Warning: Build settings file not found, using default password" )
161- time .sleep (1 )
162- newPassword = "IOtSt4ckDec0nZ"
122+ if "databasePasswordOption" in deconzYamlBuildOptions :
123+ if (
124+ deconzYamlBuildOptions ["databasePasswordOption" ] == "Randomise database password for this build"
125+ or deconzYamlBuildOptions ["databasePasswordOption" ] == "Randomise database password every build"
126+ or deconzYamlBuildOptions ["databasePasswordOption" ] == "Use default password for this build"
127+ ):
128+ if deconzYamlBuildOptions ["databasePasswordOption" ] == "Use default password for this build" :
129+ newPassword = "IOtSt4ckDec0nZ"
130+ else :
131+ newPassword = generateRandomString ()
163132 for (index , serviceName ) in enumerate (serviceYamlTemplate ):
164133 dockerComposeServicesYaml [serviceName ] = serviceYamlTemplate [serviceName ]
165134 if "environment" in serviceYamlTemplate [serviceName ]:
166135 for (envIndex , envName ) in enumerate (serviceYamlTemplate [serviceName ]["environment" ]):
167136 envName = envName .replace ("%randomPassword%" , newPassword )
168137 dockerComposeServicesYaml [serviceName ]["environment" ][envIndex ] = envName
169138
139+ # Ensure you update the "Do nothing" and other 2 strings used for password settings in 'passwords.py'
140+ if (deconzYamlBuildOptions ["databasePasswordOption" ] == "Randomise database password for this build" ):
141+ deconzYamlBuildOptions ["databasePasswordOption" ] = "Do nothing"
142+ with open (buildSettings , 'w' ) as outputFile :
143+ yaml .dump (deconzYamlBuildOptions , outputFile )
144+ else : # Do nothing - don't change password
145+ for (index , serviceName ) in enumerate (buildCacheServices ):
146+ if serviceName in buildCacheServices : # Load service from cache if exists (to maintain password)
147+ dockerComposeServicesYaml [serviceName ] = buildCacheServices [serviceName ]
148+ else :
149+ dockerComposeServicesYaml [serviceName ] = serviceYamlTemplate [serviceName ]
150+ else :
151+ print ("Deconz Warning: Build settings file not found, using default password" )
152+ time .sleep (1 )
153+ newPassword = "IOtSt4ckDec0nZ"
154+ for (index , serviceName ) in enumerate (serviceYamlTemplate ):
155+ dockerComposeServicesYaml [serviceName ] = serviceYamlTemplate [serviceName ]
156+ if "environment" in serviceYamlTemplate [serviceName ]:
157+ for (envIndex , envName ) in enumerate (serviceYamlTemplate [serviceName ]["environment" ]):
158+ envName = envName .replace ("%randomPassword%" , newPassword )
159+ dockerComposeServicesYaml [serviceName ]["environment" ][envIndex ] = envName
160+
170161 deconzYamlBuildOptions ["databasePasswordOption" ] = "Do nothing"
171162 with open (buildSettings , 'w' ) as outputFile :
172163 yaml .dump (deconzYamlBuildOptions , outputFile )
@@ -187,11 +178,18 @@ def preBuild():
187178 "service" : "Deconz" ,
188179 "comment" : "Deconz Build Options"
189180 }
190-
181+
191182 deconzYamlBuildOptions ["databasePasswordOption" ] = "Do nothing"
192183 with open (buildSettings , 'w' ) as outputFile :
193184 yaml .dump (deconzYamlBuildOptions , outputFile )
194185
186+ try :
187+ if currentServiceName in dockerComposeServicesYaml :
188+ dockerComposeServicesYaml [currentServiceName ]["devices" ] = deconzYamlBuildOptions ["hardware" ]
189+ except Exception as err :
190+ print ("Error setting deconz hardware: " , err )
191+ return False
192+
195193 return True
196194
197195 # #####################################
0 commit comments