diff --git a/source/scripts/init/src/apply_system_defaults/apply_system_defaults.c b/source/scripts/init/src/apply_system_defaults/apply_system_defaults.c index 0a589550..a7b83540 100644 --- a/source/scripts/init/src/apply_system_defaults/apply_system_defaults.c +++ b/source/scripts/init/src/apply_system_defaults/apply_system_defaults.c @@ -72,6 +72,11 @@ #define PARTNER_DEFAULT_MIGRATE_PSM "/tmp/.apply_partner_defaults_psm" #define PARTNER_DEFAULT_MIGRATE_FOR_NEW_PSM_MEMBER "/tmp/.apply_partner_defaults_new_psm_member" +#if defined(_ONESTACK_PRODUCT_REQ_) +#define BUSINESS_MODE_FILE "/nvram/.business-mode" +#define SETSTACKMODE_INIT_FLAG "/nvram/.setstackmode_intialize" +#endif + #define PARTNER_ID_LEN 64 #ifndef UNIT_TEST_DOCKER_SUPPORT @@ -2376,6 +2381,14 @@ static int apply_partnerId_default_values (char *data, char *PartnerID) APPLY_PRINT("%s - Deletion of %s file handled in PSM init \n", __FUNCTION__, PARTNER_DEFAULT_APPLY_FILE ); //Delete at PSM init //system( "rm -rf /nvram/.apply_partner_defaults" ); +#if defined(_ONESTACK_PRODUCT_REQ_) + // Partner defaults being applied (partner change) - need to reconfigure stackmode + if (access(SETSTACKMODE_INIT_FLAG, F_OK) == 0) + { + unlink(SETSTACKMODE_INIT_FLAG); + APPLY_PRINT("%s - Deleted %s to force stackmode reconfiguration\n", __FUNCTION__, SETSTACKMODE_INIT_FLAG); + } +#endif } if ( access( PARTNER_DEFAULT_MIGRATE_PSM , F_OK ) == 0 ) @@ -3529,6 +3542,36 @@ static void getPartnerIdWithRetry(char* buf, char* PartnerID) APPLY_PRINT("%s - Failed to apply_value_to_sysevent block into sysevent for '%s'\n", __FUNCTION__, PartnerID); } +#if defined(_ONESTACK_PRODUCT_REQ_) + // Set stackmode based on business-mode marker file + if (access(BUSINESS_MODE_FILE, F_OK) == 0) + { + // Business mode marker file exists, set to business mode + if (syscfg_set(NULL, "stackmode", "business") == 0) + { + syscfg_commit(); + APPLY_PRINT("%s - Set stackmode to business (marker file present)\n", __FUNCTION__); + } + else + { + APPLY_PRINT("%s - Failed to set stackmode to business\n", __FUNCTION__); + } + } + else + { + // No business mode marker file, set to residential mode + if (syscfg_set(NULL, "stackmode", "residential") == 0) + { + syscfg_commit(); + APPLY_PRINT("%s - Set stackmode to residential (no marker file)\n", __FUNCTION__); + } + else + { + APPLY_PRINT("%s - Failed to set stackmode to residential\n", __FUNCTION__); + } + } +#endif + sysevent_close(global_fd, global_id); return(0); diff --git a/source/scripts/init/system/utopia_init_xb6.sh b/source/scripts/init/system/utopia_init_xb6.sh index f21e3c78..2d75ea65 100755 --- a/source/scripts/init/system/utopia_init_xb6.sh +++ b/source/scripts/init/system/utopia_init_xb6.sh @@ -287,6 +287,27 @@ CheckAndReCreateDB() fi } +# Call setstackmode binary to set stackmode marker (with optimization) +if [ -x /usr/bin/setstackmode ]; then + SETSTACKMODE_INIT_FLAG="/nvram/.setstackmode_intialize" + + # Optimization: Check if initialization flag exists + if [ -f "$SETSTACKMODE_INIT_FLAG" ]; then + echo "[utopia][init] setstackmode already initialized, skipping binary execution" + else + echo "[utopia][init] Calling setstackmode binary to configure stack mode" + /usr/bin/setstackmode + ret=$? + if [ $ret -eq 0 ]; then + echo "[utopia][init] setstackmode binary executed successfully (return code: $ret)" + else + echo "[utopia][init] setstackmode binary failed with return code: $ret" + fi + fi +else + echo "[utopia][init] setstackmode binary not found, skipping stack mode configuration" +fi + echo "[utopia][init] Starting syscfg using file store ($SYSCFG_NEW_FILE)" if [ -f $SYSCFG_NEW_FILE ]; then # Check and remove immutable attribute on syscfg.db if set