-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[build][systemd] Mask disabled services by default (#4721)
When building the SONiC image, used systemd to mask all services which are set to "disabled" in init_cfg.json. This PR depends on sonic-net/sonic-utilities#944, otherwise `config load_minigraph will fail when trying to restart disabled services.
- Loading branch information
Showing
2 changed files
with
20 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/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)]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters