@@ -8,6 +8,7 @@ import * as ini from 'ini';
88
99import { emcmd } from '@app/core/utils/clients/emcmd.js' ;
1010import { fileExists } from '@app/core/utils/files/file-exists.js' ;
11+ import { reloadNginxAndUpdateDNS } from '@app/store/actions/reload-nginx-and-update-dns.js' ;
1112import { getters } from '@app/store/index.js' ;
1213import { ActivationCode } from '@app/unraid-api/graph/resolvers/customization/activation-code.model.js' ;
1314
@@ -24,10 +25,6 @@ export class CustomizationService implements OnModuleInit {
2425 private activationData : ActivationCode | null = null ;
2526
2627 async createOrGetFirstBootSetupFlag ( ) : Promise < boolean > {
27- // Ensure directory exists first
28- // Note: this.activationDir might not be initialized yet if called before onModuleInit
29- // It relies on being called within or after onModuleInit workflow.
30- // If called independently, it needs the path value passed or initialized differently.
3128 await fs . mkdir ( this . activationDir , { recursive : true } ) ;
3229 if ( await fileExists ( this . hasRunFirstBootSetup ) ) {
3330 this . logger . log ( 'First boot setup flag file already exists.' ) ;
@@ -153,7 +150,7 @@ export class CustomizationService implements OnModuleInit {
153150
154151 public convertWebGuiPathToAssetPath ( webGuiPath : string ) : string {
155152 // Strip the leading /usr/local/emhttp/ from the path
156- const assetPath = webGuiPath . replace ( '/usr/local/emhttp/' , '' ) ;
153+ const assetPath = webGuiPath . replace ( '/usr/local/emhttp/' , '/ ' ) ;
157154 return assetPath ;
158155 }
159156
@@ -365,7 +362,7 @@ export class CustomizationService implements OnModuleInit {
365362 }
366363
367364 private async applyServerIdentity ( ) {
368- const { getters } = await import ( '@app/store/index.js' ) ;
365+ const { getters, store } = await import ( '@app/store/index.js' ) ;
369366 if ( ! this . activationData ) {
370367 this . logger . warn ( 'No activation data available for server identity setup.' ) ;
371368 return ;
@@ -402,14 +399,18 @@ export class CustomizationService implements OnModuleInit {
402399
403400 try {
404401 // Update ident.cfg first
405- await this . updateCfgFile ( this . identCfg , null , paramsToUpdate ) ; // Update keys directly in the file
402+ await this . updateCfgFile ( this . identCfg , null , paramsToUpdate ) ;
406403 this . logger . log ( `Server identity updated in ${ this . identCfg } ` ) ;
407404
408405 // Trigger emhttp update via emcmd
409- const updateParams = { ...paramsToUpdate , changeNames : 'Apply' } ; // Prepare params for emcmd
410- this . logger . log ( `Calling emcmd with params:` , updateParams ) ; // Log the params
411- await emcmd ( updateParams ) ; // Use emcmd utility
406+ const updateParams = { ...paramsToUpdate , changeNames : 'Apply' } ;
407+ this . logger . log ( `Calling emcmd with params:` , updateParams ) ;
408+ await emcmd ( updateParams ) ;
412409 this . logger . log ( 'emcmd executed successfully.' ) ;
410+
411+ // Reload nginx and update DNS
412+ await store . dispatch ( reloadNginxAndUpdateDNS ( ) ) ;
413+ this . logger . log ( 'Nginx reloaded and DNS updated successfully.' ) ;
413414 } catch ( error ) {
414415 this . logger . error ( 'Error applying server identity:' , error ) ;
415416 }
0 commit comments