mirror of
				https://github.com/Telecominfraproject/ols-nos.git
				synced 2025-11-03 19:47:56 +00:00 
			
		
		
		
	When building the SONiC image, used systemd to mask all services which are set to "disabled" in init_cfg.json. This PR depends on https://github.com/Azure/sonic-utilities/pull/944, otherwise `config load_minigraph will fail when trying to restart disabled services.
		
			
				
	
	
		
			14 lines
		
	
	
		
			467 B
		
	
	
	
		
			Python
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			14 lines
		
	
	
		
			467 B
		
	
	
	
		
			Python
		
	
	
		
			Executable File
		
	
	
	
	
#!/usr/bin/env python3
 | 
						|
 | 
						|
import json
 | 
						|
import subprocess
 | 
						|
 | 
						|
INIT_CFG_FILE_PATH = '/etc/sonic/init_cfg.json'
 | 
						|
 | 
						|
with open(INIT_CFG_FILE_PATH) as init_cfg_file:
 | 
						|
    init_cfg = json.load(init_cfg_file)
 | 
						|
    if 'FEATURE' in init_cfg:
 | 
						|
        for feature_name, feature_props in init_cfg['FEATURE'].items():
 | 
						|
            if 'status' in feature_props and feature_props['status'] == 'disabled':
 | 
						|
                subprocess.run(['systemctl', 'mask', '{}.service'.format(feature_name)])
 |