@@ -540,6 +540,9 @@ def setup_multiproxy_instances(user_config: Dict[str, Any], app_config: Dict[str
540540 logging .info (
541541 f"Completely disabled dashboard for multiproxy instance { instance_project_name } to avoid port conflicts" )
542542
543+ # Regenerate UUIDs for apps that require them
544+ regenerate_uuids_for_apps (instance_user_config , instance_app_config )
545+
543546 instance_user_config_path = os .path .join (
544547 instance_dir , 'user-config.json' )
545548 instance_m4b_config_path = os .path .join (
@@ -561,6 +564,33 @@ def setup_multiproxy_instances(user_config: Dict[str, Any], app_config: Dict[str
561564 time .sleep (sleep_time )
562565
563566
567+ def regenerate_uuids_for_apps (user_config : Dict [str , Any ], app_config : Dict [str , Any ]) -> None :
568+ """
569+ Regenerate UUIDs for apps that require them, preserving prefixes or postfixes if defined.
570+
571+ Args:
572+ user_config (dict): The user configuration dictionary.
573+ app_config (dict): The app configuration dictionary.
574+ """
575+ for app_category in ['apps' , 'extra-apps' ]:
576+ for app in app_config .get (app_category , []):
577+ app_name = app ['name' ].lower ()
578+ app_user_config = user_config ['apps' ].get (app_name , {})
579+
580+ # Check if the app has a UUID flag and is enabled
581+ if app_user_config .get ('enabled' ) and 'uuid' in app .get ('flags' , {}):
582+ uuid_length = app ['flags' ]['uuid' ].get ('length' , 32 ) # Default to 32 if not specified
583+ prefix = app ['flags' ]['uuid' ].get ('prefix' , '' )
584+ postfix = app ['flags' ]['uuid' ].get ('postfix' , '' )
585+
586+ # Generate the new UUID part
587+ new_uuid_part = generate_uuid (uuid_length )
588+ new_uuid = f"{ prefix } { new_uuid_part } { postfix } "
589+
590+ app_user_config ['uuid' ] = new_uuid
591+ logging .info (f"Generated new UUID for { app_name } : { new_uuid } " )
592+
593+
564594def main (app_config_path : str , m4b_config_path : str , user_config_path : str ) -> None :
565595 """
566596 Main function for setting up user configurations.
0 commit comments