summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Estabrook <jestabro@vyos.io>2026-03-29 20:47:37 -0500
committerJohn Estabrook <jestabro@vyos.io>2026-04-15 15:17:27 -0500
commit858695fb4eba71cffa774f94595e5c8c8404392c (patch)
treedf4b80dbad45a8292b1f2158d94d2b407170efdc
parentd9c7cf3bc0e76661f48bd0ce13acfc7be182a326 (diff)
downloadvyos-1x-858695fb4eba71cffa774f94595e5c8c8404392c.tar.gz
vyos-1x-858695fb4eba71cffa774f94595e5c8c8404392c.zip
T8445: generate list of activation scripts at build time
-rw-r--r--.gitignore3
-rw-r--r--Makefile6
-rwxr-xr-xscripts/generate-activation-scripts-json.py55
3 files changed, 63 insertions, 1 deletions
diff --git a/.gitignore b/.gitignore
index 06ae0c0db..06ab1dcd2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -155,6 +155,9 @@ data/reftree.cache
data/op_cache.json
# autogenerated vyos-configd JSON definition
data/configd-include.json
+# autogenerated activation-scripts JSON definition
+data/activation-list
+data/activation-init
# autogenerated vyos-commitd protobuf files
python/vyos/proto/*.desc
diff --git a/Makefile b/Makefile
index 131f05917..df89b555e 100644
--- a/Makefile
+++ b/Makefile
@@ -78,7 +78,7 @@ vyshim:
$(MAKE) -C $(SHIM_DIR)
.PHONY: all
-all: clean copyright libvyosconfig pylint interface_definitions op_mode_definitions test j2lint vyshim generate-configd-include-json
+all: clean copyright libvyosconfig pylint interface_definitions op_mode_definitions test j2lint vyshim generate-configd-include-json generate-activation-scripts-json
.PHONY: copyright
copyright:
@@ -130,6 +130,10 @@ deb:
generate-configd-include-json:
@scripts/generate-configd-include-json.py
+.PHONY: generate-activation-scripts-json
+generate-activation-scripts-json:
+ @scripts/generate-activation-scripts-json.py
+
.PHONY: schema
schema:
trang -I rnc -O rng schema/interface_definition.rnc schema/interface_definition.rng
diff --git a/scripts/generate-activation-scripts-json.py b/scripts/generate-activation-scripts-json.py
new file mode 100755
index 000000000..e8a7f34b4
--- /dev/null
+++ b/scripts/generate-activation-scripts-json.py
@@ -0,0 +1,55 @@
+#!/usr/bin/env python3
+#
+# Copyright (C) VyOS Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License version 2 or later as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+
+import re
+import json
+from pathlib import Path
+
+
+def filter_key(s: Path):
+ s = s.stem
+ return re.match(r'\d+\-.+', s)
+
+
+def sort_key(s: Path):
+ s = s.stem
+ pre, rem = re.match(r'(\d+)(?:-)(.+)', s).groups()
+ return int(pre), rem
+
+
+activation_dir = 'src/activation-scripts'
+activation_list = 'data/activation-list'
+activation_list_init = 'data/activation-init'
+
+activation_scripts = Path(activation_dir).glob('*.py')
+
+filtered = filter(filter_key, activation_scripts)
+script_list = sorted(filtered, key=sort_key)
+
+# default on system update
+script_dict = dict.fromkeys(map(lambda s: s.stem, script_list), 'enabled')
+# exceptions:
+# only enabled for script_dict_init
+script_dict['00-first-installed-boot'] = 'never'
+# for backward compatibility on system update
+script_dict['20-ethernet-offload'] = 'off'
+
+# installed on image creation
+script_dict_init = dict.fromkeys(map(lambda s: s.stem, script_list), 'enabled')
+
+Path(activation_list).write_text(json.dumps(script_dict))
+Path(activation_list_init).write_text(json.dumps(script_dict_init))