summaryrefslogtreecommitdiff
path: root/data/templates
diff options
context:
space:
mode:
authorJohn Estabrook <jestabro@vyos.io>2023-10-21 13:33:37 -0500
committerJohn Estabrook <jestabro@vyos.io>2023-11-15 11:29:04 -0600
commit96b65e90fbfa1fe63d97929ac86fc910abb0caa9 (patch)
tree467b257caea8c6118dfef5eb3ac54c79b7712167 /data/templates
parent8efab9ee8cdb0e65dddb9d3ba97de8ddcf3666dc (diff)
downloadvyos-1x-96b65e90fbfa1fe63d97929ac86fc910abb0caa9.tar.gz
vyos-1x-96b65e90fbfa1fe63d97929ac86fc910abb0caa9.zip
image: T4516: support for interoperability of legacy/new image tools
This commit allows management of system images with either new or legacy tools: 'add/delete/rename system image' and 'set default' are translated appropriately on booting between images with the old and new tools. Consequently, the warning of the initial commit of T4516 is dropped.
Diffstat (limited to 'data/templates')
-rw-r--r--data/templates/grub/grub_compat.j258
1 files changed, 58 insertions, 0 deletions
diff --git a/data/templates/grub/grub_compat.j2 b/data/templates/grub/grub_compat.j2
new file mode 100644
index 000000000..935172005
--- /dev/null
+++ b/data/templates/grub/grub_compat.j2
@@ -0,0 +1,58 @@
+{# j2lint: disable=S6 #}
+### Generated by VyOS image-tools v.{{ tools_version }} ###
+{% macro menu_name(mode) -%}
+{% if mode == 'normal' -%}
+ VyOS
+{%- elif mode == 'pw_reset' -%}
+ Lost password change
+{%- else -%}
+ Unknown
+{%- endif %}
+{%- endmacro %}
+{% macro console_name(type) -%}
+{% if type == 'tty' -%}
+ KVM
+{%- elif type == 'ttyS' -%}
+ Serial
+{%- elif type == 'ttyUSB' -%}
+ USB
+{%- else -%}
+ Unknown
+{%- endif %}
+{%- endmacro %}
+{% macro console_opts(type) -%}
+{% if type == 'tty' -%}
+ console=ttyS0,115200 console=tty0
+{%- elif type == 'ttyS' -%}
+ console=tty0 console=ttyS0,115200
+{%- elif type == 'ttyUSB' -%}
+ console=tty0 console=ttyUSB0,115200
+{%- else -%}
+ console=tty0 console=ttyS0,115200
+{%- endif %}
+{%- endmacro %}
+{% macro passwd_opts(mode) -%}
+{% if mode == 'pw_reset' -%}
+ init=/opt/vyatta/sbin/standalone_root_pw_reset
+{%- endif %}
+{%- endmacro %}
+set default={{ default }}
+set timeout={{ timeout }}
+{% if console_type == 'ttyS' %}
+serial --unit={{ console_num }} --speed=115200
+{% else %}
+serial --unit=0 --speed=115200
+{% endif %}
+terminal_output --append serial
+terminal_input serial console
+{% if efi %}
+insmod efi_gop
+insmod efi_uga
+{% endif %}
+
+{% for v in versions %}
+menuentry "{{ menu_name(v.bootmode) }} {{ v.version }} ({{ console_name(v.console_type) }} console)" {
+ linux /boot/{{ v.version }}/vmlinuz {{ v.boot_opts }} {{ console_opts(v.console_type) }} {{ passwd_opts(v.bootmode) }}
+ initrd /boot/{{ v.version }}/initrd.img
+}
+{% endfor %}